From 03302aa37f00a2cba5baebcb93b726befb671dc2 Mon Sep 17 00:00:00 2001 From: Luiz Otavio O Souza Date: Sun, 22 May 2016 03:55:57 +0000 Subject: [PATCH] Get rid of two consumers of gpiobus acquire/release. The GPIO hardware should not be owned by a single device, this defeats any chance of use of the GPIO controller as an interrupt source. ow(4) is now the only consumer of this 'feature' before we can remove it for good. Discussed with: ian, bsdimp --- sys/dev/gpio/gpioiic.c | 26 -------------------------- sys/dev/gpio/gpioled.c | 14 +++----------- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/sys/dev/gpio/gpioiic.c b/sys/dev/gpio/gpioiic.c index 4b39bd11075..0a84a295e0d 100644 --- a/sys/dev/gpio/gpioiic.c +++ b/sys/dev/gpio/gpioiic.c @@ -70,7 +70,6 @@ static int gpioiic_attach(device_t); /* iicbb interface */ static void gpioiic_reset_bus(device_t); -static int gpioiic_callback(device_t, int, caddr_t); static void gpioiic_setsda(device_t, int); static void gpioiic_setscl(device_t, int); static int gpioiic_getsda(device_t); @@ -161,30 +160,6 @@ gpioiic_reset_bus(device_t dev) GPIO_PIN_INPUT); } -static int -gpioiic_callback(device_t dev, int index, caddr_t data) -{ - struct gpioiic_softc *sc = device_get_softc(dev); - int error, how; - - how = GPIOBUS_DONTWAIT; - if (data != NULL && *(int*)data == IIC_WAIT) - how = GPIOBUS_WAIT; - error = 0; - switch (index) { - case IIC_REQUEST_BUS: - error = GPIOBUS_ACQUIRE_BUS(sc->sc_busdev, sc->sc_dev, how); - break; - case IIC_RELEASE_BUS: - GPIOBUS_RELEASE_BUS(sc->sc_busdev, sc->sc_dev); - break; - default: - error = EINVAL; - } - - return (error); -} - static void gpioiic_setsda(device_t dev, int val) { @@ -271,7 +246,6 @@ static device_method_t gpioiic_methods[] = { DEVMETHOD(device_detach, bus_generic_detach), /* iicbb interface */ - DEVMETHOD(iicbb_callback, gpioiic_callback), DEVMETHOD(iicbb_setsda, gpioiic_setsda), DEVMETHOD(iicbb_setscl, gpioiic_setscl), DEVMETHOD(iicbb_getsda, gpioiic_getsda), diff --git a/sys/dev/gpio/gpioled.c b/sys/dev/gpio/gpioled.c index 17ae8323dc5..bd77f5386d5 100644 --- a/sys/dev/gpio/gpioled.c +++ b/sys/dev/gpio/gpioled.c @@ -76,23 +76,15 @@ static int gpioled_detach(device_t); static void gpioled_control(void *priv, int onoff) { - int error; struct gpioled_softc *sc; sc = (struct gpioled_softc *)priv; GPIOLED_LOCK(sc); - error = GPIOBUS_ACQUIRE_BUS(sc->sc_busdev, sc->sc_dev, - GPIOBUS_DONTWAIT); - if (error != 0) { - GPIOLED_UNLOCK(sc); - return; - } - error = GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, - GPIOLED_PIN, GPIO_PIN_OUTPUT); - if (error == 0) + if (GPIOBUS_PIN_SETFLAGS(sc->sc_busdev, sc->sc_dev, GPIOLED_PIN, + GPIO_PIN_OUTPUT) == 0) { GPIOBUS_PIN_SET(sc->sc_busdev, sc->sc_dev, GPIOLED_PIN, onoff ? GPIO_PIN_HIGH : GPIO_PIN_LOW); - GPIOBUS_RELEASE_BUS(sc->sc_busdev, sc->sc_dev); + } GPIOLED_UNLOCK(sc); }