aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2007-01-15 14:50:02 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2007-02-07 13:37:12 -0500
commitfe480a2675ed236af396597d9f05245c7bbd0149 (patch)
tree1320b12250fd7ff8b642cc205587c7d0cbf6d9bb /kernel
parentf30c53a873d0d227493197064b8886af2d57bbd6 (diff)
Modules: only add drivers/ direcory if needed
This changes the module core to only create the drivers/ directory if we are going to put something in it. Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/module.c20
-rw-r--r--kernel/params.c1
2 files changed, 11 insertions, 10 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 0f4489af3e29..9de4209f6a67 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1131,12 +1131,6 @@ static int mod_sysfs_setup(struct module *mod,
1131 if (err) 1131 if (err)
1132 goto out; 1132 goto out;
1133 1133
1134 mod->mkobj.drivers_dir = kobject_add_dir(&mod->mkobj.kobj, "drivers");
1135 if (!mod->mkobj.drivers_dir) {
1136 err = -ENOMEM;
1137 goto out_unreg;
1138 }
1139
1140 err = module_param_sysfs_setup(mod, kparam, num_params); 1134 err = module_param_sysfs_setup(mod, kparam, num_params);
1141 if (err) 1135 if (err)
1142 goto out_unreg_drivers; 1136 goto out_unreg_drivers;
@@ -1151,8 +1145,6 @@ static int mod_sysfs_setup(struct module *mod,
1151out_unreg_param: 1145out_unreg_param:
1152 module_param_sysfs_remove(mod); 1146 module_param_sysfs_remove(mod);
1153out_unreg_drivers: 1147out_unreg_drivers:
1154 kobject_unregister(mod->mkobj.drivers_dir);
1155out_unreg:
1156 kobject_del(&mod->mkobj.kobj); 1148 kobject_del(&mod->mkobj.kobj);
1157 kobject_put(&mod->mkobj.kobj); 1149 kobject_put(&mod->mkobj.kobj);
1158out: 1150out:
@@ -1163,7 +1155,8 @@ static void mod_kobject_remove(struct module *mod)
1163{ 1155{
1164 module_remove_modinfo_attrs(mod); 1156 module_remove_modinfo_attrs(mod);
1165 module_param_sysfs_remove(mod); 1157 module_param_sysfs_remove(mod);
1166 kobject_unregister(mod->mkobj.drivers_dir); 1158 if (mod->mkobj.drivers_dir)
1159 kobject_unregister(mod->mkobj.drivers_dir);
1167 1160
1168 kobject_unregister(&mod->mkobj.kobj); 1161 kobject_unregister(&mod->mkobj.kobj);
1169} 1162}
@@ -2340,6 +2333,14 @@ static char *make_driver_name(struct device_driver *drv)
2340 return driver_name; 2333 return driver_name;
2341} 2334}
2342 2335
2336static void module_create_drivers_dir(struct module_kobject *mk)
2337{
2338 if (!mk || mk->drivers_dir)
2339 return;
2340
2341 mk->drivers_dir = kobject_add_dir(&mk->kobj, "drivers");
2342}
2343
2343void module_add_driver(struct module *mod, struct device_driver *drv) 2344void module_add_driver(struct module *mod, struct device_driver *drv)
2344{ 2345{
2345 char *driver_name; 2346 char *driver_name;
@@ -2367,6 +2368,7 @@ void module_add_driver(struct module *mod, struct device_driver *drv)
2367 no_warn = sysfs_create_link(&drv->kobj, &mk->kobj, "module"); 2368 no_warn = sysfs_create_link(&drv->kobj, &mk->kobj, "module");
2368 driver_name = make_driver_name(drv); 2369 driver_name = make_driver_name(drv);
2369 if (driver_name) { 2370 if (driver_name) {
2371 module_create_drivers_dir(mk);
2370 no_warn = sysfs_create_link(mk->drivers_dir, &drv->kobj, 2372 no_warn = sysfs_create_link(mk->drivers_dir, &drv->kobj,
2371 driver_name); 2373 driver_name);
2372 kfree(driver_name); 2374 kfree(driver_name);
diff --git a/kernel/params.c b/kernel/params.c
index 737b7c5e93aa..cbaac85942d5 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -565,7 +565,6 @@ static void __init kernel_param_sysfs_setup(const char *name,
565 ret = kobject_add(&mk->kobj); 565 ret = kobject_add(&mk->kobj);
566 BUG_ON(ret < 0); 566 BUG_ON(ret < 0);
567 param_sysfs_setup(mk, kparam, num_params, name_skip); 567 param_sysfs_setup(mk, kparam, num_params, name_skip);
568 mk->drivers_dir = kobject_add_dir(&mk->kobj, "drivers");
569 kobject_uevent(&mk->kobj, KOBJ_ADD); 568 kobject_uevent(&mk->kobj, KOBJ_ADD);
570} 569}
571 570