diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-04-02 02:49:48 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-04-02 13:06:09 -0400 |
commit | 0c84ce268b69855919b6ac7edc8f11caf21e9c88 (patch) | |
tree | 64e1fca7d80026db60ed4dde751d553193587034 /kernel/module.c | |
parent | bcd9b89c02295b075fda4bdb666f6641f8212226 (diff) |
[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 <mingo@elte.hu>
Acked-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/kernel/module.c b/kernel/module.c index fbc51de6444e..dcdb32b8b13c 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -2384,8 +2384,13 @@ void module_add_driver(struct module *mod, struct device_driver *drv) | |||
2384 | 2384 | ||
2385 | /* Lookup built-in module entry in /sys/modules */ | 2385 | /* Lookup built-in module entry in /sys/modules */ |
2386 | mkobj = kset_find_obj(&module_subsys.kset, drv->mod_name); | 2386 | mkobj = kset_find_obj(&module_subsys.kset, drv->mod_name); |
2387 | if (mkobj) | 2387 | if (mkobj) { |
2388 | mk = container_of(mkobj, struct module_kobject, kobj); | 2388 | mk = container_of(mkobj, struct module_kobject, kobj); |
2389 | /* remember our module structure */ | ||
2390 | drv->mkobj = mk; | ||
2391 | /* kset_find_obj took a reference */ | ||
2392 | kobject_put(mkobj); | ||
2393 | } | ||
2389 | } | 2394 | } |
2390 | 2395 | ||
2391 | if (!mk) | 2396 | if (!mk) |
@@ -2405,17 +2410,22 @@ EXPORT_SYMBOL(module_add_driver); | |||
2405 | 2410 | ||
2406 | void module_remove_driver(struct device_driver *drv) | 2411 | void module_remove_driver(struct device_driver *drv) |
2407 | { | 2412 | { |
2413 | struct module_kobject *mk = NULL; | ||
2408 | char *driver_name; | 2414 | char *driver_name; |
2409 | 2415 | ||
2410 | if (!drv) | 2416 | if (!drv) |
2411 | return; | 2417 | return; |
2412 | 2418 | ||
2413 | sysfs_remove_link(&drv->kobj, "module"); | 2419 | sysfs_remove_link(&drv->kobj, "module"); |
2414 | if (drv->owner && drv->owner->mkobj.drivers_dir) { | 2420 | |
2421 | if (drv->owner) | ||
2422 | mk = &drv->owner->mkobj; | ||
2423 | else if (drv->mkobj) | ||
2424 | mk = drv->mkobj; | ||
2425 | if (mk && mk->drivers_dir) { | ||
2415 | driver_name = make_driver_name(drv); | 2426 | driver_name = make_driver_name(drv); |
2416 | if (driver_name) { | 2427 | if (driver_name) { |
2417 | sysfs_remove_link(drv->owner->mkobj.drivers_dir, | 2428 | sysfs_remove_link(mk->drivers_dir, driver_name); |
2418 | driver_name); | ||
2419 | kfree(driver_name); | 2429 | kfree(driver_name); |
2420 | } | 2430 | } |
2421 | } | 2431 | } |