Author: ian
Date: Thu Jul  5 15:34:16 2018
New Revision: 335985
URL: https://svnweb.freebsd.org/changeset/base/335985

Log:
  Remove a test and early-out which just can't possibly be right.  It causes
  detach() to do nothing if attach() succeeded, which is the opposite of
  what's needed.  Also, move device_delete_children() from the end to the
  beginning of detach(), so that children won't be trying to make use of the
  hardware we're in the process of shutting down.
  
  PR:           229510

Modified:
  head/sys/arm/freescale/vybrid/vf_ehci.c

Modified: head/sys/arm/freescale/vybrid/vf_ehci.c
==============================================================================
--- head/sys/arm/freescale/vybrid/vf_ehci.c     Thu Jul  5 15:27:38 2018        
(r335984)
+++ head/sys/arm/freescale/vybrid/vf_ehci.c     Thu Jul  5 15:34:16 2018        
(r335985)
@@ -390,8 +390,9 @@ vybrid_ehci_detach(device_t dev)
        esc = device_get_softc(dev);
        sc = &esc->base;
 
-       if (sc->sc_flags & EHCI_SCFLG_DONEINIT)
-               return (0);
+       /* First detach all children; we can't detach if that fails. */
+       if ((err = device_delete_children(dev)) != 0)
+               return (err);
 
        /*
         * only call ehci_detach() after ehci_init()
@@ -419,14 +420,6 @@ vybrid_ehci_detach(device_t dev)
                }
                sc->sc_intr_hdl = NULL;
        }
-
-       if (sc->sc_bus.bdev) {
-               device_delete_child(dev, sc->sc_bus.bdev);
-               sc->sc_bus.bdev = NULL;
-       }
-
-       /* During module unload there are lots of children leftover */
-       device_delete_children(dev);
 
        bus_release_resources(dev, vybrid_ehci_spec, esc->res);
 
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to