Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/gpio/gpiobus.c
Show First 20 Lines • Show All 553 Lines • ▼ Show 20 Lines | |||||
gpiobus_acquire_bus(device_t busdev, device_t child, int how) | gpiobus_acquire_bus(device_t busdev, device_t child, int how) | ||||
{ | { | ||||
struct gpiobus_softc *sc; | struct gpiobus_softc *sc; | ||||
sc = device_get_softc(busdev); | sc = device_get_softc(busdev); | ||||
GPIOBUS_ASSERT_UNLOCKED(sc); | GPIOBUS_ASSERT_UNLOCKED(sc); | ||||
GPIOBUS_LOCK(sc); | GPIOBUS_LOCK(sc); | ||||
if (sc->sc_owner != NULL) { | if (sc->sc_owner != NULL) { | ||||
if (sc->sc_owner == child) | |||||
panic("gpiobus: %s already acquired the bus\n", device_get_nameunit(child)); | |||||
imp: This should be done as a separate commit. | |||||
if (how == GPIOBUS_DONTWAIT) { | if (how == GPIOBUS_DONTWAIT) { | ||||
GPIOBUS_UNLOCK(sc); | GPIOBUS_UNLOCK(sc); | ||||
return (EWOULDBLOCK); | return (EWOULDBLOCK); | ||||
} | } | ||||
while (sc->sc_owner != NULL) | while (sc->sc_owner != NULL) { | ||||
device_printf(busdev, "%s is waiting for %s to drop the bus\n", device_get_name(child), device_get_name(sc->sc_owner)); | |||||
mtx_sleep(sc, &sc->sc_mtx, 0, "gpiobuswait", 0); | mtx_sleep(sc, &sc->sc_mtx, 0, "gpiobuswait", 0); | ||||
} | |||||
} | } | ||||
Not Done Inline ActionsThis is useless debugging. imp: This is useless debugging. | |||||
sc->sc_owner = child; | sc->sc_owner = child; | ||||
GPIOBUS_UNLOCK(sc); | GPIOBUS_UNLOCK(sc); | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | static void | ||||
gpiobus_release_bus(device_t busdev, device_t child) | gpiobus_release_bus(device_t busdev, device_t child) | ||||
▲ Show 20 Lines • Show All 185 Lines • Show Last 20 Lines |
This should be done as a separate commit.