svn commit: r229118 - in stable/9/sys: arm/econa arm/xscale/ixp425
dev/ahci dev/ata dev/gpio dev/mvs dev/ppbus dev/ppc dev/siba
dev/siis dev/usb dev/usb/controller kern mips/atheros
mips/cavium/usb...
Hans Petter Selasky
hselasky at FreeBSD.org
Sat Dec 31 15:31:35 UTC 2011
Author: hselasky
Date: Sat Dec 31 15:31:34 2011
New Revision: 229118
URL: http://svn.freebsd.org/changeset/base/229118
Log:
MFC r227701, r227847 and r227849:
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. Rename device_delete_all_children()
into device_delete_children(). Identify a few other places where
it makes sense to use device_delete_children().
Modified:
stable/9/sys/arm/econa/ehci_ebus.c
stable/9/sys/arm/econa/ohci_ec.c
stable/9/sys/arm/xscale/ixp425/avila_ata.c
stable/9/sys/dev/ahci/ahci.c
stable/9/sys/dev/ata/ata-disk.c
stable/9/sys/dev/ata/ata-pci.c
stable/9/sys/dev/gpio/gpiobus.c
stable/9/sys/dev/mvs/mvs_pci.c
stable/9/sys/dev/mvs/mvs_soc.c
stable/9/sys/dev/ppbus/ppbconf.c
stable/9/sys/dev/ppc/ppc.c
stable/9/sys/dev/siba/siba_core.c
stable/9/sys/dev/siis/siis.c
stable/9/sys/dev/usb/controller/at91dci_atmelarm.c
stable/9/sys/dev/usb/controller/atmegadci_atmelarm.c
stable/9/sys/dev/usb/controller/ehci_ixp4xx.c
stable/9/sys/dev/usb/controller/ehci_mv.c
stable/9/sys/dev/usb/controller/ehci_pci.c
stable/9/sys/dev/usb/controller/musb_otg_atmelarm.c
stable/9/sys/dev/usb/controller/ohci_atmelarm.c
stable/9/sys/dev/usb/controller/ohci_pci.c
stable/9/sys/dev/usb/controller/ohci_s3c24x0.c
stable/9/sys/dev/usb/controller/uhci_pci.c
stable/9/sys/dev/usb/controller/uss820dci_atmelarm.c
stable/9/sys/dev/usb/controller/xhci_pci.c
stable/9/sys/dev/usb/usb_util.c
stable/9/sys/dev/usb/usb_util.h
stable/9/sys/kern/subr_bus.c
stable/9/sys/mips/atheros/ar71xx_ehci.c
stable/9/sys/mips/atheros/ar71xx_ohci.c
stable/9/sys/mips/cavium/usb/octusb_octeon.c
stable/9/sys/mips/rmi/xls_ehci.c
stable/9/sys/mips/rt305x/rt305x_dotg.c
stable/9/sys/sys/bus.h
Directory Properties:
stable/9/sys/ (props changed)
stable/9/sys/amd64/include/xen/ (props changed)
stable/9/sys/boot/ (props changed)
stable/9/sys/boot/i386/efi/ (props changed)
stable/9/sys/boot/ia64/efi/ (props changed)
stable/9/sys/boot/ia64/ski/ (props changed)
stable/9/sys/boot/powerpc/boot1.chrp/ (props changed)
stable/9/sys/boot/powerpc/ofw/ (props changed)
stable/9/sys/cddl/contrib/opensolaris/ (props changed)
stable/9/sys/conf/ (props changed)
stable/9/sys/contrib/dev/acpica/ (props changed)
stable/9/sys/contrib/octeon-sdk/ (props changed)
stable/9/sys/contrib/pf/ (props changed)
stable/9/sys/contrib/x86emu/ (props changed)
Modified: stable/9/sys/arm/econa/ehci_ebus.c
==============================================================================
--- stable/9/sys/arm/econa/ehci_ebus.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/arm/econa/ehci_ebus.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -192,7 +192,7 @@ ehci_ebus_detach(device_t self)
device_delete_child(self, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(self);
+ device_delete_children(self);
/*
* disable interrupts that might have been switched on in
Modified: stable/9/sys/arm/econa/ohci_ec.c
==============================================================================
--- stable/9/sys/arm/econa/ohci_ec.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/arm/econa/ohci_ec.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -185,7 +185,7 @@ ohci_ec_detach(device_t dev)
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(dev);
+ device_delete_children(dev);
bus_space_write_4(sc->sc_ohci.sc_io_tag, sc->sc_ohci.sc_io_hdl,
OHCI_CONTROL, 0);
Modified: stable/9/sys/arm/xscale/ixp425/avila_ata.c
==============================================================================
--- stable/9/sys/arm/xscale/ixp425/avila_ata.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/arm/xscale/ixp425/avila_ata.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -259,17 +259,11 @@ static int
ata_avila_detach(device_t dev)
{
struct ata_avila_softc *sc = device_get_softc(dev);
- device_t *children;
- int nc;
/* XXX quiesce gpio? */
/* detach & delete all children */
- if (device_get_children(dev, &children, &nc) == 0) {
- if (nc > 0)
- device_delete_child(dev, children[0]);
- free(children, M_TEMP);
- }
+ device_delete_children(dev);
bus_teardown_intr(dev, sc->sc_irq, sc->sc_ih);
bus_release_resource(dev, SYS_RES_IRQ, sc->sc_rid, sc->sc_irq);
Modified: stable/9/sys/dev/ahci/ahci.c
==============================================================================
--- stable/9/sys/dev/ahci/ahci.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/ahci/ahci.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -514,15 +514,11 @@ static int
ahci_detach(device_t dev)
{
struct ahci_controller *ctlr = device_get_softc(dev);
- device_t *children;
- int nchildren, i;
+ int i;
/* Detach & delete all children */
- if (!device_get_children(dev, &children, &nchildren)) {
- for (i = 0; i < nchildren; i++)
- device_delete_child(dev, children[i]);
- free(children, M_TEMP);
- }
+ device_delete_children(dev);
+
/* Free interrupts. */
for (i = 0; i < ctlr->numirqs; i++) {
if (ctlr->irqs[i].r_irq) {
Modified: stable/9/sys/dev/ata/ata-disk.c
==============================================================================
--- stable/9/sys/dev/ata/ata-disk.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/ata/ata-disk.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -172,8 +172,6 @@ ad_detach(device_t dev)
{
struct ad_softc *adp = device_get_ivars(dev);
struct ata_device *atadev = device_get_softc(dev);
- device_t *children;
- int nchildren, i;
/* check that we have a valid disk to detach */
if (!device_get_ivars(dev))
@@ -183,12 +181,7 @@ ad_detach(device_t dev)
callout_drain(&atadev->spindown_timer);
/* detach & delete all children */
- if (!device_get_children(dev, &children, &nchildren)) {
- for (i = 0; i < nchildren; i++)
- if (children[i])
- device_delete_child(dev, children[i]);
- free(children, M_TEMP);
- }
+ device_delete_children(dev);
/* destroy disk from the system so we don't get any further requests */
disk_destroy(adp->disk);
Modified: stable/9/sys/dev/ata/ata-pci.c
==============================================================================
--- stable/9/sys/dev/ata/ata-pci.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/ata/ata-pci.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -136,15 +136,10 @@ int
ata_pci_detach(device_t dev)
{
struct ata_pci_controller *ctlr = device_get_softc(dev);
- device_t *children;
- int nchildren, i;
/* detach & delete all children */
- if (!device_get_children(dev, &children, &nchildren)) {
- for (i = 0; i < nchildren; i++)
- device_delete_child(dev, children[i]);
- free(children, M_TEMP);
- }
+ device_delete_children(dev);
+
if (ctlr->r_irq) {
bus_teardown_intr(dev, ctlr->r_irq, ctlr->handle);
bus_release_resource(dev, SYS_RES_IRQ, ctlr->r_irq_rid, ctlr->r_irq);
Modified: stable/9/sys/dev/gpio/gpiobus.c
==============================================================================
--- stable/9/sys/dev/gpio/gpiobus.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/gpio/gpiobus.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -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_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);
}
Modified: stable/9/sys/dev/mvs/mvs_pci.c
==============================================================================
--- stable/9/sys/dev/mvs/mvs_pci.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/mvs/mvs_pci.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -177,15 +177,10 @@ static int
mvs_detach(device_t dev)
{
struct mvs_controller *ctlr = device_get_softc(dev);
- device_t *children;
- int nchildren, i;
/* Detach & delete all children */
- if (!device_get_children(dev, &children, &nchildren)) {
- for (i = 0; i < nchildren; i++)
- device_delete_child(dev, children[i]);
- free(children, M_TEMP);
- }
+ device_delete_children(dev);
+
/* Free interrupt. */
if (ctlr->irq.r_irq) {
bus_teardown_intr(dev, ctlr->irq.r_irq,
Modified: stable/9/sys/dev/mvs/mvs_soc.c
==============================================================================
--- stable/9/sys/dev/mvs/mvs_soc.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/mvs/mvs_soc.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -173,15 +173,10 @@ static int
mvs_detach(device_t dev)
{
struct mvs_controller *ctlr = device_get_softc(dev);
- device_t *children;
- int nchildren, i;
/* Detach & delete all children */
- if (!device_get_children(dev, &children, &nchildren)) {
- for (i = 0; i < nchildren; i++)
- device_delete_child(dev, children[i]);
- free(children, M_TEMP);
- }
+ device_delete_children(dev);
+
/* Free interrupt. */
if (ctlr->irq.r_irq) {
bus_teardown_intr(dev, ctlr->irq.r_irq,
Modified: stable/9/sys/dev/ppbus/ppbconf.c
==============================================================================
--- stable/9/sys/dev/ppbus/ppbconf.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/ppbus/ppbconf.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -422,20 +422,14 @@ ppbus_attach(device_t dev)
static int
ppbus_detach(device_t dev)
{
- device_t *children;
- int error, nchildren, i;
+ int error;
error = bus_generic_detach(dev);
if (error)
return (error);
/* detach & delete all children */
- if (!device_get_children(dev, &children, &nchildren)) {
- for (i = 0; i < nchildren; i++)
- if (children[i])
- device_delete_child(dev, children[i]);
- free(children, M_TEMP);
- }
+ device_delete_children(dev);
return (0);
}
Modified: stable/9/sys/dev/ppc/ppc.c
==============================================================================
--- stable/9/sys/dev/ppc/ppc.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/ppc/ppc.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -1851,20 +1851,13 @@ int
ppc_detach(device_t dev)
{
struct ppc_data *ppc = DEVTOSOFTC(dev);
- device_t *children;
- int nchildren, i;
if (ppc->res_irq == 0) {
return (ENXIO);
}
/* detach & delete all children */
- if (!device_get_children(dev, &children, &nchildren)) {
- for (i = 0; i < nchildren; i++)
- if (children[i])
- device_delete_child(dev, children[i]);
- free(children, M_TEMP);
- }
+ device_delete_children(dev);
if (ppc->res_irq != 0) {
bus_teardown_intr(dev, ppc->res_irq, ppc->intr_cookie);
Modified: stable/9/sys/dev/siba/siba_core.c
==============================================================================
--- stable/9/sys/dev/siba/siba_core.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/siba/siba_core.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -214,16 +214,8 @@ siba_core_attach(struct siba_softc *siba
int
siba_core_detach(struct siba_softc *siba)
{
- device_t *devlistp;
- int devcnt, error = 0, i;
-
- error = device_get_children(siba->siba_dev, &devlistp, &devcnt);
- if (error != 0)
- return (0);
-
- for ( i = 0 ; i < devcnt ; i++)
- device_delete_child(siba->siba_dev, devlistp[i]);
- free(devlistp, M_TEMP);
+ /* detach & delete all children */
+ device_delete_children(siba->siba_dev);
return (0);
}
Modified: stable/9/sys/dev/siis/siis.c
==============================================================================
--- stable/9/sys/dev/siis/siis.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/siis/siis.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -205,15 +205,10 @@ static int
siis_detach(device_t dev)
{
struct siis_controller *ctlr = device_get_softc(dev);
- device_t *children;
- int nchildren, i;
/* Detach & delete all children */
- if (!device_get_children(dev, &children, &nchildren)) {
- for (i = 0; i < nchildren; i++)
- device_delete_child(dev, children[i]);
- free(children, M_TEMP);
- }
+ device_delete_children(dev);
+
/* Free interrupts. */
if (ctlr->irq.r_irq) {
bus_teardown_intr(dev, ctlr->irq.r_irq,
Modified: stable/9/sys/dev/usb/controller/at91dci_atmelarm.c
==============================================================================
--- stable/9/sys/dev/usb/controller/at91dci_atmelarm.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/usb/controller/at91dci_atmelarm.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -270,7 +270,7 @@ at91_udp_detach(device_t dev)
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(dev);
+ device_delete_children(dev);
/* disable Transceiver */
AT91_UDP_WRITE_4(&sc->sc_dci, AT91_UDP_TXVC, AT91_UDP_TXVC_DIS);
Modified: stable/9/sys/dev/usb/controller/atmegadci_atmelarm.c
==============================================================================
--- stable/9/sys/dev/usb/controller/atmegadci_atmelarm.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/usb/controller/atmegadci_atmelarm.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -163,7 +163,7 @@ atmegadci_detach(device_t dev)
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(dev);
+ device_delete_children(dev);
if (sc->sc_otg.sc_irq_res && sc->sc_otg.sc_intr_hdl) {
/*
Modified: stable/9/sys/dev/usb/controller/ehci_ixp4xx.c
==============================================================================
--- stable/9/sys/dev/usb/controller/ehci_ixp4xx.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/usb/controller/ehci_ixp4xx.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -215,7 +215,7 @@ ehci_ixp_detach(device_t self)
device_delete_child(self, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(self);
+ device_delete_children(self);
if (sc->sc_irq_res && sc->sc_intr_hdl) {
/*
Modified: stable/9/sys/dev/usb/controller/ehci_mv.c
==============================================================================
--- stable/9/sys/dev/usb/controller/ehci_mv.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/usb/controller/ehci_mv.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -247,7 +247,7 @@ mv_ehci_detach(device_t self)
device_delete_child(self, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(self);
+ device_delete_children(self);
/*
* disable interrupts that might have been switched on in mv_ehci_attach
Modified: stable/9/sys/dev/usb/controller/ehci_pci.c
==============================================================================
--- stable/9/sys/dev/usb/controller/ehci_pci.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/usb/controller/ehci_pci.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -455,7 +455,7 @@ ehci_pci_detach(device_t self)
device_delete_child(self, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(self);
+ device_delete_children(self);
pci_disable_busmaster(self);
Modified: stable/9/sys/dev/usb/controller/musb_otg_atmelarm.c
==============================================================================
--- stable/9/sys/dev/usb/controller/musb_otg_atmelarm.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/usb/controller/musb_otg_atmelarm.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -188,7 +188,7 @@ musbotg_detach(device_t dev)
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(dev);
+ device_delete_children(dev);
if (sc->sc_otg.sc_irq_res && sc->sc_otg.sc_intr_hdl) {
/*
Modified: stable/9/sys/dev/usb/controller/ohci_atmelarm.c
==============================================================================
--- stable/9/sys/dev/usb/controller/ohci_atmelarm.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/usb/controller/ohci_atmelarm.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -174,7 +174,7 @@ ohci_atmelarm_detach(device_t dev)
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(dev);
+ device_delete_children(dev);
/*
* Put the controller into reset, then disable clocks and do
Modified: stable/9/sys/dev/usb/controller/ohci_pci.c
==============================================================================
--- stable/9/sys/dev/usb/controller/ohci_pci.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/usb/controller/ohci_pci.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -331,7 +331,7 @@ ohci_pci_detach(device_t self)
device_delete_child(self, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(self);
+ device_delete_children(self);
pci_disable_busmaster(self);
Modified: stable/9/sys/dev/usb/controller/ohci_s3c24x0.c
==============================================================================
--- stable/9/sys/dev/usb/controller/ohci_s3c24x0.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/usb/controller/ohci_s3c24x0.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -156,7 +156,7 @@ ohci_s3c24x0_detach(device_t dev)
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(dev);
+ device_delete_children(dev);
/*
* Put the controller into reset, then disable clocks and do
Modified: stable/9/sys/dev/usb/controller/uhci_pci.c
==============================================================================
--- stable/9/sys/dev/usb/controller/uhci_pci.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/usb/controller/uhci_pci.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -387,7 +387,7 @@ uhci_pci_detach(device_t self)
device_delete_child(self, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(self);
+ device_delete_children(self);
/*
* disable interrupts that might have been switched on in
Modified: stable/9/sys/dev/usb/controller/uss820dci_atmelarm.c
==============================================================================
--- stable/9/sys/dev/usb/controller/uss820dci_atmelarm.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/usb/controller/uss820dci_atmelarm.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -177,7 +177,7 @@ uss820_atmelarm_detach(device_t dev)
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(dev);
+ device_delete_children(dev);
if (sc->sc_irq_res && sc->sc_intr_hdl) {
/*
Modified: stable/9/sys/dev/usb/controller/xhci_pci.c
==============================================================================
--- stable/9/sys/dev/usb/controller/xhci_pci.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/usb/controller/xhci_pci.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -202,7 +202,7 @@ xhci_pci_detach(device_t self)
device_delete_child(self, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(self);
+ device_delete_children(self);
pci_disable_busmaster(self);
Modified: stable/9/sys/dev/usb/usb_util.c
==============================================================================
--- stable/9/sys/dev/usb/usb_util.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/usb/usb_util.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -58,31 +58,6 @@
#include <dev/usb/usb_bus.h>
/*------------------------------------------------------------------------*
- * device_delete_all_children - delete all children of a device
- *------------------------------------------------------------------------*/
-#ifndef device_delete_all_children
-int
-device_delete_all_children(device_t dev)
-{
- device_t *devlist;
- int devcount;
- int error;
-
- error = device_get_children(dev, &devlist, &devcount);
- if (error == 0) {
- while (devcount-- > 0) {
- error = device_delete_child(dev, devlist[devcount]);
- if (error) {
- break;
- }
- }
- free(devlist, M_TEMP);
- }
- return (error);
-}
-#endif
-
-/*------------------------------------------------------------------------*
* device_set_usb_desc
*
* This function can be called at probe or attach to set the USB
Modified: stable/9/sys/dev/usb/usb_util.h
==============================================================================
--- stable/9/sys/dev/usb/usb_util.h Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/dev/usb/usb_util.h Sat Dec 31 15:31:34 2011 (r229118)
@@ -27,7 +27,6 @@
#ifndef _USB_UTIL_H_
#define _USB_UTIL_H_
-int device_delete_all_children(device_t dev);
uint8_t usb_make_str_desc(void *ptr, uint16_t max_len, const char *s);
void usb_printbcd(char *p, uint16_t p_len, uint16_t bcd);
void usb_trim_spaces(char *p);
Modified: stable/9/sys/kern/subr_bus.c
==============================================================================
--- stable/9/sys/kern/subr_bus.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/kern/subr_bus.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -1862,7 +1862,7 @@ device_delete_child(device_t dev, device
PDEBUG(("%s from %s", DEVICENAME(child), DEVICENAME(dev)));
/* remove children first */
- while ( (grandchild = TAILQ_FIRST(&child->children)) ) {
+ while ((grandchild = TAILQ_FIRST(&child->children)) != NULL) {
error = device_delete_child(child, grandchild);
if (error)
return (error);
@@ -1881,6 +1881,39 @@ device_delete_child(device_t dev, device
}
/**
+ * @brief Delete all children devices of the given device, if any.
+ *
+ * This function deletes all children devices of the given device, if
+ * any, using the device_delete_child() function for each device it
+ * finds. If a child device cannot be deleted, this function will
+ * return an error code.
+ *
+ * @param dev the parent device
+ *
+ * @retval 0 success
+ * @retval non-zero a device would not detach
+ */
+int
+device_delete_children(device_t dev)
+{
+ device_t child;
+ int error;
+
+ PDEBUG(("Deleting all children of %s", DEVICENAME(dev)));
+
+ error = 0;
+
+ while ((child = TAILQ_FIRST(&dev->children)) != NULL) {
+ error = device_delete_child(dev, child);
+ if (error) {
+ PDEBUG(("Failed deleting %s", DEVICENAME(child)));
+ break;
+ }
+ }
+ return (error);
+}
+
+/**
* @brief Find a device given a unit number
*
* This is similar to devclass_get_devices() but only searches for
Modified: stable/9/sys/mips/atheros/ar71xx_ehci.c
==============================================================================
--- stable/9/sys/mips/atheros/ar71xx_ehci.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/mips/atheros/ar71xx_ehci.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -202,7 +202,7 @@ ar71xx_ehci_detach(device_t self)
device_delete_child(self, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(self);
+ device_delete_children(self);
if (sc->sc_irq_res && sc->sc_intr_hdl) {
/*
Modified: stable/9/sys/mips/atheros/ar71xx_ohci.c
==============================================================================
--- stable/9/sys/mips/atheros/ar71xx_ohci.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/mips/atheros/ar71xx_ohci.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -150,7 +150,7 @@ ar71xx_ohci_detach(device_t dev)
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(dev);
+ device_delete_children(dev);
/*
* Put the controller into reset, then disable clocks and do
Modified: stable/9/sys/mips/cavium/usb/octusb_octeon.c
==============================================================================
--- stable/9/sys/mips/cavium/usb/octusb_octeon.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/mips/cavium/usb/octusb_octeon.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -159,7 +159,7 @@ octusb_octeon_detach(device_t dev)
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(dev);
+ device_delete_children(dev);
if (sc->sc_dci.sc_irq_res && sc->sc_dci.sc_intr_hdl) {
/*
Modified: stable/9/sys/mips/rmi/xls_ehci.c
==============================================================================
--- stable/9/sys/mips/rmi/xls_ehci.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/mips/rmi/xls_ehci.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -172,7 +172,7 @@ ehci_xls_detach(device_t self)
device_delete_child(self, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(self);
+ device_delete_children(self);
if (sc->sc_irq_res && sc->sc_intr_hdl) {
ehci_detach(sc);
Modified: stable/9/sys/mips/rt305x/rt305x_dotg.c
==============================================================================
--- stable/9/sys/mips/rt305x/rt305x_dotg.c Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/mips/rt305x/rt305x_dotg.c Sat Dec 31 15:31:34 2011 (r229118)
@@ -175,7 +175,7 @@ dotg_obio_detach(device_t dev)
device_delete_child(dev, bdev);
}
/* during module unload there are lots of children leftover */
- device_delete_all_children(dev);
+ device_delete_children(dev);
if (sc->sc_dci.sc_irq_res && sc->sc_dci.sc_intr_hdl) {
/*
Modified: stable/9/sys/sys/bus.h
==============================================================================
--- stable/9/sys/sys/bus.h Sat Dec 31 15:18:51 2011 (r229117)
+++ stable/9/sys/sys/bus.h Sat Dec 31 15:31:34 2011 (r229118)
@@ -424,6 +424,7 @@ device_t device_add_child_ordered(device
const char *name, int unit);
void device_busy(device_t dev);
int device_delete_child(device_t dev, device_t child);
+int device_delete_children(device_t dev);
int device_attach(device_t dev);
int device_detach(device_t dev);
void device_disable(device_t dev);
More information about the svn-src-stable-9
mailing list