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/d83de2d51f99
branches:  trunk
changeset: 466804:d83de2d51f99
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jan 02 16:24:51 2020 +0000

description:
No need to use I2C_F_POLL here.

diffstat:

 sys/dev/i2c/ds1307.c  |  49 ++++++++++++++++++++++++-------------------------
 sys/dev/i2c/m41st84.c |  47 +++++++++++++++++++++++------------------------
 sys/dev/i2c/m41t00.c  |  32 ++++++++++++++++----------------
 sys/dev/i2c/max6900.c |  40 ++++++++++++++++++++--------------------
 4 files changed, 83 insertions(+), 85 deletions(-)

diffs (truncated from 564 to 300 lines):

diff -r a8426917211e -r d83de2d51f99 sys/dev/i2c/ds1307.c
--- a/sys/dev/i2c/ds1307.c      Thu Jan 02 16:18:37 2020 +0000
+++ b/sys/dev/i2c/ds1307.c      Thu Jan 02 16:24:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ds1307.c,v 1.33 2019/09/29 05:35:29 macallan Exp $     */
+/*     $NetBSD: ds1307.c,v 1.34 2020/01/02 16:24:51 thorpej Exp $      */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.33 2019/09/29 05:35:29 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ds1307.c,v 1.34 2020/01/02 16:24:51 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -524,7 +524,7 @@
 
        KASSERT(DSXXXX_RTC_SIZE >= dm->dm_rtc_size);
 
-       if ((error = iic_acquire_bus(sc->sc_tag, I2C_F_POLL)) != 0) {
+       if ((error = iic_acquire_bus(sc->sc_tag, 0)) != 0) {
                aprint_error_dev(sc->sc_dev,
                    "%s: failed to acquire I2C bus: %d\n",
                    __func__, error);
@@ -536,11 +536,11 @@
                cmdbuf[0] = dm->dm_rtc_start + i;
 
                error = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
-                   sc->sc_address, cmdbuf, 1, &bcd[i], 1, I2C_F_POLL);
+                   sc->sc_address, cmdbuf, 1, &bcd[i], 1, 0);
        }
 
        /* Done with I2C */
-       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+       iic_release_bus(sc->sc_tag, 0);
 
        if (error != 0) {
                aprint_error_dev(sc->sc_dev,
@@ -609,7 +609,7 @@
        if (dt->dt_year - offset >= 100)
                bcd[DSXXXX_MONTH] |= DSXXXX_MONTH_CENTURY;
 
-       if ((error = iic_acquire_bus(sc->sc_tag, I2C_F_POLL)) != 0) {
+       if ((error = iic_acquire_bus(sc->sc_tag, 0)) != 0) {
                aprint_error_dev(sc->sc_dev,
                    "%s: failed to acquire I2C bus: %d\n",
                    __func__, error);
@@ -620,8 +620,8 @@
        cmdbuf[0] = dm->dm_ch_reg;
 
        if ((error = iic_exec(sc->sc_tag, I2C_OP_READ, sc->sc_address,
-           cmdbuf, 1, &cmdbuf[1], 1, I2C_F_POLL)) != 0) {
-               iic_release_bus(sc->sc_tag, I2C_F_POLL);
+           cmdbuf, 1, &cmdbuf[1], 1, 0)) != 0) {
+               iic_release_bus(sc->sc_tag, 0);
                aprint_error_dev(sc->sc_dev,
                    "%s: failed to read Hold Clock: %d\n",
                    __func__, error);
@@ -634,8 +634,8 @@
                cmdbuf[1] |= dm->dm_ch_value;
 
        if ((error = iic_exec(sc->sc_tag, I2C_OP_WRITE, sc->sc_address,
-           cmdbuf, 1, &cmdbuf[1], 1, I2C_F_POLL)) != 0) {
-               iic_release_bus(sc->sc_tag, I2C_F_POLL);
+           cmdbuf, 1, &cmdbuf[1], 1, 0)) != 0) {
+               iic_release_bus(sc->sc_tag, 0);
                aprint_error_dev(sc->sc_dev,
                    "%s: failed to write Hold Clock: %d\n",
                    __func__, error);
@@ -658,8 +658,8 @@
                                bcd[i] |= dm->dm_ch_value;
                }
                if ((error = iic_exec(sc->sc_tag, op, sc->sc_address,
-                   cmdbuf, 1, &bcd[i], 1, I2C_F_POLL)) != 0) {
-                       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+                   cmdbuf, 1, &bcd[i], 1, 0)) != 0) {
+                       iic_release_bus(sc->sc_tag, 0);
                        aprint_error_dev(sc->sc_dev,
                            "%s: failed to write rtc at 0x%x: %d\n",
                            __func__, i, error);
@@ -679,9 +679,8 @@
                        cmdbuf[1] &= ~dm->dm_ch_value;
 
                if ((error = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP,
-                   sc->sc_address, cmdbuf, 1, &cmdbuf[1], 1,
-                   I2C_F_POLL)) != 0) {
-                       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+                   sc->sc_address, cmdbuf, 1, &cmdbuf[1], 1, 0)) != 0) {
+                       iic_release_bus(sc->sc_tag, 0);
                        aprint_error_dev(sc->sc_dev,
                            "%s: failed to Hold Clock: %d\n",
                            __func__, error);
@@ -689,7 +688,7 @@
                }
        }
 
