summaryrefslogtreecommitdiffstats
path: root/sys/dev/gpio
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2011-11-19 10:11:50 +0000
committerhselasky <hselasky@FreeBSD.org>2011-11-19 10:11:50 +0000
commit3bcdb8772aed66918259718d05cb24d56914ab89 (patch)
treed8ce224aa83a7409b55f7416386eadc3d984598d /sys/dev/gpio
parent57eff55b88ea3dc6a4a8cc80becb3dc21dcbf80c (diff)
downloadFreeBSD-src-3bcdb8772aed66918259718d05cb24d56914ab89.zip
FreeBSD-src-3bcdb8772aed66918259718d05cb24d56914ab89.tar.gz
Move the device_delete_all_children() function from usb_util.c
to kern/subr_bus.c. Simplify this function so that it no longer depends on malloc() to execute. Identify a few other places where it makes sense to use device_delete_all_children(). MFC after: 1 week
Diffstat (limited to 'sys/dev/gpio')
-rw-r--r--sys/dev/gpio/gpiobus.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/sys/dev/gpio/gpiobus.c b/sys/dev/gpio/gpiobus.c
index d973694..54644a2 100644
--- a/sys/dev/gpio/gpiobus.c
+++ b/sys/dev/gpio/gpiobus.c
@@ -219,8 +219,7 @@ static int
gpiobus_detach(device_t dev)
{
struct gpiobus_softc *sc = GPIOBUS_SOFTC(dev);
- int err, ndevs, i;
- device_t *devlist;
+ int err;
KASSERT(mtx_initialized(&sc->sc_mtx),
("gpiobus mutex not initialized"));
@@ -228,16 +227,14 @@ gpiobus_detach(device_t dev)
if ((err = bus_generic_detach(dev)) != 0)
return (err);
- if ((err = device_get_children(dev, &devlist, &ndevs)) != 0)
- return (err);
- for (i = 0; i < ndevs; i++)
- device_delete_child(dev, devlist[i]);
+
+ /* detach and delete all children */
+ device_delete_all_children(dev);
if (sc->sc_pins_mapped) {
free(sc->sc_pins_mapped, M_DEVBUF);
sc->sc_pins_mapped = NULL;
}
- free(devlist, M_TEMP);
return (0);
}
OpenPOWER on IntegriCloud