Module Name: src
Committed By: thorpej
Date: Thu Jan 2 17:10:00 UTC 2020
Modified Files:
src/sys/dev/i2c: rkpmic.c
Log Message:
No need to use I2C_F_POLL here.
XXX This entire driver needs to have its error reporting overhauled.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/i2c/rkpmic.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/i2c/rkpmic.c
diff -u src/sys/dev/i2c/rkpmic.c:1.6 src/sys/dev/i2c/rkpmic.c:1.7
--- src/sys/dev/i2c/rkpmic.c:1.6 Wed Jan 1 00:38:30 2020
+++ src/sys/dev/i2c/rkpmic.c Thu Jan 2 17:09:59 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: rkpmic.c,v 1.6 2020/01/01 00:38:30 jmcneill Exp $ */
+/* $NetBSD: rkpmic.c,v 1.7 2020/01/02 17:09:59 thorpej Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <[email protected]>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rkpmic.c,v 1.6 2020/01/01 00:38:30 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rkpmic.c,v 1.7 2020/01/02 17:09:59 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -249,24 +249,27 @@ rkpmic_write(struct rkpmic_softc *sc, ui
device_printf(sc->sc_dev, "error writing reg %#x: %d\n", reg, error);
}
-#define I2C_READ(sc, reg) rkpmic_read((sc), (reg), I2C_F_POLL)
-#define I2C_WRITE(sc, reg, val) rkpmic_write((sc), (reg), (val), I2C_F_POLL)
-#define I2C_LOCK(sc) iic_acquire_bus((sc)->sc_i2c, I2C_F_POLL)
-#define I2C_UNLOCK(sc) iic_release_bus((sc)->sc_i2c, I2C_F_POLL)
+#define I2C_READ(sc, reg) rkpmic_read((sc), (reg), 0)
+#define I2C_WRITE(sc, reg, val) rkpmic_write((sc), (reg), (val), 0)
+#define I2C_LOCK(sc) iic_acquire_bus((sc)->sc_i2c, 0)
+#define I2C_UNLOCK(sc) iic_release_bus((sc)->sc_i2c, 0)
static int
rkpmic_todr_settime(todr_chip_handle_t ch, struct clock_ymdhms *dt)
{
struct rkpmic_softc * const sc = ch->cookie;
uint8_t val;
+ int error;
if (dt->dt_year < 2000 || dt->dt_year >= 2100) {
device_printf(sc->sc_dev, "year out of range\n");
return EINVAL;
}
- if (I2C_LOCK(sc))
- return EBUSY;
+ if ((error = I2C_LOCK(sc)) != 0)
+ return error;
+
+ /* XXX Fix error reporting. */
val = I2C_READ(sc, RTC_CTRL_REG);
I2C_WRITE(sc, RTC_CTRL_REG, val | RTC_CTRL_STOP_RTC);
@@ -288,9 +291,12 @@ rkpmic_todr_gettime(todr_chip_handle_t c
{
struct rkpmic_softc * const sc = ch->cookie;
uint8_t val;
+ int error;
+
+ if ((error = I2C_LOCK(sc)) != 0)
+ return error;
- if (I2C_LOCK(sc))
- return EBUSY;
+ /* XXX Fix error reporting. */
val = I2C_READ(sc, RTC_CTRL_REG);
I2C_WRITE(sc, RTC_CTRL_REG, val | RTC_CTRL_GET_TIME | RTC_CTRL_READSEL);