Detach all children before beginning to tear down the hardware, instead of
doing it last. Also, remove the local tracking of whether usb's busdma memory allocation got done, because it's safe to call the free_all function even if it wasn't.
This commit is contained in:
parent
8dceda29e8
commit
00c8d880f9
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user