git: 160179ea3e24 - main - Remove now-redundant calls to device_delete_children

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 02 Jan 2025 18:28:22 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=160179ea3e24651cd8b15a4fafce519546eac505

commit 160179ea3e24651cd8b15a4fafce519546eac505
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-01-02 18:22:50 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-01-02 18:22:50 +0000

    Remove now-redundant calls to device_delete_children
    
    Earlier calls to bus_generic_detach now take care of deleting
    children.
    
    Differential Revision:  https://reviews.freebsd.org/D47962
---
 sys/arm/ti/cpsw/if_cpsw.c                       |  2 +-
 sys/dev/cardbus/cardbus.c                       |  2 --
 sys/dev/cxgbe/t4_main.c                         |  1 -
 sys/dev/dpaa2/dpaa2_mc.c                        |  2 +-
 sys/dev/dpaa2/dpaa2_rc.c                        |  2 +-
 sys/dev/gpio/gpiobus.c                          | 10 +---------
 sys/dev/hid/hidbus.c                            |  3 +--
 sys/dev/ida/ida.c                               |  3 ---
 sys/dev/iicbus/controller/opencores/iicoc_pci.c |  1 -
 sys/dev/iicbus/iicsmb.c                         |  1 -
 sys/dev/nvdimm/nvdimm_acpi.c                    |  7 +------
 sys/dev/pci/pci.c                               |  4 +---
 sys/dev/superio/superio.c                       |  1 -
 sys/dev/usb/misc/cp2112.c                       |  1 -
 sys/dev/usb/misc/i2ctinyusb.c                   |  1 -
 sys/dev/vmd/vmd.c                               |  3 ---
 16 files changed, 7 insertions(+), 37 deletions(-)

diff --git a/sys/arm/ti/cpsw/if_cpsw.c b/sys/arm/ti/cpsw/if_cpsw.c
index 674a7ed8575a..5b443e6c2712 100644
--- a/sys/arm/ti/cpsw/if_cpsw.c
+++ b/sys/arm/ti/cpsw/if_cpsw.c
@@ -965,7 +965,7 @@ cpsw_detach(device_t dev)
 	if (error != 0)
 		return (error);
         
-	return (device_delete_children(dev));
+	return (0);
 }
 
 static phandle_t
diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c
index f375eb112cce..21467a11cb68 100644
--- a/sys/dev/cardbus/cardbus.c
+++ b/sys/dev/cardbus/cardbus.c
@@ -245,8 +245,6 @@ cardbus_detach_card(device_t cbdev)
 
 	bus_topo_lock();
 	err = bus_generic_detach(cbdev);
-	if (err == 0)
-		err = device_delete_children(cbdev);
 	bus_topo_unlock();
 	if (err)
 		return (err);
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index 024c97dcb78c..e4120e76000c 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -2814,7 +2814,6 @@ cxgbe_detach(device_t dev)
 	rc = bus_generic_detach(dev);
 	if (rc)
 		return (rc);
-	device_delete_children(dev);
 
 	sysctl_ctx_free(&pi->ctx);
 	begin_vi_detach(sc, &pi->vi[0]);
diff --git a/sys/dev/dpaa2/dpaa2_mc.c b/sys/dev/dpaa2/dpaa2_mc.c
index c84b22d1d74d..8abfc3bfe1cc 100644
--- a/sys/dev/dpaa2/dpaa2_mc.c
+++ b/sys/dev/dpaa2/dpaa2_mc.c
@@ -292,7 +292,7 @@ dpaa2_mc_detach(device_t dev)
 	if (dinfo)
 		free(dinfo, M_DPAA2_MC);
 
