On Friday 19 November 2010 02:43 pm, Attilio Rao wrote:
> Author: attilio
> Date: Fri Nov 19 19:43:56 2010
> New Revision: 215544
> URL: http://svn.freebsd.org/changeset/base/215544
>
> Log:
>   Scan the list in reverse order for the shutdown handlers of
> loaded modules. This way, when there is a dependency between two
> modules, the handler of the latter probed runs first.
>
>   This is a similar approach as the modules are unloaded in the
> same linkerfile.
>
>   Sponsored by:       Sandvine Incorporated
>   Submitted by:       Nima Misaghian <nmisaghian at sandvine dot com>
>   MFC after:  1 week

Hmm...  It is not directly related but I was thinking about doing 
similar things for sys/kern/subr_bus.c.  What do you think about the 
attached patch?

Jung-uk Kim
Index: sys/kern/subr_bus.c
===================================================================
--- sys/kern/subr_bus.c (revision 215542)
+++ sys/kern/subr_bus.c (working copy)
@@ -1847,7 +1847,7 @@ device_delete_child(device_t dev, device_t child)
        PDEBUG(("%s from %s", DEVICENAME(child), DEVICENAME(dev)));
 
        /* remove children first */
-       while ( (grandchild = TAILQ_FIRST(&child->children)) ) {
+       while ( (grandchild = TAILQ_LAST(&child->children, device_list)) ) {
                error = device_delete_child(child, grandchild);
                if (error)
                        return (error);
@@ -3381,7 +3381,7 @@ bus_generic_detach(device_t dev)
        if (dev->state != DS_ATTACHED)
                return (EBUSY);
 
-       TAILQ_FOREACH(child, &dev->children, link) {
+       TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) {
                if ((error = device_detach(child)) != 0)
                        return (error);
        }
@@ -3401,7 +3401,7 @@ bus_generic_shutdown(device_t dev)
 {
        device_t child;
 
-       TAILQ_FOREACH(child, &dev->children, link) {
+       TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) {
                device_shutdown(child);
        }
 
@@ -3423,7 +3423,7 @@ bus_generic_suspend(device_t dev)
        int             error;
        device_t        child, child2;
 
-       TAILQ_FOREACH(child, &dev->children, link) {
+       TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) {
                error = DEVICE_SUSPEND(child);
                if (error) {
                        for (child2 = TAILQ_FIRST(&dev->children);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to