summaryrefslogtreecommitdiff
path: root/sys/arch/loongson
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-02-24 22:14:20 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-02-24 22:14:20 +0000
commit2f72b19d92d8ab2d3459065eecf2c62a6af803b2 (patch)
treeb9d970b48785f42150df201974b81b12ba35d76d /sys/arch/loongson
parent84d3cbf044d2ed7c08de103181238b25a5c6c943 (diff)
Fix read/write logic to not rely upon M41T8X_TOD_START being zero.
No functional change.
Diffstat (limited to 'sys/arch/loongson')
-rw-r--r--sys/arch/loongson/dev/m41t8xclock.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/arch/loongson/dev/m41t8xclock.c b/sys/arch/loongson/dev/m41t8xclock.c
index 551e53ef047..9cc5f2b994f 100644
--- a/sys/arch/loongson/dev/m41t8xclock.c
+++ b/sys/arch/loongson/dev/m41t8xclock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: m41t8xclock.c,v 1.1 2010/02/19 00:21:45 miod Exp $ */
+/* $OpenBSD: m41t8xclock.c,v 1.2 2010/02/24 22:14:19 miod Exp $ */
/*
* Copyright (c) 2010 Miodrag Vallat.
@@ -102,7 +102,8 @@ m41t8xclock_get(void *cookie, time_t unused, struct tod_time *tt)
for (regno = M41T8X_TOD_START;
regno < M41T8X_TOD_START + M41T8X_TOD_LENGTH; regno++)
iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
- &regno, sizeof regno, data + regno, sizeof data[0], 0);
+ &regno, sizeof regno, data + regno - M41T8X_TOD_START,
+ sizeof data[0], 0);
splx(s);
iic_release_bus(sc->sc_tag, 0);
@@ -130,7 +131,8 @@ m41t8xclock_set(void *cookie, struct tod_time *tt)
for (regno = M41T8X_TOD_START;
regno < M41T8X_TOD_START + M41T8X_TOD_LENGTH; regno++)
iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
- &regno, sizeof regno, data + regno, sizeof data[0], 0);
+ &regno, sizeof regno, data + regno - M41T8X_TOD_START,
+ sizeof data[0], 0);
/* compute new state */
data[M41T8X_HSEC] = 0;
data[M41T8X_SEC] = bin2bcd(tt->sec);