Page MenuHomeFreeBSD

D47972.id147650.diff
No OneTemporary

D47972.id147650.diff

diff --git a/sys/arm/ti/twl/twl.c b/sys/arm/ti/twl/twl.c
--- a/sys/arm/ti/twl/twl.c
+++ b/sys/arm/ti/twl/twl.c
@@ -425,13 +425,13 @@
twl_detach(device_t dev)
{
struct twl_softc *sc;
+ int error;
sc = device_get_softc(dev);
- if (sc->sc_vreg)
- device_delete_child(dev, sc->sc_vreg);
- if (sc->sc_clks)
- device_delete_child(dev, sc->sc_clks);
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
TWL_LOCK_DESTROY(sc);
diff --git a/sys/dev/aac/aac.c b/sys/dev/aac/aac.c
--- a/sys/dev/aac/aac.c
+++ b/sys/dev/aac/aac.c
@@ -669,6 +669,10 @@
sc = device_get_softc(dev);
fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
+
callout_drain(&sc->aac_daemontime);
mtx_lock(&sc->aac_io_lock);
@@ -683,9 +687,6 @@
/* Remove the child containers */
while ((co = TAILQ_FIRST(&sc->aac_container_tqh)) != NULL) {
- error = device_delete_child(dev, co->co_disk);
- if (error)
- return (error);
TAILQ_REMOVE(&sc->aac_container_tqh, co, co_link);
free(co, M_AACBUF);
}
@@ -693,9 +694,6 @@
/* Remove the CAM SIMs */
while ((sim = TAILQ_FIRST(&sc->aac_sim_tqh)) != NULL) {
TAILQ_REMOVE(&sc->aac_sim_tqh, sim, sim_link);
- error = device_delete_child(dev, sim->sim_dev);
- if (error)
- return (error);
free(sim, M_AACBUF);
}
diff --git a/sys/dev/aacraid/aacraid.c b/sys/dev/aacraid/aacraid.c
--- a/sys/dev/aacraid/aacraid.c
+++ b/sys/dev/aacraid/aacraid.c
@@ -739,6 +739,10 @@
sc = device_get_softc(dev);
fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
+
callout_drain(&sc->aac_daemontime);
/* Remove the child containers */
while ((co = TAILQ_FIRST(&sc->aac_container_tqh)) != NULL) {
@@ -749,9 +753,6 @@
/* Remove the CAM SIMs */
while ((sim = TAILQ_FIRST(&sc->aac_sim_tqh)) != NULL) {
TAILQ_REMOVE(&sc->aac_sim_tqh, sim, sim_link);
- error = device_delete_child(dev, sim->sim_dev);
- if (error)
- return (error);
free(sim, M_AACRAIDBUF);
}
diff --git a/sys/dev/alpm/alpm.c b/sys/dev/alpm/alpm.c
--- a/sys/dev/alpm/alpm.c
+++ b/sys/dev/alpm/alpm.c
@@ -232,11 +232,12 @@
alpm_detach(device_t dev)
{
struct alpm_softc *alpm = device_get_softc(dev);
+ int error;
+
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
- if (alpm->smbus) {
- device_delete_child(dev, alpm->smbus);
- alpm->smbus = NULL;
- }
mtx_destroy(&alpm->lock);
if (alpm->res)
diff --git a/sys/dev/altera/atse/if_atse.c b/sys/dev/altera/atse/if_atse.c
--- a/sys/dev/altera/atse/if_atse.c
+++ b/sys/dev/altera/atse/if_atse.c
@@ -1432,9 +1432,7 @@
callout_drain(&sc->atse_tick);
ether_ifdetach(ifp);
}
- if (sc->atse_miibus != NULL) {
- device_delete_child(dev, sc->atse_miibus);
- }
+ bus_generic_detach(dev);
if (ifp != NULL) {
if_free(ifp);
diff --git a/sys/dev/amdpm/amdpm.c b/sys/dev/amdpm/amdpm.c
--- a/sys/dev/amdpm/amdpm.c
+++ b/sys/dev/amdpm/amdpm.c
@@ -229,11 +229,11 @@
amdpm_detach(device_t dev)
{
struct amdpm_softc *amdpm_sc = device_get_softc(dev);
+ int error;
- if (amdpm_sc->smbus) {
- device_delete_child(dev, amdpm_sc->smbus);
- amdpm_sc->smbus = NULL;
- }
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
mtx_destroy(&amdpm_sc->lock);
if (amdpm_sc->res)
diff --git a/sys/dev/amdsmb/amdsmb.c b/sys/dev/amdsmb/amdsmb.c
--- a/sys/dev/amdsmb/amdsmb.c
+++ b/sys/dev/amdsmb/amdsmb.c
@@ -174,11 +174,11 @@
amdsmb_detach(device_t dev)
{
struct amdsmb_softc *amdsmb_sc = device_get_softc(dev);
+ int error;
- if (amdsmb_sc->smbus) {
- device_delete_child(dev, amdsmb_sc->smbus);
- amdsmb_sc->smbus = NULL;
- }
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
mtx_destroy(&amdsmb_sc->lock);
if (amdsmb_sc->res)
diff --git a/sys/dev/cas/if_cas.c b/sys/dev/cas/if_cas.c
--- a/sys/dev/cas/if_cas.c
+++ b/sys/dev/cas/if_cas.c
@@ -477,7 +477,7 @@
taskqueue_drain(sc->sc_tq, &sc->sc_tx_task);
if_free(ifp);
taskqueue_free(sc->sc_tq);
- device_delete_child(sc->sc_dev, sc->sc_miibus);
+ bus_generic_detach(sc->sc_dev);
for (i = 0; i < CAS_NRXDESC; i++)
if (sc->sc_rxdsoft[i].rxds_dmamap != NULL)
diff --git a/sys/dev/enetc/if_enetc.c b/sys/dev/enetc/if_enetc.c
--- a/sys/dev/enetc/if_enetc.c
+++ b/sys/dev/enetc/if_enetc.c
@@ -459,8 +459,7 @@
for (i = 0; i < sc->rx_num_queues; i++)
iflib_irq_free(ctx, &sc->rx_queues[i].irq);
- if (sc->miibus != NULL)
- device_delete_child(sc->dev, sc->miibus);
+ bus_generic_detach(sc->dev);
if (sc->regs != NULL)
error = bus_release_resource(sc->dev, SYS_RES_MEMORY,
diff --git a/sys/dev/gem/if_gem.c b/sys/dev/gem/if_gem.c
--- a/sys/dev/gem/if_gem.c
+++ b/sys/dev/gem/if_gem.c
@@ -413,7 +413,7 @@
callout_drain(&sc->sc_rx_ch);
#endif
if_free(ifp);
- device_delete_child(sc->sc_dev, sc->sc_miibus);
+ bus_generic_detach(sc->sc_dev);
for (i = 0; i < GEM_NRXDESC; i++)
if (sc->sc_rxsoft[i].rxs_dmamap != NULL)
diff --git a/sys/dev/mgb/if_mgb.c b/sys/dev/mgb/if_mgb.c
--- a/sys/dev/mgb/if_mgb.c
+++ b/sys/dev/mgb/if_mgb.c
@@ -482,8 +482,7 @@
iflib_irq_free(ctx, &sc->rx_irq);
iflib_irq_free(ctx, &sc->admin_irq);
- if (sc->miibus != NULL)
- device_delete_child(sc->dev, sc->miibus);
+ bus_generic_detach(sc->dev);
if (sc->pba != NULL)
error = bus_release_resource(sc->dev, SYS_RES_MEMORY,
diff --git a/sys/dev/mlx/mlx.c b/sys/dev/mlx/mlx.c
--- a/sys/dev/mlx/mlx.c
+++ b/sys/dev/mlx/mlx.c
@@ -642,7 +642,7 @@
static int
mlx_shutdown_locked(struct mlx_softc *sc)
{
- int i, error;
+ int error;
debug_called(1);
@@ -660,17 +660,11 @@
printf("done\n");
}
MLX_IO_UNLOCK(sc);
-
+
/* delete all our child devices */
- for (i = 0; i < MLX_MAXDRIVES; i++) {
- if (sc->mlx_sysdrive[i].ms_disk != 0) {
- if ((error = device_delete_child(sc->mlx_dev, sc->mlx_sysdrive[i].ms_disk)) != 0)
- return (error);
- sc->mlx_sysdrive[i].ms_disk = 0;
- }
- }
+ error = bus_generic_detach(sc->mlx_dev);
- return (0);
+ return (error);
}
/********************************************************************************
diff --git a/sys/dev/nfsmb/nfsmb.c b/sys/dev/nfsmb/nfsmb.c
--- a/sys/dev/nfsmb/nfsmb.c
+++ b/sys/dev/nfsmb/nfsmb.c
@@ -275,13 +275,13 @@
{
device_t parent;
struct nfsmb_softc *nfsmbsub_sc = device_get_softc(dev);
+ int error;
parent = device_get_parent(dev);
- if (nfsmbsub_sc->smbus) {
- device_delete_child(dev, nfsmbsub_sc->smbus);
- nfsmbsub_sc->smbus = NULL;
- }
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
mtx_destroy(&nfsmbsub_sc->lock);
if (nfsmbsub_sc->res) {
bus_release_resource(parent, SYS_RES_IOPORT, nfsmbsub_sc->rid,
@@ -295,16 +295,11 @@
nfsmb_detach(device_t dev)
{
struct nfsmb_softc *nfsmb_sc = device_get_softc(dev);
+ int error;
- if (nfsmb_sc->subdev) {
- device_delete_child(dev, nfsmb_sc->subdev);
- nfsmb_sc->subdev = NULL;
- }
-
- if (nfsmb_sc->smbus) {
- device_delete_child(dev, nfsmb_sc->smbus);
- nfsmb_sc->smbus = NULL;
- }
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
mtx_destroy(&nfsmb_sc->lock);
if (nfsmb_sc->res) {
diff --git a/sys/dev/puc/puc.c b/sys/dev/puc/puc.c
--- a/sys/dev/puc/puc.c
+++ b/sys/dev/puc/puc.c
@@ -409,21 +409,19 @@
sc = device_get_softc(dev);
/* Detach our children. */
- error = 0;
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
+
for (idx = 0; idx < sc->sc_nports; idx++) {
port = &sc->sc_port[idx];
if (port->p_dev == NULL)
continue;
- if (device_delete_child(dev, port->p_dev) == 0) {
- if (port->p_rres != NULL)
- rman_release_resource(port->p_rres);
- if (port->p_ires != NULL)
- rman_release_resource(port->p_ires);
- } else
- error = ENXIO;
+ if (port->p_rres != NULL)
+ rman_release_resource(port->p_rres);
+ if (port->p_ires != NULL)
+ rman_release_resource(port->p_ires);
}
- if (error)
- return (error);
if (sc->sc_serdevs != 0UL)
bus_teardown_intr(dev, sc->sc_ires, sc->sc_icookie);
diff --git a/sys/dev/sound/pci/hda/hdac.c b/sys/dev/sound/pci/hda/hdac.c
--- a/sys/dev/sound/pci/hda/hdac.c
+++ b/sys/dev/sound/pci/hda/hdac.c
@@ -1740,20 +1740,11 @@
hdac_detach(device_t dev)
{
struct hdac_softc *sc = device_get_softc(dev);
- device_t *devlist;
- int cad, i, devcount, error;
+ int i, error;
- if ((error = device_get_children(dev, &devlist, &devcount)) != 0)
+ error = bus_generic_detach(dev);
+ if (error != 0)
return (error);
- for (i = 0; i < devcount; i++) {
- cad = (intptr_t)device_get_ivars(devlist[i]);
- if ((error = device_delete_child(dev, devlist[i])) != 0) {
- free(devlist, M_TEMP);
- return (error);
- }
- sc->codecs[cad].dev = NULL;
- }
- free(devlist, M_TEMP);
hdac_lock(sc);
hdac_reset(sc, false);
diff --git a/sys/dev/usb/net/usb_ethernet.c b/sys/dev/usb/net/usb_ethernet.c
--- a/sys/dev/usb/net/usb_ethernet.c
+++ b/sys/dev/usb/net/usb_ethernet.c
@@ -315,11 +315,9 @@
ether_ifdetach(ifp);
/* detach miibus */
- if (ue->ue_miibus != NULL) {
- bus_topo_lock();
- device_delete_child(ue->ue_dev, ue->ue_miibus);
- bus_topo_unlock();
- }
+ bus_topo_lock();
+ bus_generic_detach(ue->ue_dev);
+ bus_topo_unlock();
/* free interface instance */
if_free(ifp);
diff --git a/sys/dev/virtio/mmio/virtio_mmio.c b/sys/dev/virtio/mmio/virtio_mmio.c
--- a/sys/dev/virtio/mmio/virtio_mmio.c
+++ b/sys/dev/virtio/mmio/virtio_mmio.c
@@ -292,17 +292,13 @@
vtmmio_detach(device_t dev)
{
struct vtmmio_softc *sc;
- device_t child;
int error;
sc = device_get_softc(dev);
- if ((child = sc->vtmmio_child_dev) != NULL) {
- error = device_delete_child(dev, child);
- if (error)
- return (error);
- sc->vtmmio_child_dev = NULL;
- }
+ error = bus_generic_detach(dev);
+ if (error)
+ return (error);
vtmmio_reset(sc);
diff --git a/sys/dev/virtio/pci/virtio_pci.c b/sys/dev/virtio/pci/virtio_pci.c
--- a/sys/dev/virtio/pci/virtio_pci.c
+++ b/sys/dev/virtio/pci/virtio_pci.c
@@ -182,18 +182,14 @@
int
vtpci_delete_child(struct vtpci_common *cn)
{
- device_t dev, child;
+ device_t dev;
int error;
dev = cn->vtpci_dev;
- child = cn->vtpci_child_dev;
- if (child != NULL) {
- error = device_delete_child(dev, child);
- if (error)
- return (error);
- cn->vtpci_child_dev = NULL;
- }
+ error = bus_generic_detach(dev);
+ if (error)
+ return (error);
return (0);
}
diff --git a/sys/dev/xilinx/if_xae.c b/sys/dev/xilinx/if_xae.c
--- a/sys/dev/xilinx/if_xae.c
+++ b/sys/dev/xilinx/if_xae.c
@@ -1052,8 +1052,7 @@
ether_ifdetach(ifp);
}
- if (sc->miibus != NULL)
- device_delete_child(dev, sc->miibus);
+ bus_generic_detach(dev);
if (ifp != NULL)
if_free(ifp);

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 20, 5:11 AM (18 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25709107
Default Alt Text
D47972.id147650.diff (10 KB)

Event Timeline