-	return (device_delete_children(dev));
+	return (0);
 }
 
 /*
diff --git a/sys/dev/dpaa2/dpaa2_rc.c b/sys/dev/dpaa2/dpaa2_rc.c
index 7f8eddff1353..d8e15e388bf5 100644
--- a/sys/dev/dpaa2/dpaa2_rc.c
+++ b/sys/dev/dpaa2/dpaa2_rc.c
@@ -114,7 +114,7 @@ dpaa2_rc_detach(device_t dev)
 	if (dinfo)
 		free(dinfo, M_DPAA2_RC);
 
-	return (device_delete_children(dev));
+	return (0);
 }
 
 static int
diff --git a/sys/dev/gpio/gpiobus.c b/sys/dev/gpio/gpiobus.c
index 37371fa4e1cc..e053adacf457 100644
--- a/sys/dev/gpio/gpiobus.c
+++ b/sys/dev/gpio/gpiobus.c
@@ -315,16 +315,10 @@ gpiobus_attach_bus(device_t dev)
 int
 gpiobus_detach_bus(device_t dev)
 {
-	int err;
-
 #ifdef FDT
 	ofw_gpiobus_unregister_provider(dev);
 #endif
-	err = bus_generic_detach(dev);
-	if (err != 0)
-		return (err);
-
-	return (device_delete_children(dev));
+	return (bus_generic_detach(dev));
 }
 
 int
@@ -584,8 +578,6 @@ gpiobus_detach(device_t dev)
 
 	if ((err = bus_detach_children(dev)) != 0)
 		return (err);
-	if ((err = device_delete_children(dev)) != 0)
-		return (err);
 
 	rman_fini(&sc->sc_intr_rman);
 	if (sc->sc_pins) {
diff --git a/sys/dev/hid/hidbus.c b/sys/dev/hid/hidbus.c
index 9b8b7fed8887..96d36c8d191d 100644
--- a/sys/dev/hid/hidbus.c
+++ b/sys/dev/hid/hidbus.c
@@ -297,8 +297,7 @@ hidbus_detach_children(device_t dev)
 
 	if (is_bus) {
 		/* If hidbus is passed, delete all children. */
