diff --git a/sys/arm/xilinx/zy7_ehci.c b/sys/arm/xilinx/zy7_ehci.c index f6e34f774491..0b7a3ffd22e9 100644 --- a/sys/arm/xilinx/zy7_ehci.c +++ b/sys/arm/xilinx/zy7_ehci.c @@ -325,13 +325,10 @@ zy7_ehci_detach(device_t dev) /* during module unload there are lots of children leftover */ device_delete_children(dev); - sc->sc_flags &= ~EHCI_SCFLG_DONEINIT; - - if (sc->sc_irq_res && sc->sc_intr_hdl) - /* call ehci_detach() after ehci_init() called after - * successful bus_setup_intr(). - */ + if ((sc->sc_flags & EHCI_SCFLG_DONEINIT) != 0) { ehci_detach(sc); + sc->sc_flags &= ~EHCI_SCFLG_DONEINIT; + } if (sc->sc_irq_res) { if (sc->sc_intr_hdl != NULL)