git: 4e62c3cafa4c - main - Remove now-redundant calls to device_delete_child
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 02 Jan 2025 18:28:21 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=4e62c3cafa4c4e41efd6f87b7fe559cf819cf3e4 commit 4e62c3cafa4c4e41efd6f87b7fe559cf819cf3e4 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2025-01-02 18:22:35 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2025-01-02 18:22:35 +0000 Remove now-redundant calls to device_delete_child Deleting a child explicitly before calling bus_generic_detach is now redundant, so remove those calls and rely on bus_generic_detach to delete children instead. Differential Revision: https://reviews.freebsd.org/D47961 --- sys/arm/allwinner/if_emac.c | 5 +---- sys/dev/ae/if_ae.c | 4 ---- sys/dev/age/if_age.c | 4 ---- sys/dev/alc/if_alc.c | 4 ---- sys/dev/ale/if_ale.c | 4 ---- sys/dev/dc/if_dc.c | 2 -- sys/dev/dwc/if_dwc.c | 4 ---- sys/dev/eqos/if_eqos.c | 2 -- sys/dev/et/if_et.c | 2 -- sys/dev/fxp/if_fxp.c | 2 -- sys/dev/ips/ips.c | 12 +----------- sys/dev/jme/if_jme.c | 4 ---- sys/dev/msk/if_msk.c | 21 +-------------------- sys/dev/nfe/if_nfe.c | 2 -- sys/dev/nge/if_nge.c | 4 ---- sys/dev/pccbb/pccbb.c | 32 +------------------------------- sys/dev/re/if_re.c | 2 -- sys/dev/rl/if_rl.c | 2 -- sys/dev/sge/if_sge.c | 2 -- sys/dev/sis/if_sis.c | 2 -- sys/dev/sk/if_sk.c | 19 +------------------ sys/dev/smc/if_smc.c | 5 +---- sys/dev/ste/if_ste.c | 2 -- sys/dev/stge/if_stge.c | 4 ---- sys/dev/vge/if_vge.c | 2 -- sys/dev/vr/if_vr.c | 2 -- sys/dev/vte/if_vte.c | 4 ---- sys/dev/xl/if_xl.c | 2 -- 28 files changed, 6 insertions(+), 150 deletions(-) diff --git a/sys/arm/allwinner/if_emac.c b/sys/arm/allwinner/if_emac.c index 1db43cbca26c..1fa6691ade1a 100644 --- a/sys/arm/allwinner/if_emac.c +++ b/sys/arm/allwinner/if_emac.c @@ -811,10 +811,7 @@ emac_detach(device_t dev) bus_teardown_intr(sc->emac_dev, sc->emac_irq, sc->emac_intrhand); - if (sc->emac_miibus != NULL) { - device_delete_child(sc->emac_dev, sc->emac_miibus); - bus_generic_detach(sc->emac_dev); - } + bus_generic_detach(sc->emac_dev); if (sc->emac_clk != NULL) clk_disable(sc->emac_clk); diff --git a/sys/dev/ae/if_ae.c b/sys/dev/ae/if_ae.c index adbb3e48a4e3..2525c7aa4510 100644 --- a/sys/dev/ae/if_ae.c +++ b/sys/dev/ae/if_ae.c @@ -761,10 +761,6 @@ ae_detach(device_t dev) taskqueue_free(sc->tq); sc->tq = NULL; } - if (sc->miibus != NULL) { - device_delete_child(dev, sc->miibus); - sc->miibus = NULL; - } bus_generic_detach(sc->dev); ae_dma_free(sc); if (sc->intrhand != NULL) { diff --git a/sys/dev/age/if_age.c b/sys/dev/age/if_age.c index 10f99129401a..c22a41b9c4e3 100644 --- a/sys/dev/age/if_age.c +++ b/sys/dev/age/if_age.c @@ -686,10 +686,6 @@ age_detach(device_t dev) sc->age_tq = NULL; } - if (sc->age_miibus != NULL) { - device_delete_child(dev, sc->age_miibus); - sc->age_miibus = NULL; - } bus_generic_detach(dev); age_dma_free(sc); diff --git a/sys/dev/alc/if_alc.c b/sys/dev/alc/if_alc.c index 07ba02c33c88..e03cfe590214 100644 --- a/sys/dev/alc/if_alc.c +++ b/sys/dev/alc/if_alc.c @@ -1699,10 +1699,6 @@ alc_detach(device_t dev) sc->alc_tq = NULL; } - if (sc->alc_miibus != NULL) { - device_delete_child(dev, sc->alc_miibus); - sc->alc_miibus = NULL; - } bus_generic_detach(dev); alc_dma_free(sc); diff --git a/sys/dev/ale/if_ale.c b/sys/dev/ale/if_ale.c index e4d61e636f8b..c24ff2ea65cb 100644 --- a/sys/dev/ale/if_ale.c +++ b/sys/dev/ale/if_ale.c @@ -711,10 +711,6 @@ ale_detach(device_t dev) sc->ale_tq = NULL; } - if (sc->ale_miibus != NULL) { - device_delete_child(dev, sc->ale_miibus); - sc->ale_miibus = NULL; - } bus_generic_detach(dev); ale_dma_free(sc); diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c index 809feed7855f..bed74c3b6181 100644 --- a/sys/dev/dc/if_dc.c +++ b/sys/dev/dc/if_dc.c @@ -2539,8 +2539,6 @@ dc_detach(device_t dev) callout_drain(&sc->dc_wdog_ch); ether_ifdetach(ifp); } - if (sc->dc_miibus) - device_delete_child(dev, sc->dc_miibus); bus_generic_detach(dev); if (sc->dc_intrhand) diff --git a/sys/dev/dwc/if_dwc.c b/sys/dev/dwc/if_dwc.c index 17657045b73c..33657b33fe25 100644 --- a/sys/dev/dwc/if_dwc.c +++ b/sys/dev/dwc/if_dwc.c @@ -656,10 +656,6 @@ dwc_detach(device_t dev) ether_ifdetach(sc->ifp); } - if (sc->miibus != NULL) { - device_delete_child(dev, sc->miibus); - sc->miibus = NULL; - } bus_generic_detach(dev); /* Free DMA descriptors */ diff --git a/sys/dev/eqos/if_eqos.c b/sys/dev/eqos/if_eqos.c index 6f58c96a10b7..6e2eea2e6c37 100644 --- a/sys/dev/eqos/if_eqos.c +++ b/sys/dev/eqos/if_eqos.c @@ -1216,8 +1216,6 @@ eqos_detach(device_t dev) ether_ifdetach(sc->ifp); } - if (sc->miibus) - device_delete_child(dev, sc->miibus); bus_generic_detach(dev); if (sc->irq_handle) diff --git a/sys/dev/et/if_et.c b/sys/dev/et/if_et.c index dedd2218b4a8..399c9fa77989 100644 --- a/sys/dev/et/if_et.c +++ b/sys/dev/et/if_et.c @@ -370,8 +370,6 @@ et_detach(device_t dev) callout_drain(&sc->sc_tick); } - if (sc->sc_miibus != NULL) - device_delete_child(dev, sc->sc_miibus); bus_generic_detach(dev); if (sc->sc_irq_handle != NULL) diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c index 7684b94df316..b26879cfa25c 100644 --- a/sys/dev/fxp/if_fxp.c +++ b/sys/dev/fxp/if_fxp.c @@ -933,8 +933,6 @@ fxp_release(struct fxp_softc *sc) FXP_LOCK_ASSERT(sc, MA_NOTOWNED); KASSERT(sc->ih == NULL, ("fxp_release() called with intr handle still active")); - if (sc->miibus) - device_delete_child(sc->dev, sc->miibus); bus_generic_detach(sc->dev); ifmedia_removeall(&sc->sc_media); if (sc->fxp_desc.cbl_list) { diff --git a/sys/dev/ips/ips.c b/sys/dev/ips/ips.c index 0079e4183db5..7a73aee2ef49 100644 --- a/sys/dev/ips/ips.c +++ b/sys/dev/ips/ips.c @@ -279,17 +279,7 @@ static int ips_diskdev_init(ips_softc_t *sc) static int ips_diskdev_free(ips_softc_t *sc) { - int i; - int error = 0; - for(i = 0; i < IPS_MAX_NUM_DRIVES; i++){ - if(sc->diskdev[i]) { - error = device_delete_child(sc->dev, sc->diskdev[i]); - if(error) - return error; - } - } - bus_generic_detach(sc->dev); - return 0; + return (bus_generic_detach(sc->dev)); } /* ips_timeout is periodically called to make sure no commands sent diff --git a/sys/dev/jme/if_jme.c b/sys/dev/jme/if_jme.c index 4f739ec26347..834717d849a0 100644 --- a/sys/dev/jme/if_jme.c +++ b/sys/dev/jme/if_jme.c @@ -928,10 +928,6 @@ jme_detach(device_t dev) sc->jme_tq = NULL; } - if (sc->jme_miibus != NULL) { - device_delete_child(dev, sc->jme_miibus); - sc->jme_miibus = NULL; - } bus_generic_detach(dev); jme_dma_free(sc); diff --git a/sys/dev/msk/if_msk.c b/sys/dev/msk/if_msk.c index 46219c3c9ab2..295eb2584b3e 100644 --- a/sys/dev/msk/if_msk.c +++ b/sys/dev/msk/if_msk.c @@ -2020,17 +2020,6 @@ msk_detach(device_t dev) MSK_IF_LOCK(sc_if); } - /* - * We're generally called from mskc_detach() which is using - * device_delete_child() to get to here. It's already trashed - * miibus for us, so don't do it here or we'll panic. - * - * if (sc_if->msk_miibus != NULL) { - * device_delete_child(dev, sc_if->msk_miibus); - * sc_if->msk_miibus = NULL; - * } - */ - msk_rx_dma_jfree(sc_if); msk_txrx_dma_free(sc_if); bus_generic_detach(dev); @@ -2058,15 +2047,7 @@ mskc_detach(device_t dev) sc = device_get_softc(dev); KASSERT(mtx_initialized(&sc->msk_mtx), ("msk mutex not initialized")); - if (device_is_alive(dev)) { - if (sc->msk_devs[MSK_PORT_A] != NULL) { - device_delete_child(dev, sc->msk_devs[MSK_PORT_A]); - } - if (sc->msk_devs[MSK_PORT_B] != NULL) { - device_delete_child(dev, sc->msk_devs[MSK_PORT_B]); - } - bus_generic_detach(dev); - } + bus_generic_detach(dev); /* Disable all interrupts. */ CSR_WRITE_4(sc, B0_IMSK, 0); diff --git a/sys/dev/nfe/if_nfe.c b/sys/dev/nfe/if_nfe.c index 23a743759bdd..8df4ca27ac9d 100644 --- a/sys/dev/nfe/if_nfe.c +++ b/sys/dev/nfe/if_nfe.c @@ -711,8 +711,6 @@ nfe_detach(device_t dev) nfe_set_macaddr(sc, eaddr); if_free(ifp); } - if (sc->nfe_miibus) - device_delete_child(dev, sc->nfe_miibus); bus_generic_detach(dev); if (sc->nfe_tq != NULL) { taskqueue_drain(sc->nfe_tq, &sc->nfe_int_task); diff --git a/sys/dev/nge/if_nge.c b/sys/dev/nge/if_nge.c index c7c2b3c99d5a..90650bf353a5 100644 --- a/sys/dev/nge/if_nge.c +++ b/sys/dev/nge/if_nge.c @@ -999,10 +999,6 @@ nge_detach(device_t dev) ether_ifdetach(ifp); } - if (sc->nge_miibus != NULL) { - device_delete_child(dev, sc->nge_miibus); - sc->nge_miibus = NULL; - } bus_generic_detach(dev); if (sc->nge_intrhand != NULL) bus_teardown_intr(dev, sc->nge_irq, sc->nge_intrhand); diff --git a/sys/dev/pccbb/pccbb.c b/sys/dev/pccbb/pccbb.c index c40261be4724..b8fb7827dfbf 100644 --- a/sys/dev/pccbb/pccbb.c +++ b/sys/dev/pccbb/pccbb.c @@ -275,42 +275,12 @@ int cbb_detach(device_t brdev) { struct cbb_softc *sc = device_get_softc(brdev); - device_t *devlist; - int tmp, tries, error, numdevs; + int error; - /* - * Before we delete the children (which we have to do because - * attach doesn't check for children busses correctly), we have - * to detach the children. Even if we didn't need to delete the - * children, we have to detach them. - */ error = bus_generic_detach(brdev); if (error != 0) return (error); - /* - * Since the attach routine doesn't search for children before it - * attaches them to this device, we must delete them here in order - * for the kldload/unload case to work. If we failed to do that, then - * we'd get duplicate devices when cbb.ko was reloaded. - */ - tries = 10; - do { - error = device_get_children(brdev, &devlist, &numdevs); - if (error == 0) - break; - /* - * Try hard to cope with low memory. - */ - if (error == ENOMEM) { - pause("cbbnomem", 1); - continue; - } - } while (tries-- > 0); - for (tmp = 0; tmp < numdevs; tmp++) - device_delete_child(brdev, devlist[tmp]); - free(devlist, M_TEMP); - /* Turn off the interrupts */ cbb_set(sc, CBB_SOCKET_MASK, 0); diff --git a/sys/dev/re/if_re.c b/sys/dev/re/if_re.c index 69593e68d36f..f6c28209d504 100644 --- a/sys/dev/re/if_re.c +++ b/sys/dev/re/if_re.c @@ -1803,8 +1803,6 @@ re_detach(device_t dev) if_setflagbits(ifp, 0, IFF_UP); ether_ifdetach(ifp); } - if (sc->rl_miibus) - device_delete_child(dev, sc->rl_miibus); bus_generic_detach(dev); /* diff --git a/sys/dev/rl/if_rl.c b/sys/dev/rl/if_rl.c index cd60561ad2d8..4a5f375c2dd3 100644 --- a/sys/dev/rl/if_rl.c +++ b/sys/dev/rl/if_rl.c @@ -882,8 +882,6 @@ rl_detach(device_t dev) #if 0 sc->suspended = 1; #endif - if (sc->rl_miibus) - device_delete_child(dev, sc->rl_miibus); bus_generic_detach(dev); if (sc->rl_intrhand[0]) diff --git a/sys/dev/sge/if_sge.c b/sys/dev/sge/if_sge.c index c6e8f4790190..80ec0c435ead 100644 --- a/sys/dev/sge/if_sge.c +++ b/sys/dev/sge/if_sge.c @@ -675,8 +675,6 @@ sge_detach(device_t dev) SGE_UNLOCK(sc); callout_drain(&sc->sge_stat_ch); } - if (sc->sge_miibus) - device_delete_child(dev, sc->sge_miibus); bus_generic_detach(dev); if (sc->sge_intrhand) diff --git a/sys/dev/sis/if_sis.c b/sys/dev/sis/if_sis.c index 64a43b2bf51e..5879674b4fbb 100644 --- a/sys/dev/sis/if_sis.c +++ b/sys/dev/sis/if_sis.c @@ -1146,8 +1146,6 @@ sis_detach(device_t dev) callout_drain(&sc->sis_stat_ch); ether_ifdetach(ifp); } - if (sc->sis_miibus) - device_delete_child(dev, sc->sis_miibus); bus_generic_detach(dev); if (sc->sis_intrhand) diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c index 643b49119ef1..094211cc3c34 100644 --- a/sys/dev/sk/if_sk.c +++ b/sys/dev/sk/if_sk.c @@ -1771,15 +1771,6 @@ sk_detach(device_t dev) ether_ifdetach(ifp); SK_IF_LOCK(sc_if); } - /* - * We're generally called from skc_detach() which is using - * device_delete_child() to get to here. It's already trashed - * miibus for us, so don't do it here or we'll panic. - */ - /* - if (sc_if->sk_miibus != NULL) - device_delete_child(dev, sc_if->sk_miibus); - */ bus_generic_detach(dev); sk_dma_jumbo_free(sc_if); sk_dma_free(sc_if); @@ -1798,15 +1789,7 @@ skc_detach(device_t dev) sc = device_get_softc(dev); KASSERT(mtx_initialized(&sc->sk_mtx), ("sk mutex not initialized")); - if (device_is_alive(dev)) { - if (sc->sk_devs[SK_PORT_A] != NULL) { - device_delete_child(dev, sc->sk_devs[SK_PORT_A]); - } - if (sc->sk_devs[SK_PORT_B] != NULL) { - device_delete_child(dev, sc->sk_devs[SK_PORT_B]); - } - bus_generic_detach(dev); - } + bus_generic_detach(dev); if (sc->sk_intrhand) bus_teardown_intr(dev, sc->sk_res[1], sc->sk_intrhand); diff --git a/sys/dev/smc/if_smc.c b/sys/dev/smc/if_smc.c index 12e903d1af9b..cc05cfd45f67 100644 --- a/sys/dev/smc/if_smc.c +++ b/sys/dev/smc/if_smc.c @@ -450,10 +450,7 @@ smc_detach(device_t dev) if_free(sc->smc_ifp); } - if (sc->smc_miibus != NULL) { - device_delete_child(sc->smc_dev, sc->smc_miibus); - bus_generic_detach(sc->smc_dev); - } + bus_generic_detach(sc->smc_dev); if (sc->smc_reg != NULL) { type = SYS_RES_IOPORT; diff --git a/sys/dev/ste/if_ste.c b/sys/dev/ste/if_ste.c index 06e25175c617..7b347a97712f 100644 --- a/sys/dev/ste/if_ste.c +++ b/sys/dev/ste/if_ste.c @@ -1074,8 +1074,6 @@ ste_detach(device_t dev) STE_UNLOCK(sc); callout_drain(&sc->ste_callout); } - if (sc->ste_miibus) - device_delete_child(dev, sc->ste_miibus); bus_generic_detach(dev); if (sc->ste_intrhand) diff --git a/sys/dev/stge/if_stge.c b/sys/dev/stge/if_stge.c index 97c2b751d476..a9a30332358c 100644 --- a/sys/dev/stge/if_stge.c +++ b/sys/dev/stge/if_stge.c @@ -672,10 +672,6 @@ stge_detach(device_t dev) ether_ifdetach(ifp); } - if (sc->sc_miibus != NULL) { - device_delete_child(dev, sc->sc_miibus); - sc->sc_miibus = NULL; - } bus_generic_detach(dev); stge_dma_free(sc); diff --git a/sys/dev/vge/if_vge.c b/sys/dev/vge/if_vge.c index 9f71049a150b..395715e67e48 100644 --- a/sys/dev/vge/if_vge.c +++ b/sys/dev/vge/if_vge.c @@ -1177,8 +1177,6 @@ vge_detach(device_t dev) VGE_UNLOCK(sc); callout_drain(&sc->vge_watchdog); } - if (sc->vge_miibus) - device_delete_child(dev, sc->vge_miibus); bus_generic_detach(dev); if (sc->vge_intrhand) diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c index 02b55ef4f304..47de78166d35 100644 --- a/sys/dev/vr/if_vr.c +++ b/sys/dev/vr/if_vr.c @@ -838,8 +838,6 @@ vr_detach(device_t dev) taskqueue_drain(taskqueue_fast, &sc->vr_inttask); ether_ifdetach(ifp); } - if (sc->vr_miibus) - device_delete_child(dev, sc->vr_miibus); bus_generic_detach(dev); if (sc->vr_intrhand) diff --git a/sys/dev/vte/if_vte.c b/sys/dev/vte/if_vte.c index 64da34364341..f32053c36cee 100644 --- a/sys/dev/vte/if_vte.c +++ b/sys/dev/vte/if_vte.c @@ -506,10 +506,6 @@ vte_detach(device_t dev) ether_ifdetach(ifp); } - if (sc->vte_miibus != NULL) { - device_delete_child(dev, sc->vte_miibus); - sc->vte_miibus = NULL; - } bus_generic_detach(dev); if (sc->vte_intrhand != NULL) { diff --git a/sys/dev/xl/if_xl.c b/sys/dev/xl/if_xl.c index 32f95549b774..8e12ba7d67b2 100644 --- a/sys/dev/xl/if_xl.c +++ b/sys/dev/xl/if_xl.c @@ -1572,8 +1572,6 @@ xl_detach(device_t dev) callout_drain(&sc->xl_tick_callout); ether_ifdetach(ifp); } - if (sc->xl_miibus) - device_delete_child(dev, sc->xl_miibus); bus_generic_detach(dev); ifmedia_removeall(&sc->ifmedia);