Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c iic_acquire_bus can fail



details:   https://anonhg.NetBSD.org/src/rev/901c58f5d4ab
branches:  trunk
changeset: 983895:901c58f5d4ab
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sun Jun 13 09:48:04 2021 +0000

description:
iic_acquire_bus can fail

diffstat:

 sys/dev/i2c/lm_i2c.c     |  10 ++++++----
 sys/dev/i2c/spdmem_i2c.c |  12 ++++++++----
 2 files changed, 14 insertions(+), 8 deletions(-)

diffs (78 lines):

diff -r 7cf69b99781e -r 901c58f5d4ab sys/dev/i2c/lm_i2c.c
--- a/sys/dev/i2c/lm_i2c.c      Sun Jun 13 09:47:36 2021 +0000
+++ b/sys/dev/i2c/lm_i2c.c      Sun Jun 13 09:48:04 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lm_i2c.c,v 1.6 2020/06/24 19:11:49 jdolecek Exp $      */
+/*     $NetBSD: lm_i2c.c,v 1.7 2021/06/13 09:48:44 mlelstv Exp $       */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lm_i2c.c,v 1.6 2020/06/24 19:11:49 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm_i2c.c,v 1.7 2021/06/13 09:48:44 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -119,7 +119,8 @@
        struct lm_i2c_softc *sc = (struct lm_i2c_softc *)lmsc;
        uint8_t cmd, data;
 
-       iic_acquire_bus(sc->sc_tag, 0);
+       if (iic_acquire_bus(sc->sc_tag, 0))
+               return 0;
 
        cmd = reg;
        iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
@@ -137,7 +138,8 @@
        struct lm_i2c_softc *sc = (struct lm_i2c_softc *)lmsc;
        uint8_t cmd, data;
 
-       iic_acquire_bus(sc->sc_tag, 0);
+       if (iic_acquire_bus(sc->sc_tag, 0))
+               return;
 
        cmd = reg;
        data = val;
diff -r 7cf69b99781e -r 901c58f5d4ab sys/dev/i2c/spdmem_i2c.c
--- a/sys/dev/i2c/spdmem_i2c.c  Sun Jun 13 09:47:36 2021 +0000
+++ b/sys/dev/i2c/spdmem_i2c.c  Sun Jun 13 09:48:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spdmem_i2c.c,v 1.21 2021/01/27 02:29:48 thorpej Exp $ */
+/* $NetBSD: spdmem_i2c.c,v 1.22 2021/06/13 09:48:04 mlelstv Exp $ */
 
 /*
  * Copyright (c) 2007 Nicolas Joly
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spdmem_i2c.c,v 1.21 2021/01/27 02:29:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spdmem_i2c.c,v 1.22 2021/06/13 09:48:04 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -107,7 +107,9 @@
 
        reg = 0;
 
-       iic_acquire_bus(sc->sc_tag, 0);
+       rv = iic_acquire_bus(sc->sc_tag, 0);
+       if (rv)
+               return rv;
 
        /*
         * Try to read byte 0 and 2. If it failed, it's not spdmem or a device
@@ -265,7 +267,9 @@
 
        reg = addr & 0xff;
 
-       iic_acquire_bus(sc->sc_tag, 0);
+       rv = iic_acquire_bus(sc->sc_tag, 0);
+       if (rv)
+               return rv;
 
        if (addr & 0x100) {
                rv = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_page1,



Home | Main Index | Thread Index | Old Index