Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=0c84ce268b69855919b6ac7edc8f11caf21e9c88
Commit:     0c84ce268b69855919b6ac7edc8f11caf21e9c88
Parent:     bcd9b89c02295b075fda4bdb666f6641f8212226
Author:     Kay Sievers <[EMAIL PROTECTED]>
AuthorDate: Sun Apr 1 23:49:48 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Mon Apr 2 10:06:09 2007 -0700

    [PATCH] driver core: fix built-in drivers sysfs links
    
    built-in drivers had broken sysfs links that caused bootup hangs for
    certain driver unregistry sequences.
    
    Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]>
    Acked-by: Kay Sievers <[EMAIL PROTECTED]>
    Signed-off-by: Greg KH <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 include/linux/device.h |    1 +
 kernel/module.c        |   18 ++++++++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/include/linux/device.h b/include/linux/device.h
index caad9bb..5cf30e9 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -128,6 +128,7 @@ struct device_driver {
 
        struct module           * owner;
        const char              * mod_name;     /* used for built-in modules */
+       struct module_kobject   * mkobj;
 
        int     (*probe)        (struct device * dev);
        int     (*remove)       (struct device * dev);
diff --git a/kernel/module.c b/kernel/module.c
index fbc51de..dcdb32b 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2384,8 +2384,13 @@ void module_add_driver(struct module *mod, struct 
device_driver *drv)
 
                /* Lookup built-in module entry in /sys/modules */
                mkobj = kset_find_obj(&module_subsys.kset, drv->mod_name);
-               if (mkobj)
+               if (mkobj) {
                        mk = container_of(mkobj, struct module_kobject, kobj);
+                       /* remember our module structure */
+                       drv->mkobj = mk;
+                       /* kset_find_obj took a reference */
+                       kobject_put(mkobj);
+               }
        }
 
        if (!mk)
@@ -2405,17 +2410,22 @@ EXPORT_SYMBOL(module_add_driver);
 
 void module_remove_driver(struct device_driver *drv)
 {
+       struct module_kobject *mk = NULL;
        char *driver_name;
 
        if (!drv)
                return;
 
        sysfs_remove_link(&drv->kobj, "module");
-       if (drv->owner && drv->owner->mkobj.drivers_dir) {
+
+       if (drv->owner)
+               mk = &drv->owner->mkobj;
+       else if (drv->mkobj)
+               mk = drv->mkobj;
+       if (mk && mk->drivers_dir) {
                driver_name = make_driver_name(drv);
                if (driver_name) {
-                       sysfs_remove_link(drv->owner->mkobj.drivers_dir,
-                                         driver_name);
+                       sysfs_remove_link(mk->drivers_dir, driver_name);
                        kfree(driver_name);
                }
        }
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to