Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/i2c No need to use I2C_F_POLL here.



details:   https://anonhg.NetBSD.org/src/rev/ef6cca66c229
branches:  trunk
changeset: 847734:ef6cca66c229
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jan 02 17:09:59 2020 +0000

description:
No need to use I2C_F_POLL here.

XXX This entire driver needs to have its error reporting overhauled.

diffstat:

 sys/dev/i2c/rkpmic.c |  26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diffs (67 lines):

diff -r acee67163121 -r ef6cca66c229 sys/dev/i2c/rkpmic.c
--- a/sys/dev/i2c/rkpmic.c      Thu Jan 02 17:03:05 2020 +0000
+++ b/sys/dev/i2c/rkpmic.c      Thu Jan 02 17:09:59 2020 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
                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 @@
 {
        struct rkpmic_softc * const sc = ch->cookie;
        uint8_t val;
+       int error;
 
-       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_GET_TIME | RTC_CTRL_READSEL);



Home | Main Index | Thread Index | Old Index