diff options
author | loos <loos@FreeBSD.org> | 2015-01-09 02:25:19 +0000 |
---|---|---|
committer | loos <loos@FreeBSD.org> | 2015-01-09 02:25:19 +0000 |
commit | 2b55fce49f93314345fff2d2bf9af96c8445a8d8 (patch) | |
tree | 2fb16f9e5a2b620c18b553496a981631866cce55 /sys/arm/broadcom | |
parent | 27e2f26e1531b869ff531fab5ac3ef06aae4d4f4 (diff) | |
download | FreeBSD-src-2b55fce49f93314345fff2d2bf9af96c8445a8d8.zip FreeBSD-src-2b55fce49f93314345fff2d2bf9af96c8445a8d8.tar.gz |
MFC r273329, r273337 and r274415
Add another wakeup() after actually set the bus as free.
This fix a race where the threads waiting for the bus would wake up early
and still see bus as busy.
While here, give a better description to wmesg for the two use cases we
have (bus and io waiting).
Fix the mtx_sleep() error checking, catch all errors and not only
EWOULDBLOCK.
Do not print any message at errors. The errors are properly sent to upper
layers which should be able to deal with it, including printing the errors
when they need to.
The error message was quite annoying while scanning the i2c bus.
Diffstat (limited to 'sys/arm/broadcom')
-rw-r--r-- | sys/arm/broadcom/bcm2835/bcm2835_bsc.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_bsc.c b/sys/arm/broadcom/bcm2835/bcm2835_bsc.c index 1e486a4..f8e9801 100644 --- a/sys/arm/broadcom/bcm2835/bcm2835_bsc.c +++ b/sys/arm/broadcom/bcm2835/bcm2835_bsc.c @@ -395,7 +395,7 @@ bcm_bsc_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) /* If the controller is busy wait until it is available. */ while (sc->sc_flags & BCM_I2C_BUSY) - mtx_sleep(dev, &sc->sc_mtx, 0, "bcm_bsc", 0); + mtx_sleep(dev, &sc->sc_mtx, 0, "bscbusw", 0); /* Now we have control over the BSC controller. */ sc->sc_flags = BCM_I2C_BUSY; @@ -439,19 +439,21 @@ bcm_bsc_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) BCM_BSC_CTRL_ST | read | intr); /* Wait for the transaction to complete. */ - err = mtx_sleep(dev, &sc->sc_mtx, 0, "bcm_bsc", hz); + err = mtx_sleep(dev, &sc->sc_mtx, 0, "bsciow", hz); - /* Check if we have a timeout or an I2C error. */ - if ((sc->sc_flags & BCM_I2C_ERROR) || err == EWOULDBLOCK) { - device_printf(sc->sc_dev, "I2C error\n"); + /* Check for errors. */ + if (err == 0 && (sc->sc_flags & BCM_I2C_ERROR)) err = EIO; + if (err != 0) break; - } } /* Clean the controller flags. */ sc->sc_flags = 0; + /* Wake up the threads waiting for bus. */ + wakeup(dev); + BCM_BSC_UNLOCK(sc); return (err); |