aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2025-01-02 18:24:28 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2025-01-02 18:24:28 +0000
commit3ddaf8200bc90b1410755ebac7b5c979ea90a2f6 (patch)
tree6991e24d4ee73db1084a04ccf55098123c293422 /sys/dev/usb
parent20f932af2973afc7624ac40a843b85b48a3947c7 (diff)
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/controller/dwc_otg_acpi.c5
-rw-r--r--sys/dev/usb/controller/dwc_otg_fdt.c5
-rw-r--r--sys/dev/usb/controller/ehci_fsl.c14
-rw-r--r--sys/dev/usb/controller/ehci_imx.c2
-rw-r--r--sys/dev/usb/controller/ehci_msm.c10
-rw-r--r--sys/dev/usb/controller/ehci_mv.c4
-rw-r--r--sys/dev/usb/controller/ehci_pci.c5
-rw-r--r--sys/dev/usb/controller/generic_ehci.c4
-rw-r--r--sys/dev/usb/controller/generic_ohci.c4
-rw-r--r--sys/dev/usb/controller/generic_xhci.c4
-rw-r--r--sys/dev/usb/controller/musb_otg_allwinner.c13
-rw-r--r--sys/dev/usb/controller/ohci_pci.c5
-rw-r--r--sys/dev/usb/controller/uhci_pci.c5
-rw-r--r--sys/dev/usb/controller/xhci_pci.c5
-rw-r--r--sys/dev/usb/input/usbhid.c6
-rw-r--r--sys/dev/usb/video/udl.c5
16 files changed, 58 insertions, 38 deletions
diff --git a/sys/dev/usb/controller/dwc_otg_acpi.c b/sys/dev/usb/controller/dwc_otg_acpi.c
index 9b982dfd6e41..5d509911a54a 100644
--- a/sys/dev/usb/controller/dwc_otg_acpi.c
+++ b/sys/dev/usb/controller/dwc_otg_acpi.c
@@ -127,9 +127,12 @@ static int
dwc_otg_detach(device_t dev)
{
struct dwc_otg_softc *sc = device_get_softc(dev);
+ int error;
/* during module unload there are lots of children leftover */
- device_delete_children(dev);
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
if (sc->sc_irq_res && sc->sc_intr_hdl) {
/*
diff --git a/sys/dev/usb/controller/dwc_otg_fdt.c b/sys/dev/usb/controller/dwc_otg_fdt.c
index d692638857c5..3d5dcb9e9a7b 100644
--- a/sys/dev/usb/controller/dwc_otg_fdt.c
+++ b/sys/dev/usb/controller/dwc_otg_fdt.c
@@ -162,9 +162,12 @@ int
dwc_otg_detach(device_t dev)
{
struct dwc_otg_fdt_softc *sc = device_get_softc(dev);
+ int error;
/* during module unload there are lots of children leftover */
- device_delete_children(dev);
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
if (sc->sc_otg.sc_irq_res && sc->sc_otg.sc_intr_hdl) {
/*
diff --git a/sys/dev/usb/controller/ehci_fsl.c b/sys/dev/usb/controller/ehci_fsl.c
index 49d23996b696..ed3d4c64f4f8 100644
--- a/sys/dev/usb/controller/ehci_fsl.c
+++ b/sys/dev/usb/controller/ehci_fsl.c
@@ -372,10 +372,14 @@ fsl_ehci_attach(device_t self)
static int
fsl_ehci_detach(device_t self)
{
-
int err;
ehci_softc_t *sc;
+ /* During module unload there are lots of children leftover */
+ err = bus_generic_detach(self);
+ if (err != 0)
+ return (err);
+
sc = device_get_softc(self);
/*
* only call ehci_detach() after ehci_init()
@@ -399,14 +403,6 @@ fsl_ehci_detach(device_t self)
sc->sc_intr_hdl = NULL;
}
- if (sc->sc_bus.bdev) {
- device_delete_child(self, sc->sc_bus.bdev);
- sc->sc_bus.bdev = NULL;
- }
-
- /* During module unload there are lots of children leftover */
- device_delete_children(self);
-
if (sc->sc_irq_res) {
bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res);
sc->sc_irq_res = NULL;
diff --git a/sys/dev/usb/controller/ehci_imx.c b/sys/dev/usb/controller/ehci_imx.c
index 0ab9bf0ed6f2..caba6b7da85a 100644
--- a/sys/dev/usb/controller/ehci_imx.c
+++ b/sys/dev/usb/controller/ehci_imx.c
@@ -314,7 +314,7 @@ imx_ehci_detach(device_t dev)
esc = &sc->ehci_softc;
/* First detach all children; we can't detach if that fails. */
- if ((err = device_delete_children(dev)) != 0)
+ if ((err = bus_generic_detach(dev)) != 0)
return (err);
if (esc->sc_flags & EHCI_SCFLG_DONEINIT)
diff --git a/sys/dev/usb/controller/ehci_msm.c b/sys/dev/usb/controller/ehci_msm.c
index c628d5bf8fde..7f06ad6a1600 100644
--- a/sys/dev/usb/controller/ehci_msm.c
+++ b/sys/dev/usb/controller/ehci_msm.c
@@ -171,13 +171,9 @@ ehci_msm_detach(device_t dev)
sc = device_get_softc(dev);
- if (sc->sc_bus.bdev) {
- bdev = sc->sc_bus.bdev;
- device_detach(bdev);
- device_delete_child(dev, bdev);
- }
-
- device_delete_children(dev);
+ err = bus_generic_detach(dev);
+ if (err != 0)
+ return (err);
if (sc->sc_irq_res && sc->sc_intr_hdl) {
/* only call ehci_detach() after ehci_init() */
diff --git a/sys/dev/usb/controller/ehci_mv.c b/sys/dev/usb/controller/ehci_mv.c
index 5535cb061949..817cd68257c8 100644
--- a/sys/dev/usb/controller/ehci_mv.c
+++ b/sys/dev/usb/controller/ehci_mv.c
@@ -283,7 +283,9 @@ mv_ehci_detach(device_t self)
int err;
/* during module unload there are lots of children leftover */
- device_delete_children(self);
+ err = bus_generic_detach(self);
+ if (err != 0)
+ return (err);
/*
* disable interrupts that might have been switched on in mv_ehci_attach
diff --git a/sys/dev/usb/controller/ehci_pci.c b/sys/dev/usb/controller/ehci_pci.c
index 5141548bf793..bc75669a8d20 100644
--- a/sys/dev/usb/controller/ehci_pci.c
+++ b/sys/dev/usb/controller/ehci_pci.c
@@ -505,9 +505,12 @@ static int
ehci_pci_detach(device_t self)
{
ehci_softc_t *sc = device_get_softc(self);
+ int error;
/* during module unload there are lots of children leftover */
- device_delete_children(self);
+ error = bus_generic_detach(self);
+ if (error != 0)
+ return (error);
pci_disable_busmaster(self);
diff --git a/sys/dev/usb/controller/generic_ehci.c b/sys/dev/usb/controller/generic_ehci.c
index e660a338df64..35a9564631e0 100644
--- a/sys/dev/usb/controller/generic_ehci.c
+++ b/sys/dev/usb/controller/generic_ehci.c
@@ -139,7 +139,9 @@ generic_ehci_detach(device_t self)
int err;
/* during module unload there are lots of children leftover */
- device_delete_children(self);
+ err = bus_generic_detach(self);
+ if (err != 0)
+ return (err);
if (sc->sc_irq_res && sc->sc_intr_hdl) {
/*
diff --git a/sys/dev/usb/controller/generic_ohci.c b/sys/dev/usb/controller/generic_ohci.c
index fe4493fda977..5c0de59074d2 100644
--- a/sys/dev/usb/controller/generic_ohci.c
+++ b/sys/dev/usb/controller/generic_ohci.c
@@ -231,7 +231,9 @@ generic_ohci_detach(device_t dev)
struct hwrst_list *rst, *rst_tmp;
/* during module unload there are lots of children leftover */
- device_delete_children(dev);
+ err = bus_generic_detach(dev);
+ if (err != 0)
+ return (err);
/*
* Put the controller into reset, then disable clocks and do
diff --git a/sys/dev/usb/controller/generic_xhci.c b/sys/dev/usb/controller/generic_xhci.c
index 95551aafa519..f64e1fd01ba0 100644
--- a/sys/dev/usb/controller/generic_xhci.c
+++ b/sys/dev/usb/controller/generic_xhci.c
@@ -152,7 +152,9 @@ generic_xhci_detach(device_t dev)
int err;
/* during module unload there are lots of children leftover */
- device_delete_children(dev);
+ err = bus_generic_detach(dev);
+ if (err != 0)
+ return (err);
if (sc->sc_irq_res != NULL && sc->sc_intr_hdl != NULL) {
err = bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intr_hdl);
diff --git a/sys/dev/usb/controller/musb_otg_allwinner.c b/sys/dev/usb/controller/musb_otg_allwinner.c
index c52b381fd16a..574e8e712713 100644
--- a/sys/dev/usb/controller/musb_otg_allwinner.c
+++ b/sys/dev/usb/controller/musb_otg_allwinner.c
@@ -561,16 +561,13 @@ static int
awusbdrd_detach(device_t dev)
{
struct awusbdrd_softc *sc;
- device_t bdev;
int error;
- sc = device_get_softc(dev);
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
- if (sc->sc.sc_bus.bdev != NULL) {
- bdev = sc->sc.sc_bus.bdev;
- device_detach(bdev);
- device_delete_child(dev, bdev);
- }
+ sc = device_get_softc(dev);
musbotg_uninit(&sc->sc);
error = bus_teardown_intr(dev, sc->res[1], sc->sc.sc_intr_hdl);
@@ -594,8 +591,6 @@ awusbdrd_detach(device_t dev)
bus_release_resources(dev, awusbdrd_spec, sc->res);
- device_delete_children(dev);
-
return (0);
}
diff --git a/sys/dev/usb/controller/ohci_pci.c b/sys/dev/usb/controller/ohci_pci.c
index 03291ff34a6f..027be4ce9588 100644
--- a/sys/dev/usb/controller/ohci_pci.c
+++ b/sys/dev/usb/controller/ohci_pci.c
@@ -320,9 +320,12 @@ static int
ohci_pci_detach(device_t self)
{
ohci_softc_t *sc = device_get_softc(self);
+ int error;
/* during module unload there are lots of children leftover */
- device_delete_children(self);
+ error = bus_generic_detach(self);
+ if (error != 0)
+ return (error);
pci_disable_busmaster(self);
diff --git a/sys/dev/usb/controller/uhci_pci.c b/sys/dev/usb/controller/uhci_pci.c
index 90f3dca8f830..0dc2763aed8d 100644
--- a/sys/dev/usb/controller/uhci_pci.c
+++ b/sys/dev/usb/controller/uhci_pci.c
@@ -414,9 +414,12 @@ int
uhci_pci_detach(device_t self)
{
uhci_softc_t *sc = device_get_softc(self);
+ int error;
/* during module unload there are lots of children leftover */
- device_delete_children(self);
+ error = bus_generic_detach(self);
+ if (error != 0)
+ return (error);
/*
* disable interrupts that might have been switched on in
diff --git a/sys/dev/usb/controller/xhci_pci.c b/sys/dev/usb/controller/xhci_pci.c
index 6f128f1d2fa7..c436f60aefcf 100644
--- a/sys/dev/usb/controller/xhci_pci.c
+++ b/sys/dev/usb/controller/xhci_pci.c
@@ -465,9 +465,12 @@ static int
xhci_pci_detach(device_t self)
{
struct xhci_softc *sc = device_get_softc(self);
+ int error;
/* during module unload there are lots of children leftover */
- device_delete_children(self);
+ error = bus_generic_detach(self);
+ if (error != 0)
+ return (error);
usb_callout_drain(&sc->sc_callout);
xhci_halt_controller(sc);
diff --git a/sys/dev/usb/input/usbhid.c b/sys/dev/usb/input/usbhid.c
index d357a699b527..e88588182ae5 100644
--- a/sys/dev/usb/input/usbhid.c
+++ b/sys/dev/usb/input/usbhid.c
@@ -851,8 +851,12 @@ static int
usbhid_detach(device_t dev)
{
struct usbhid_softc *sc = device_get_softc(dev);
+ int error;
+
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
- device_delete_children(dev);
mtx_destroy(&sc->sc_mtx);
return (0);
diff --git a/sys/dev/usb/video/udl.c b/sys/dev/usb/video/udl.c
index b5af3be8bc50..213f1f5bb957 100644
--- a/sys/dev/usb/video/udl.c
+++ b/sys/dev/usb/video/udl.c
@@ -441,9 +441,12 @@ static int
udl_detach(device_t dev)
{
struct udl_softc *sc = device_get_softc(dev);
+ int error;
/* delete all child devices */
- device_delete_children(dev);
+ error = bus_generic_detach(dev);
+ if (error != 0)
+ return (error);
UDL_LOCK(sc);
sc->sc_gone = 1;