-		bus_generic_detach(bus);
-		device_delete_children(bus);
+		error = bus_generic_detach(bus);
 	} else {
 		/*
 		 * If hidbus child is passed, delete all hidbus children
diff --git a/sys/dev/ida/ida.c b/sys/dev/ida/ida.c
index ea231b041e13..fa135b7fc9ed 100644
--- a/sys/dev/ida/ida.c
+++ b/sys/dev/ida/ida.c
@@ -346,9 +346,6 @@ ida_detach(device_t dev)
 	ida = (struct ida_softc *)device_get_softc(dev);
 
 	error = bus_generic_detach(dev);
-	if (error)
-		return (error);
-	error = device_delete_children(dev);
 	if (error)
 		return (error);
 
diff --git a/sys/dev/iicbus/controller/opencores/iicoc_pci.c b/sys/dev/iicbus/controller/opencores/iicoc_pci.c
index cecfa888349b..f01b4514936e 100644
--- a/sys/dev/iicbus/controller/opencores/iicoc_pci.c
+++ b/sys/dev/iicbus/controller/opencores/iicoc_pci.c
@@ -50,7 +50,6 @@ iicoc_detach(device_t dev)
 	struct iicoc_softc *sc;
 
 	sc = device_get_softc(dev);
-	device_delete_children(dev);
 	bus_generic_detach(dev);
 	bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem_res);
 	mtx_destroy(&sc->sc_mtx);
diff --git a/sys/dev/iicbus/iicsmb.c b/sys/dev/iicbus/iicsmb.c
index e502ad904070..a5885648632e 100644
--- a/sys/dev/iicbus/iicsmb.c
+++ b/sys/dev/iicbus/iicsmb.c
@@ -166,7 +166,6 @@ iicsmb_detach(device_t dev)
 	struct iicsmb_softc *sc = (struct iicsmb_softc *)device_get_softc(dev);
 
 	bus_generic_detach(dev);
-	device_delete_children(dev);
 	mtx_destroy(&sc->lock);
 
 	return (0);
diff --git a/sys/dev/nvdimm/nvdimm_acpi.c b/sys/dev/nvdimm/nvdimm_acpi.c
index b9803c2c3a05..39697e52eebb 100644
--- a/sys/dev/nvdimm/nvdimm_acpi.c
+++ b/sys/dev/nvdimm/nvdimm_acpi.c
@@ -206,7 +206,6 @@ nvdimm_root_detach(device_t dev)
 {
 	struct nvdimm_root_dev *root;
 	struct SPA_mapping *spa, *next;
-	int error;
 
 	root = device_get_softc(dev);
 	SLIST_FOREACH_SAFE(spa, &root->spas, link, next) {
@@ -215,11 +214,7 @@ nvdimm_root_detach(device_t dev)
 		SLIST_REMOVE_HEAD(&root->spas, link);
 		free(spa, M_NVDIMM_ACPI);
 	}
-	error = bus_generic_detach(dev);
-	if (error != 0)
-		return (error);
-	error = device_delete_children(dev);
-	return (error);
+	return (bus_generic_detach(dev));
 }
 
 static int
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index 64bce9f01ea8..251680590747 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -4510,9 +4510,7 @@ pci_detach(device_t dev)
 		return (error);
 	sc = device_get_softc(dev);
 	error = bus_release_resource(dev, PCI_RES_BUS, 0, sc->sc_bus);
-	if (error)
-		return (error);
-	return (device_delete_children(dev));
+	return (error);
 }
 
 static void
diff --git a/sys/dev/superio/superio.c b/sys/dev/superio/superio.c
index 7bed7bb510d3..94e97f197a93 100644
--- a/sys/dev/superio/superio.c
+++ b/sys/dev/superio/superio.c
@@ -740,7 +740,6 @@ superio_detach(device_t dev)
 		return (error);
 	if (sc->chardev != NULL)
 		destroy_dev(sc->chardev);
-	device_delete_children(dev);
 	bus_release_resource(dev, SYS_RES_IOPORT, sc->io_rid, sc->io_res);
 	mtx_destroy(&sc->conf_lock);
 	return (0);
diff --git a/sys/dev/usb/misc/cp2112.c b/sys/dev/usb/misc/cp2112.c
index e3587241f412..d4776ca342cb 100644
--- a/sys/dev/usb/misc/cp2112.c
+++ b/sys/dev/usb/misc/cp2112.c
@@ -1345,7 +1345,6 @@ cp2112iic_detach(device_t dev)
 	err = bus_generic_detach(dev);
 	if (err != 0)
 		return (err);
-	device_delete_children(dev);
 
 	mtx_lock(&sc->io.lock);
 	usbd_transfer_stop(sc->xfers[CP2112_INTR_IN]);
diff --git a/sys/dev/usb/misc/i2ctinyusb.c b/sys/dev/usb/misc/i2ctinyusb.c
index 47f27d9383a6..ca40fd5baf5c 100644
--- a/sys/dev/usb/misc/i2ctinyusb.c
+++ b/sys/dev/usb/misc/i2ctinyusb.c
@@ -193,7 +193,6 @@ i2ctinyusb_detach(device_t dev)
 	err = bus_generic_detach(dev);
 	if (err != 0)
 		return (err);
-	device_delete_children(dev);
 
 	mtx_destroy(&sc->sc_mtx);
 
diff --git a/sys/dev/vmd/vmd.c b/sys/dev/vmd/vmd.c
index 40565eab6f3e..0595a6c5be16 100644
--- a/sys/dev/vmd/vmd.c
+++ b/sys/dev/vmd/vmd.c
@@ -399,9 +399,6 @@ vmd_detach(device_t dev)
 	int error;
 
 	error = bus_generic_detach(dev);
-	if (error)
-		return (error);
-	error = device_delete_children(dev);
 	if (error)
 		return (error);
 	if (sc->vmd_msix_count == 0)