diff options
author | Linus Torvalds <torvalds@woody.osdl.org> | 2007-01-06 03:10:55 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2007-01-06 03:10:55 -0500 |
commit | d0abc451a685a8d8a5b05db660b06199786981b1 (patch) | |
tree | a9ce623b45dc70524475e8c76082fc52e7f82b24 | |
parent | 4497fe1e88cdee984925c2b477e5c73379e00620 (diff) | |
parent | 7f422e2e84307bdd9b51c19a602e1601d160aebc (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6:
[PATCH] Driver core: Fix prefix driver links in /sys/module by bus-name
-rw-r--r-- | kernel/module.c | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/kernel/module.c b/kernel/module.c index dbce132b354c..d0f2260a0210 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -1148,10 +1148,10 @@ static int mod_sysfs_setup(struct module *mod, | |||
1148 | kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD); | 1148 | kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD); |
1149 | return 0; | 1149 | return 0; |
1150 | 1150 | ||
1151 | out_unreg_drivers: | ||
1152 | kobject_unregister(mod->drivers_dir); | ||
1153 | out_unreg_param: | 1151 | out_unreg_param: |
1154 | module_param_sysfs_remove(mod); | 1152 | module_param_sysfs_remove(mod); |
1153 | out_unreg_drivers: | ||
1154 | kobject_unregister(mod->drivers_dir); | ||
1155 | out_unreg: | 1155 | out_unreg: |
1156 | kobject_del(&mod->mkobj.kobj); | 1156 | kobject_del(&mod->mkobj.kobj); |
1157 | kobject_put(&mod->mkobj.kobj); | 1157 | kobject_put(&mod->mkobj.kobj); |
@@ -2327,8 +2327,22 @@ void print_modules(void) | |||
2327 | printk("\n"); | 2327 | printk("\n"); |
2328 | } | 2328 | } |
2329 | 2329 | ||
2330 | static char *make_driver_name(struct device_driver *drv) | ||
2331 | { | ||
2332 | char *driver_name; | ||
2333 | |||
2334 | driver_name = kmalloc(strlen(drv->name) + strlen(drv->bus->name) + 2, | ||
2335 | GFP_KERNEL); | ||
2336 | if (!driver_name) | ||
2337 | return NULL; | ||
2338 | |||
2339 | sprintf(driver_name, "%s:%s", drv->bus->name, drv->name); | ||
2340 | return driver_name; | ||
2341 | } | ||
2342 | |||
2330 | void module_add_driver(struct module *mod, struct device_driver *drv) | 2343 | void module_add_driver(struct module *mod, struct device_driver *drv) |
2331 | { | 2344 | { |
2345 | char *driver_name; | ||
2332 | int no_warn; | 2346 | int no_warn; |
2333 | 2347 | ||
2334 | if (!mod || !drv) | 2348 | if (!mod || !drv) |
@@ -2336,17 +2350,31 @@ void module_add_driver(struct module *mod, struct device_driver *drv) | |||
2336 | 2350 | ||
2337 | /* Don't check return codes; these calls are idempotent */ | 2351 | /* Don't check return codes; these calls are idempotent */ |
2338 | no_warn = sysfs_create_link(&drv->kobj, &mod->mkobj.kobj, "module"); | 2352 | no_warn = sysfs_create_link(&drv->kobj, &mod->mkobj.kobj, "module"); |
2339 | no_warn = sysfs_create_link(mod->drivers_dir, &drv->kobj, drv->name); | 2353 | driver_name = make_driver_name(drv); |
2354 | if (driver_name) { | ||
2355 | no_warn = sysfs_create_link(mod->drivers_dir, &drv->kobj, | ||
2356 | driver_name); | ||
2357 | kfree(driver_name); | ||
2358 | } | ||
2340 | } | 2359 | } |
2341 | EXPORT_SYMBOL(module_add_driver); | 2360 | EXPORT_SYMBOL(module_add_driver); |
2342 | 2361 | ||
2343 | void module_remove_driver(struct device_driver *drv) | 2362 | void module_remove_driver(struct device_driver *drv) |
2344 | { | 2363 | { |
2364 | char *driver_name; | ||
2365 | |||
2345 | if (!drv) | 2366 | if (!drv) |
2346 | return; | 2367 | return; |
2368 | |||
2347 | sysfs_remove_link(&drv->kobj, "module"); | 2369 | sysfs_remove_link(&drv->kobj, "module"); |
2348 | if (drv->owner && drv->owner->drivers_dir) | 2370 | if (drv->owner && drv->owner->drivers_dir) { |
2349 | sysfs_remove_link(drv->owner->drivers_dir, drv->name); | 2371 | driver_name = make_driver_name(drv); |
2372 | if (driver_name) { | ||
2373 | sysfs_remove_link(drv->owner->drivers_dir, | ||
2374 | driver_name); | ||
2375 | kfree(driver_name); | ||
2376 | } | ||
2377 | } | ||
2350 | } | 2378 | } |
2351 | EXPORT_SYMBOL(module_remove_driver); | 2379 | EXPORT_SYMBOL(module_remove_driver); |
2352 | 2380 | ||