summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_bsc.c14
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);
OpenPOWER on IntegriCloud