diff options
author | Ian Lepore <ian@FreeBSD.org> | 2018-07-05 16:00:58 +0000 |
---|---|---|
committer | Ian Lepore <ian@FreeBSD.org> | 2018-07-05 16:00:58 +0000 |
commit | a6dae5627aab2943b9c6dce0590ef5c07cedb3c4 (patch) | |
tree | ce986eb8caf0b08031660783ecd266953f57cf01 | |
parent | 80c8ba2869ae7a2e8ebbac5acbf4ac07fe18792d (diff) |
Notes
-rw-r--r-- | sys/dev/usb/controller/ehci_imx.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/sys/dev/usb/controller/ehci_imx.c b/sys/dev/usb/controller/ehci_imx.c index 20d040845243..3fa466357b24 100644 --- a/sys/dev/usb/controller/ehci_imx.c +++ b/sys/dev/usb/controller/ehci_imx.c @@ -268,7 +268,6 @@ struct imx_ehci_softc { device_t dev; struct resource *ehci_mem_res; /* EHCI core regs. */ struct resource *ehci_irq_res; /* EHCI core IRQ. */ - bool usb_mem_allocated; }; static struct ofw_compat_data compat_data[] = { @@ -313,13 +312,16 @@ imx_ehci_detach(device_t dev) { struct imx_ehci_softc *sc; ehci_softc_t *esc; + int err; sc = device_get_softc(dev); esc = &sc->ehci_softc; - if (esc->sc_bus.bdev != NULL) - device_delete_child(dev, esc->sc_bus.bdev); + /* First detach all children; we can't detach if that fails. */ + if ((err = device_delete_children(dev)) != 0) + return (err); + if (esc->sc_flags & EHCI_SCFLG_DONEINIT) ehci_detach(esc); if (esc->sc_intr_hdl != NULL) @@ -332,11 +334,7 @@ imx_ehci_detach(device_t dev) bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->ehci_mem_res); - if (sc->usb_mem_allocated) - usb_bus_mem_free_all(&esc->sc_bus, &ehci_iterate_hw_softc); - - /* During module unload there are lots of children leftover */ - device_delete_children(dev); + usb_bus_mem_free_all(&esc->sc_bus, &ehci_iterate_hw_softc); return (0); } @@ -415,7 +413,6 @@ imx_ehci_attach(device_t dev) err = ENOMEM; goto out; } - sc->usb_mem_allocated = true; /* * Set handle to USB related registers subregion used by |