diff options
author | loos <loos@FreeBSD.org> | 2015-01-31 12:17:07 +0000 |
---|---|---|
committer | loos <loos@FreeBSD.org> | 2015-01-31 12:17:07 +0000 |
commit | a2924f5feeb568dc5a1dc2b53be66542d8825e87 (patch) | |
tree | 32cccced059cc9d62c6880a990ae89819afccc09 /sys/arm/freescale/imx | |
parent | 4b26a78e587bd62c2b734d552d2ec5a699e6d93f (diff) | |
download | FreeBSD-src-a2924f5feeb568dc5a1dc2b53be66542d8825e87.zip FreeBSD-src-a2924f5feeb568dc5a1dc2b53be66542d8825e87.tar.gz |
Clean up and fix the device detach routine and the failure path on GPIO
drivers.
This paves the way for upcoming work.
Diffstat (limited to 'sys/arm/freescale/imx')
-rw-r--r-- | sys/arm/freescale/imx/imx_gpio.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sys/arm/freescale/imx/imx_gpio.c b/sys/arm/freescale/imx/imx_gpio.c index c23f75b..911c9bbb 100644 --- a/sys/arm/freescale/imx/imx_gpio.c +++ b/sys/arm/freescale/imx/imx_gpio.c @@ -389,6 +389,8 @@ imx51_gpio_attach(device_t dev) if (bus_alloc_resources(dev, imx_gpio_spec, sc->sc_res)) { device_printf(dev, "could not allocate resources\n"); + bus_release_resources(dev, imx_gpio_spec, sc->sc_res); + mtx_destroy(&sc->sc_mtx); return (ENXIO); } @@ -411,6 +413,7 @@ imx51_gpio_attach(device_t dev) imx51_gpio_intr, NULL, sc, &sc->gpio_ih[irq]))) { device_printf(dev, "WARNING: unable to register interrupt handler\n"); + imx51_gpio_detach(dev); return (ENXIO); } } @@ -434,6 +437,7 @@ imx51_gpio_attach(device_t dev) static int imx51_gpio_detach(device_t dev) { + int irq; struct imx51_gpio_softc *sc; sc = device_get_softc(dev); @@ -441,13 +445,12 @@ imx51_gpio_detach(device_t dev) KASSERT(mtx_initialized(&sc->sc_mtx), ("gpio mutex not initialized")); bus_generic_detach(dev); - - if (sc->sc_res[3]) - bus_release_resources(dev, imx_gpio0irq_spec, &sc->sc_res[3]); - - if (sc->sc_res[0]) - bus_release_resources(dev, imx_gpio_spec, sc->sc_res); - + for (irq = 1; irq <= sc->sc_l_irq; irq ++) { + if (sc->gpio_ih[irq]) + bus_teardown_intr(dev, sc->sc_res[irq], sc->gpio_ih[irq]); + } + bus_release_resources(dev, imx_gpio0irq_spec, &sc->sc_res[3]); + bus_release_resources(dev, imx_gpio_spec, sc->sc_res); mtx_destroy(&sc->sc_mtx); return(0); |