]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Use IIC_EBUSBSY and IIC_BUSERR status values consistantly across all drivers.
authorian <ian@FreeBSD.org>
Fri, 9 Oct 2015 22:49:50 +0000 (22:49 +0000)
committerian <ian@FreeBSD.org>
Fri, 9 Oct 2015 22:49:50 +0000 (22:49 +0000)
Make it clearer what each one means in the comments that define them.

IIC_BUSBSY was used in many places to mean two different things, either
"someone else has reserved the bus so you have to wait until they're done"
or "the signal level on the bus was not in the state I expected before/after
issuing some command".

Now IIC_BUSERR is used consistantly to refer to protocol/signaling errors,
and IIC_BUSBSY refers to ownership/reservation of the bus.

sys/arm/freescale/imx/imx_i2c.c
sys/arm/freescale/vybrid/vf_i2c.c
sys/arm/samsung/exynos/exynos5_i2c.c
sys/dev/iicbus/iicoc.c
sys/dev/iicbus/iiconf.h
sys/dev/pcf/pcf.c
sys/powerpc/mpc85xx/i2c.c

index ad2f6b7adc46605a51da94e6030596e8edf02679..0249275d26f8122adc7f8676536c0262cbe681db 100644 (file)
@@ -243,7 +243,7 @@ wait_for_xfer(struct i2c_softc *sc, int checkack)
                sr = i2c_read_reg(sc, I2C_STATUS_REG);
                if (sr & I2CSR_MIF) {
                         if (sr & I2CSR_MAL) 
-                               return (IIC_EBUSBSY);
+                               return (IIC_EBUSERR);
                        else if (checkack && (sr & I2CSR_RXAK))
                                return (IIC_ENOACK);
                        else
@@ -350,7 +350,7 @@ i2c_start(device_t dev, u_char slave, int timeout)
        i2c_write_reg(sc, I2C_CONTROL_REG, I2CCR_MEN);
        DELAY(10); /* Delay for controller to sample bus state. */
        if (i2c_read_reg(sc, I2C_STATUS_REG) & I2CSR_MBB) {
-               return (i2c_error_handler(sc, IIC_EBUSBSY));
+               return (i2c_error_handler(sc, IIC_EBUSERR));
        }
        i2c_write_reg(sc, I2C_CONTROL_REG, I2CCR_MEN | I2CCR_MSTA | I2CCR_MTX);
        if ((error = wait_for_busbusy(sc, true)) != IIC_NOERR)
index c554ce2e2686d534847562d70dce652c765e3d61..8008d1af8973038c27223b4b5cded1b68a218f3d 100644 (file)
@@ -232,7 +232,7 @@ i2c_repeated_start(device_t dev, u_char slave, int timeout)
 
        if ((READ1(sc, I2C_IBSR) & IBSR_IBB) == 0) {
                mtx_unlock(&sc->mutex);
-               return (IIC_EBUSBSY);
+               return (IIC_EBUSERR);
        }
 
        /* Set repeated start condition */
@@ -275,7 +275,7 @@ i2c_start(device_t dev, u_char slave, int timeout)
        if (READ1(sc, I2C_IBSR) & IBSR_IBB) {
                mtx_unlock(&sc->mutex);
                vf_i2c_dbg(sc, "cant i2c start: IIC_EBUSBSY\n");
-               return (IIC_EBUSBSY);
+               return (IIC_EBUSERR);
        }
 
        /* Set start condition */
index 294249a5a354af7fa766c1459ba87961a6eee1da..d8791386bcbbf84d71374b496488da9b0b0ec4ad 100644 (file)
@@ -263,8 +263,8 @@ i2c_start(device_t dev, u_char slave, int timeout)
        error = wait_for_nibb(sc);
        if (error) {
                mtx_unlock(&sc->mutex);
-               DPRINTF("cant i2c start: IIC_EBUSBSY\n");
-               return (IIC_EBUSBSY);
+               DPRINTF("cant i2c start: IIC_EBUSERR\n");
+               return (IIC_EBUSERR);
        }
 
        reg = READ1(sc, I2CCON);
index de17e74ac52912292111641a62c15ffe99f1e2df..45f1692fa479d28094285742a963c465af3e7671 100644 (file)
@@ -236,7 +236,7 @@ iicoc_detach(device_t dev)
 static int 
 iicoc_start(device_t dev, u_char slave, int timeout)
 {
-       int error = IIC_EBUSBSY;
+       int error = IIC_EBUSERR;
        struct iicoc_softc *sc;
 
        sc = device_get_softc(dev);
index 092ba8de065ec94d91e9459174e8ebd15201b3bc..9ceaeb8bab3cd9889f05c3ed2fa6e13aac48b580 100644 (file)
  * adapter layer errors
  */
 #define IIC_NOERR      0x0     /* no error occured */
-#define IIC_EBUSERR    0x1     /* bus error */
+#define IIC_EBUSERR    0x1     /* bus error (hardware not in expected state) */
 #define IIC_ENOACK     0x2     /* ack not received until timeout */
 #define IIC_ETIMEOUT   0x3     /* timeout */
-#define IIC_EBUSBSY    0x4     /* bus busy */
+#define IIC_EBUSBSY    0x4     /* bus busy (reserved by another client) */
 #define IIC_ESTATUS    0x5     /* status error */
 #define IIC_EUNDERFLOW 0x6     /* slave ready for more data */
 #define IIC_EOVERFLOW  0x7     /* too much data */
index 55e03460fb7ee8eed84b900bfe390d376c7a296b..f9252b57c6388d700effd4287c8ccb217a7713b3 100644 (file)
@@ -170,7 +170,7 @@ pcf_start(device_t dev, u_char slave, int timeout)
                printf("pcf: busy!\n");
 #endif
                PCF_UNLOCK(sc);
-               return (IIC_EBUSBSY);
+               return (IIC_EBUSERR);
        }
 
        /* set slave address to PCF. Last bit (LSB) must be set correctly
index f21c845c058a3857de78583c481a40e97fd83892..e02a08bdb554bdb9ef3efed122371647526f0357 100644 (file)
@@ -284,7 +284,7 @@ i2c_start(device_t dev, u_char slave, int timeout)
                debugf("bus busy");
                mtx_unlock(&sc->mutex);
                i2c_stop(dev);
-               return (IIC_EBUSBSY);
+               return (IIC_EBUSERR);
        }
 
        /* Set start condition */