aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2007-01-15 14:22:02 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2007-02-07 13:37:12 -0500
commitf30c53a873d0d227493197064b8886af2d57bbd6 (patch)
treecd051f14effbbb015a1bae6fe5bfabcf14037f13 /kernel/module.c
parentc744aeae9d173a953b771a7ad5c872f91fa99dec (diff)
MODULES: add the module name for built in kernel drivers
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'kernel/module.c')
-rw-r--r--kernel/module.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/kernel/module.c b/kernel/module.c
index d0f2260a0210..0f4489af3e29 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1131,8 +1131,8 @@ static int mod_sysfs_setup(struct module *mod,
1131 if (err) 1131 if (err)
1132 goto out; 1132 goto out;
1133 1133
1134 mod->drivers_dir = kobject_add_dir(&mod->mkobj.kobj, "drivers"); 1134 mod->mkobj.drivers_dir = kobject_add_dir(&mod->mkobj.kobj, "drivers");
1135 if (!mod->drivers_dir) { 1135 if (!mod->mkobj.drivers_dir) {
1136 err = -ENOMEM; 1136 err = -ENOMEM;
1137 goto out_unreg; 1137 goto out_unreg;
1138 } 1138 }
@@ -1151,7 +1151,7 @@ static int mod_sysfs_setup(struct module *mod,
1151out_unreg_param: 1151out_unreg_param:
1152 module_param_sysfs_remove(mod); 1152 module_param_sysfs_remove(mod);
1153out_unreg_drivers: 1153out_unreg_drivers:
1154 kobject_unregister(mod->drivers_dir); 1154 kobject_unregister(mod->mkobj.drivers_dir);
1155out_unreg: 1155out_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);
@@ -1163,7 +1163,7 @@ static void mod_kobject_remove(struct module *mod)
1163{ 1163{
1164 module_remove_modinfo_attrs(mod); 1164 module_remove_modinfo_attrs(mod);
1165 module_param_sysfs_remove(mod); 1165 module_param_sysfs_remove(mod);
1166 kobject_unregister(mod->drivers_dir); 1166 kobject_unregister(mod->mkobj.drivers_dir);
1167 1167
1168 kobject_unregister(&mod->mkobj.kobj); 1168 kobject_unregister(&mod->mkobj.kobj);
1169} 1169}
@@ -2344,15 +2344,30 @@ void module_add_driver(struct module *mod, struct device_driver *drv)
2344{ 2344{
2345 char *driver_name; 2345 char *driver_name;
2346 int no_warn; 2346 int no_warn;
2347 struct module_kobject *mk = NULL;
2347 2348
2348 if (!mod || !drv) 2349 if (!drv)
2350 return;
2351
2352 if (mod)
2353 mk = &mod->mkobj;
2354 else if (drv->mod_name) {
2355 struct kobject *mkobj;
2356
2357 /* Lookup built-in module entry in /sys/modules */
2358 mkobj = kset_find_obj(&module_subsys.kset, drv->mod_name);
2359 if (mkobj)
2360 mk = container_of(mkobj, struct module_kobject, kobj);
2361 }
2362
2363 if (!mk)
2349 return; 2364 return;
2350 2365
2351 /* Don't check return codes; these calls are idempotent */ 2366 /* Don't check return codes; these calls are idempotent */
2352 no_warn = sysfs_create_link(&drv->kobj, &mod->mkobj.kobj, "module"); 2367 no_warn = sysfs_create_link(&drv->kobj, &mk->kobj, "module");
2353 driver_name = make_driver_name(drv); 2368 driver_name = make_driver_name(drv);
2354 if (driver_name) { 2369 if (driver_name) {
2355 no_warn = sysfs_create_link(mod->drivers_dir, &drv->kobj, 2370 no_warn = sysfs_create_link(mk->drivers_dir, &drv->kobj,
2356 driver_name); 2371 driver_name);
2357 kfree(driver_name); 2372 kfree(driver_name);
2358 } 2373 }
@@ -2367,10 +2382,10 @@ void module_remove_driver(struct device_driver *drv)
2367 return; 2382 return;
2368 2383
2369 sysfs_remove_link(&drv->kobj, "module"); 2384 sysfs_remove_link(&drv->kobj, "module");
2370 if (drv->owner && drv->owner->drivers_dir) { 2385 if (drv->owner && drv->owner->mkobj.drivers_dir) {
2371 driver_name = make_driver_name(drv); 2386 driver_name = make_driver_name(drv);
2372 if (driver_name) { 2387 if (driver_name) {
2373 sysfs_remove_link(drv->owner->drivers_dir, 2388 sysfs_remove_link(drv->owner->mkobj.drivers_dir,
2374 driver_name); 2389 driver_name);
2375 kfree(driver_name); 2390 kfree(driver_name);
2376 } 2391 }