git: cf416f56eb73 - main - Use the new bus_generic_detach directly in place of home-grown versions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 02 Jan 2025 18:28:19 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=cf416f56eb73006b32f9279da6a848299ede3f1d
commit cf416f56eb73006b32f9279da6a848299ede3f1d
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-01-02 18:22:20 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-01-02 18:22:20 +0000
Use the new bus_generic_detach directly in place of home-grown versions
Differential Revision: https://reviews.freebsd.org/D47960
---
sys/dev/bwn/if_bwn_pci.c | 13 +------------
sys/dev/iicbus/iicbb.c | 13 +------------
sys/dev/imcsmb/imcsmb.c | 27 +--------------------------
sys/dev/imcsmb/imcsmb_pci.c | 27 +--------------------------
sys/dev/p2sb/lewisburg_gpiocm.c | 14 +-------------
sys/dev/pci/vga_pci.c | 13 +------------
sys/dev/ppbus/ppbconf.c | 17 +----------------
sys/dev/pwm/pwmbus.c | 13 +------------
sys/dev/usb/misc/cp2112.c | 17 ++---------------
9 files changed, 10 insertions(+), 144 deletions(-)
diff --git a/sys/dev/bwn/if_bwn_pci.c b/sys/dev/bwn/if_bwn_pci.c
index e2ba15dd67c8..a81284158443 100644
--- a/sys/dev/bwn/if_bwn_pci.c
+++ b/sys/dev/bwn/if_bwn_pci.c
@@ -189,17 +189,6 @@ bwn_pci_attach(device_t dev)
return (0);
}
-static int
-bwn_pci_detach(device_t dev)
-{
- int error;
-
- if ((error = bus_generic_detach(dev)))
- return (error);
-
- return (device_delete_children(dev));
-}
-
static void
bwn_pci_probe_nomatch(device_t dev, device_t child)
{
@@ -268,7 +257,7 @@ static device_method_t bwn_pci_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, bwn_pci_probe),
DEVMETHOD(device_attach, bwn_pci_attach),
- DEVMETHOD(device_detach, bwn_pci_detach),
+ DEVMETHOD(device_detach, bus_generic_detach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
diff --git a/sys/dev/iicbus/iicbb.c b/sys/dev/iicbus/iicbb.c
index dec5e4bc0c7e..c344bda930b0 100644
--- a/sys/dev/iicbus/iicbb.c
+++ b/sys/dev/iicbus/iicbb.c
@@ -80,7 +80,6 @@ struct iicbb_softc {
static int iicbb_attach(device_t);
static void iicbb_child_detached(device_t, device_t);
-static int iicbb_detach(device_t);
static int iicbb_print_child(device_t, device_t);
static int iicbb_probe(device_t);
@@ -101,7 +100,7 @@ static device_method_t iicbb_methods[] = {
/* device interface */
DEVMETHOD(device_probe, iicbb_probe),
DEVMETHOD(device_attach, iicbb_attach),
- DEVMETHOD(device_detach, iicbb_detach),
+ DEVMETHOD(device_detach, bus_generic_detach),
/* bus interface */
DEVMETHOD(bus_child_detached, iicbb_child_detached),
@@ -168,16 +167,6 @@ iicbb_attach(device_t dev)
return (0);
}
-static int
-iicbb_detach(device_t dev)
-{
-
- bus_generic_detach(dev);
- device_delete_children(dev);
-
- return (0);
-}
-
#ifdef FDT
static phandle_t
iicbb_get_node(device_t bus, device_t dev)
diff --git a/sys/dev/imcsmb/imcsmb.c b/sys/dev/imcsmb/imcsmb.c
index 2507d948e8e4..50280ad1b0f7 100644
--- a/sys/dev/imcsmb/imcsmb.c
+++ b/sys/dev/imcsmb/imcsmb.c
@@ -53,7 +53,6 @@
/* Device methods */
static int imcsmb_attach(device_t dev);
-static int imcsmb_detach(device_t dev);
static int imcsmb_probe(device_t dev);
/* SMBus methods */
@@ -106,30 +105,6 @@ out:
return (rc);
}
-/**
- * device_detach() method. attach() didn't do any allocations, so all that's
- * needed here is to free up any downstream drivers and children.
- *
- * @author Joe Kloss
- *
- * @param[in] dev
- * Device being detached.
- */
-static int
-imcsmb_detach(device_t dev)
-{
- int rc;
-
- /* Detach any attached drivers */
- rc = bus_generic_detach(dev);
- if (rc == 0) {
- /* Remove all children */
- rc = device_delete_children(dev);
- }
-
- return (rc);
-}
-
/**
* device_probe() method. All the actual probing was done by the imcsmb_pci
* parent, so just report success.
@@ -522,7 +497,7 @@ out:
static device_method_t imcsmb_methods[] = {
/* Device interface */
DEVMETHOD(device_attach, imcsmb_attach),
- DEVMETHOD(device_detach, imcsmb_detach),
+ DEVMETHOD(device_detach, bus_generic_detach),
DEVMETHOD(device_probe, imcsmb_probe),
/* smbus methods */
diff --git a/sys/dev/imcsmb/imcsmb_pci.c b/sys/dev/imcsmb/imcsmb_pci.c
index c6e5d1d690c0..6e9e601989b1 100644
--- a/sys/dev/imcsmb/imcsmb_pci.c
+++ b/sys/dev/imcsmb/imcsmb_pci.c
@@ -146,7 +146,6 @@ static struct imcsmb_pci_device {
/* Device methods. */
static int imcsmb_pci_attach(device_t dev);
-static int imcsmb_pci_detach(device_t dev);
static int imcsmb_pci_probe(device_t dev);
/**
@@ -195,30 +194,6 @@ out:
return (rc);
}
-/**
- * device_detach() method. attach() didn't do any allocations, so all that's
- * needed here is to free up any downstream drivers and children.
- *
- * @author Joe Kloss
- *
- * @param[in] dev
- * Device being detached.
- */
-static int
-imcsmb_pci_detach(device_t dev)
-{
- int rc;
-
- /* Detach any attached drivers */
- rc = bus_generic_detach(dev);
- if (rc == 0) {
- /* Remove all children */
- rc = device_delete_children(dev);
- }
-
- return (rc);
-}
-
/**
* device_probe() method. Look for the right PCI vendor/device IDs.
*
@@ -318,7 +293,7 @@ imcsmb_pci_request_bus(device_t dev)
static device_method_t imcsmb_pci_methods[] = {
/* Device interface */
DEVMETHOD(device_attach, imcsmb_pci_attach),
- DEVMETHOD(device_detach, imcsmb_pci_detach),
+ DEVMETHOD(device_detach, bus_generic_detach),
DEVMETHOD(device_probe, imcsmb_pci_probe),
DEVMETHOD_END
diff --git a/sys/dev/p2sb/lewisburg_gpiocm.c b/sys/dev/p2sb/lewisburg_gpiocm.c
index 7eeab669d625..f5c1792c69e1 100644
--- a/sys/dev/p2sb/lewisburg_gpiocm.c
+++ b/sys/dev/p2sb/lewisburg_gpiocm.c
@@ -322,23 +322,11 @@ lbggpiocm_attach(device_t dev)
return (0);
}
-static int
-lbggpiocm_detach(device_t dev)
-{
- int error;
-
- error = device_delete_children(dev);
- if (error)
- return (error);
-
- return (bus_generic_detach(dev));
-}
-
static device_method_t lbggpiocm_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, lbggpiocm_probe),
DEVMETHOD(device_attach, lbggpiocm_attach),
- DEVMETHOD(device_detach, lbggpiocm_detach),
+ DEVMETHOD(device_detach, bus_generic_detach),
DEVMETHOD_END
};
diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c
index 243c0b53dda4..09166c0cbea6 100644
--- a/sys/dev/pci/vga_pci.c
+++ b/sys/dev/pci/vga_pci.c
@@ -378,17 +378,6 @@ vga_pci_attach(device_t dev)
return (0);
}
-static int
-vga_pci_detach(device_t dev)
-{
- int error;
-
- error = bus_generic_detach(dev);
- if (error == 0)
- error = device_delete_children(dev);
- return (error);
-}
-
/* Bus interface. */
static int
@@ -719,7 +708,7 @@ static device_method_t vga_pci_methods[] = {
DEVMETHOD(device_attach, vga_pci_attach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_detach, vga_pci_detach),
+ DEVMETHOD(device_detach, bus_generic_detach),
DEVMETHOD(device_resume, bus_generic_resume),
/* Bus interface */
diff --git a/sys/dev/ppbus/ppbconf.c b/sys/dev/ppbus/ppbconf.c
index 17fef1eebde7..2c3f17318747 100644
--- a/sys/dev/ppbus/ppbconf.c
+++ b/sys/dev/ppbus/ppbconf.c
@@ -419,21 +419,6 @@ ppbus_attach(device_t dev)
return (0);
}
-static int
-ppbus_detach(device_t dev)
-{
- int error;
-
- error = bus_generic_detach(dev);
- if (error)
- return (error);
-
- /* detach & delete all children */
- device_delete_children(dev);
-
- return (0);
-}
-
static int
ppbus_intr(void *arg)
{
@@ -578,7 +563,7 @@ static device_method_t ppbus_methods[] = {
/* device interface */
DEVMETHOD(device_probe, ppbus_probe),
DEVMETHOD(device_attach, ppbus_attach),
- DEVMETHOD(device_detach, ppbus_detach),
+ DEVMETHOD(device_detach, bus_generic_detach),
/* bus interface */
DEVMETHOD(bus_add_child, ppbus_add_child),
diff --git a/sys/dev/pwm/pwmbus.c b/sys/dev/pwm/pwmbus.c
index ae40a23d0d45..c0c07a36c277 100644
--- a/sys/dev/pwm/pwmbus.c
+++ b/sys/dev/pwm/pwmbus.c
@@ -188,17 +188,6 @@ pwmbus_attach(device_t dev)
return (0);
}
-static int
-pwmbus_detach(device_t dev)
-{
- int rv;
-
- if ((rv = bus_generic_detach(dev)) == 0)
- rv = device_delete_children(dev);
-
- return (rv);
-}
-
/*
* pwmbus_if methods...
*/
@@ -249,7 +238,7 @@ static device_method_t pwmbus_methods[] = {
/* device_if */
DEVMETHOD(device_probe, pwmbus_probe),
DEVMETHOD(device_attach, pwmbus_attach),
- DEVMETHOD(device_detach, pwmbus_detach),
+ DEVMETHOD(device_detach, bus_generic_detach),
/* bus_if */
DEVMETHOD(bus_add_child, pwmbus_add_child),
diff --git a/sys/dev/usb/misc/cp2112.c b/sys/dev/usb/misc/cp2112.c
index 2492eae978bb..e3587241f412 100644
--- a/sys/dev/usb/misc/cp2112.c
+++ b/sys/dev/usb/misc/cp2112.c
@@ -252,7 +252,6 @@ struct cp2112iic_softc {
} io;
};
-static int cp2112_detach(device_t dev);
static int cp2112gpio_detach(device_t dev);
static int cp2112iic_detach(device_t dev);
@@ -351,22 +350,10 @@ cp2112_attach(device_t dev)
return (0);
detach:
- cp2112_detach(dev);
+ bus_generic_detach(dev);
return (ENXIO);
}
-static int
-cp2112_detach(device_t dev)
-{
- int err;
-
- err = bus_generic_detach(dev);
- if (err != 0)
- return (err);
- device_delete_children(dev);
- return (0);
-}
-
static int
cp2112_gpio_read_pin(device_t dev, uint32_t pin_num, bool *on)
{
@@ -1374,7 +1361,7 @@ cp2112iic_detach(device_t dev)
static device_method_t cp2112hid_methods[] = {
DEVMETHOD(device_probe, cp2112_probe),
DEVMETHOD(device_attach, cp2112_attach),
- DEVMETHOD(device_detach, cp2112_detach),
+ DEVMETHOD(device_detach, bus_generic_detach),
DEVMETHOD_END
};