diff options
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 20 |
1 files changed, 11 insertions, 9 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, | |||
1151 | out_unreg_param: | 1145 | out_unreg_param: |
1152 | module_param_sysfs_remove(mod); | 1146 | module_param_sysfs_remove(mod); |
1153 | out_unreg_drivers: | 1147 | out_unreg_drivers: |
1154 | kobject_unregister(mod->mkobj.drivers_dir); | ||
1155 | out_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); |
1158 | out: | 1150 | out: |
@@ -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 | ||
2336 | static 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 | |||
2343 | void module_add_driver(struct module *mod, struct device_driver *drv) | 2344 | void 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); |