-       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+       iic_release_bus(sc->sc_tag, 0);
 
        return 1;
 }
@@ -740,7 +739,7 @@
        uint8_t buf[4];
        int error;
 
-       if ((error = iic_acquire_bus(sc->sc_tag, I2C_F_POLL)) != 0) {
+       if ((error = iic_acquire_bus(sc->sc_tag, 0)) != 0) {
                aprint_error_dev(sc->sc_dev,
                    "%s: failed to acquire I2C bus: %d\n",
                    __func__, error);
@@ -750,10 +749,10 @@
        /* read all registers: */
        uint8_t reg = dm->dm_rtc_start;
        error = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_address,
-            &reg, 1, buf, 4, I2C_F_POLL);
+            &reg, 1, buf, 4, 0);
 
        /* Done with I2C */
-       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+       iic_release_bus(sc->sc_tag, 0);
 
        if (error != 0) {
                aprint_error_dev(sc->sc_dev,
@@ -790,7 +789,7 @@
        buf[4] = (t >> 24) & 0xff;
        buf[5] = 0;
 
-       if ((error = iic_acquire_bus(sc->sc_tag, I2C_F_POLL)) != 0) {
+       if ((error = iic_acquire_bus(sc->sc_tag, 0)) != 0) {
                aprint_error_dev(sc->sc_dev,
                    "%s: failed to acquire I2C bus: %d\n",
                    __func__, error);
@@ -798,10 +797,10 @@
        }
 
        error = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_address,
-           &buf, buflen, NULL, 0, I2C_F_POLL);
+           &buf, buflen, NULL, 0, 0);
 
        /* Done with I2C */
-       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+       iic_release_bus(sc->sc_tag, 0);
 
        /* send data */
        if (error != 0) {
@@ -824,7 +823,7 @@
        if ((sc->sc_model.dm_flags & DSRTC_FLAG_TEMP) == 0)
                return ENOTSUP;
 
-       if ((error = iic_acquire_bus(sc->sc_tag, I2C_F_POLL)) != 0) {
+       if ((error = iic_acquire_bus(sc->sc_tag, 0)) != 0) {
                aprint_error_dev(sc->sc_dev,
                    "%s: failed to acquire I2C bus: %d\n",
                    __func__, error);
@@ -833,10 +832,10 @@
 
        /* read temperature registers: */
        error = iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_address,
-            &reg, 1, buf, 2, I2C_F_POLL);
+            &reg, 1, buf, 2, 0);
 
        /* Done with I2C */
-       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+       iic_release_bus(sc->sc_tag, 0);
 
        if (error != 0) {
                aprint_error_dev(sc->sc_dev,
diff -r a8426917211e -r d83de2d51f99 sys/dev/i2c/m41st84.c
--- a/sys/dev/i2c/m41st84.c     Thu Jan 02 16:18:37 2020 +0000
+++ b/sys/dev/i2c/m41st84.c     Thu Jan 02 16:24:51 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: m41st84.c,v 1.24 2018/06/16 21:22:13 thorpej Exp $     */
+/*     $NetBSD: m41st84.c,v 1.25 2020/01/02 16:28:02 thorpej Exp $     */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: m41st84.c,v 1.24 2018/06/16 21:22:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m41st84.c,v 1.25 2020/01/02 16:28:02 thorpej Exp $");
 
 #include "opt_strtc.h"
 
@@ -294,7 +294,7 @@
        u_int8_t bcd[M41ST84_REG_DATE_BYTES], cmdbuf[2];
        int i;
 
-       if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL)) {
+       if (iic_acquire_bus(sc->sc_tag, 0)) {
                aprint_error_dev(sc->sc_dev,
                    "strtc_clock_read: failed to acquire I2C bus\n");
                return (0);
@@ -307,8 +307,8 @@
         */
        cmdbuf[0] = M41ST84_REG_AL_HOUR;
        if (iic_exec(sc->sc_tag, I2C_OP_READ, sc->sc_address,
-                    cmdbuf, 1, &cmdbuf[1], 1, I2C_F_POLL)) {
-               iic_release_bus(sc->sc_tag, I2C_F_POLL);
+                    cmdbuf, 1, &cmdbuf[1], 1, 0)) {
+               iic_release_bus(sc->sc_tag, 0);
                aprint_error_dev(sc->sc_dev,
                    "strtc_clock_read: failed to read HT\n");
                return (0);
@@ -316,8 +316,8 @@
        if (cmdbuf[1] & M41ST84_AL_HOUR_HT) {
                cmdbuf[1] &= ~M41ST84_AL_HOUR_HT;
                if (iic_exec(sc->sc_tag, I2C_OP_WRITE, sc->sc_address,
-                            cmdbuf, 1, &cmdbuf[1], 1, I2C_F_POLL)) {
-                       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+                            cmdbuf, 1, &cmdbuf[1], 1, 0)) {
+                       iic_release_bus(sc->sc_tag, 0);
                        aprint_error_dev(sc->sc_dev,
                            "strtc_clock_read: failed to reset HT\n");
                        return (0);
@@ -330,8 +330,8 @@
 
                if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
                             sc->sc_address, cmdbuf, 1,
-                            &bcd[i], 1, I2C_F_POLL)) {
-                       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+                            &bcd[i], 1, 0)) {
+                       iic_release_bus(sc->sc_tag, 0);
                        aprint_error_dev(sc->sc_dev,
                            "strtc_clock_read: failed to read rtc "
                            "at 0x%x\n", i);
@@ -340,7 +340,7 @@
        }
 
        /* Done with I2C */
-       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+       iic_release_bus(sc->sc_tag, 0);
 
        /*
         * Convert the M41ST84's register values into something useable
@@ -376,7 +376,7 @@
        bcd[M41ST84_REG_MONTH] = bintobcd(dt->dt_mon);
        bcd[M41ST84_REG_YEAR] = bintobcd((dt->dt_year - POSIX_BASE_YEAR) % 100);
 
-       if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL)) {
+       if (iic_acquire_bus(sc->sc_tag, 0)) {
                aprint_error_dev(sc->sc_dev,
                    "strtc_clock_write: failed to acquire I2C bus\n");
                return (0);
@@ -387,8 +387,8 @@
        cmdbuf[1] = M41ST84_SEC_ST;
 
        if (iic_exec(sc->sc_tag, I2C_OP_WRITE, sc->sc_address,
-                    cmdbuf, 1, &cmdbuf[1], 1, I2C_F_POLL)) {
-               iic_release_bus(sc->sc_tag, I2C_F_POLL);
+                    cmdbuf, 1, &cmdbuf[1], 1, 0)) {
+               iic_release_bus(sc->sc_tag, 0);
                aprint_error_dev(sc->sc_dev,
                    "strtc_clock_write: failed to Hold Clock\n");
                return (0);
@@ -401,8 +401,8 @@
         */
        cmdbuf[0] = M41ST84_REG_AL_HOUR;
        if (iic_exec(sc->sc_tag, I2C_OP_READ, sc->sc_address,
-                    cmdbuf, 1, &cmdbuf[1], 1, I2C_F_POLL)) {
-               iic_release_bus(sc->sc_tag, I2C_F_POLL);
+                    cmdbuf, 1, &cmdbuf[1], 1, 0)) {
+               iic_release_bus(sc->sc_tag, 0);
                aprint_error_dev(sc->sc_dev,
                    "strtc_clock_write: failed to read HT\n");
                return (0);
@@ -410,8 +410,8 @@
        if (cmdbuf[1] & M41ST84_AL_HOUR_HT) {
                cmdbuf[1] &= ~M41ST84_AL_HOUR_HT;
                if (iic_exec(sc->sc_tag, I2C_OP_WRITE, sc->sc_address,
-                            cmdbuf, 1, &cmdbuf[1], 1, I2C_F_POLL)) {
-                       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+                            cmdbuf, 1, &cmdbuf[1], 1, 0)) {
+                       iic_release_bus(sc->sc_tag, 0);
                        aprint_error_dev(sc->sc_dev,
                            "strtc_clock_write: failed to reset HT\n");
                        return (0);
@@ -426,9 +426,8 @@
                cmdbuf[0] = i;
                if (iic_exec(sc->sc_tag,
                             i ? I2C_OP_WRITE : I2C_OP_WRITE_WITH_STOP,
-                            sc->sc_address, cmdbuf, 1, &bcd[i], 1,
-                            I2C_F_POLL)) {
-                       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+                            sc->sc_address, cmdbuf, 1, &bcd[i], 1, 0)) {
+                       iic_release_bus(sc->sc_tag, 0);
                        aprint_error_dev(sc->sc_dev,
                            "strtc_clock_write: failed to write rtc "
                            " at 0x%x\n", i);
@@ -437,7 +436,7 @@
                }
        }
 
-       iic_release_bus(sc->sc_tag, I2C_F_POLL);
+       iic_release_bus(sc->sc_tag, 0);
 



Home | Main Index | Thread Index | Old Index