diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2006-11-24 06:15:25 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-12-01 17:52:02 -0500 |
commit | e17e0f51aeea4e59c7e450a1c0f26605b91c1260 (patch) | |
tree | eb177cbfe18d433ab115222bfe53f1098de844c2 /kernel | |
parent | c957b32406b73ed66d0f20ebab0cab25c848105d (diff) |
Driver core: show drivers in /sys/module/
Show the drivers, which belong to the module:
$ ls -l /sys/module/usbcore/drivers/
hub -> ../../../bus/usb/drivers/hub
usb -> ../../../bus/usb/drivers/usb
usbfs -> ../../../bus/usb/drivers/usbfs
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/module.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/kernel/module.c b/kernel/module.c index f0166563c602..45e01cb60101 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -1086,22 +1086,35 @@ static int mod_sysfs_setup(struct module *mod, | |||
1086 | goto out; | 1086 | goto out; |
1087 | kobj_set_kset_s(&mod->mkobj, module_subsys); | 1087 | kobj_set_kset_s(&mod->mkobj, module_subsys); |
1088 | mod->mkobj.mod = mod; | 1088 | mod->mkobj.mod = mod; |
1089 | err = kobject_register(&mod->mkobj.kobj); | 1089 | |
1090 | /* delay uevent until full sysfs population */ | ||
1091 | kobject_init(&mod->mkobj.kobj); | ||
1092 | err = kobject_add(&mod->mkobj.kobj); | ||
1090 | if (err) | 1093 | if (err) |
1091 | goto out; | 1094 | goto out; |
1092 | 1095 | ||
1096 | mod->drivers_dir = kobject_add_dir(&mod->mkobj.kobj, "drivers"); | ||
1097 | if (!mod->drivers_dir) | ||
1098 | goto out_unreg; | ||
1099 | |||
1093 | err = module_param_sysfs_setup(mod, kparam, num_params); | 1100 | err = module_param_sysfs_setup(mod, kparam, num_params); |
1094 | if (err) | 1101 | if (err) |
1095 | goto out_unreg; | 1102 | goto out_unreg_drivers; |
1096 | 1103 | ||
1097 | err = module_add_modinfo_attrs(mod); | 1104 | err = module_add_modinfo_attrs(mod); |
1098 | if (err) | 1105 | if (err) |
1099 | goto out_unreg; | 1106 | goto out_unreg_param; |
1100 | 1107 | ||
1108 | kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD); | ||
1101 | return 0; | 1109 | return 0; |
1102 | 1110 | ||
1111 | out_unreg_drivers: | ||
1112 | kobject_unregister(mod->drivers_dir); | ||
1113 | out_unreg_param: | ||
1114 | module_param_sysfs_remove(mod); | ||
1103 | out_unreg: | 1115 | out_unreg: |
1104 | kobject_unregister(&mod->mkobj.kobj); | 1116 | kobject_del(&mod->mkobj.kobj); |
1117 | kobject_put(&mod->mkobj.kobj); | ||
1105 | out: | 1118 | out: |
1106 | return err; | 1119 | return err; |
1107 | } | 1120 | } |
@@ -1110,6 +1123,7 @@ static void mod_kobject_remove(struct module *mod) | |||
1110 | { | 1123 | { |
1111 | module_remove_modinfo_attrs(mod); | 1124 | module_remove_modinfo_attrs(mod); |
1112 | module_param_sysfs_remove(mod); | 1125 | module_param_sysfs_remove(mod); |
1126 | kobject_unregister(mod->drivers_dir); | ||
1113 | 1127 | ||
1114 | kobject_unregister(&mod->mkobj.kobj); | 1128 | kobject_unregister(&mod->mkobj.kobj); |
1115 | } | 1129 | } |
@@ -2275,11 +2289,14 @@ void print_modules(void) | |||
2275 | 2289 | ||
2276 | void module_add_driver(struct module *mod, struct device_driver *drv) | 2290 | void module_add_driver(struct module *mod, struct device_driver *drv) |
2277 | { | 2291 | { |
2292 | int no_warn; | ||
2293 | |||
2278 | if (!mod || !drv) | 2294 | if (!mod || !drv) |
2279 | return; | 2295 | return; |
2280 | 2296 | ||
2281 | /* Don't check return code; this call is idempotent */ | 2297 | /* Don't check return codes; these calls are idempotent */ |
2282 | sysfs_create_link(&drv->kobj, &mod->mkobj.kobj, "module"); | 2298 | no_warn = sysfs_create_link(&drv->kobj, &mod->mkobj.kobj, "module"); |
2299 | no_warn = sysfs_create_link(mod->drivers_dir, &drv->kobj, drv->name); | ||
2283 | } | 2300 | } |
2284 | EXPORT_SYMBOL(module_add_driver); | 2301 | EXPORT_SYMBOL(module_add_driver); |
2285 | 2302 | ||
@@ -2288,6 +2305,8 @@ void module_remove_driver(struct device_driver *drv) | |||
2288 | if (!drv) | 2305 | if (!drv) |
2289 | return; | 2306 | return; |
2290 | sysfs_remove_link(&drv->kobj, "module"); | 2307 | sysfs_remove_link(&drv->kobj, "module"); |
2308 | if (drv->owner && drv->owner->drivers_dir) | ||
2309 | sysfs_remove_link(drv->owner->drivers_dir, drv->name); | ||
2291 | } | 2310 | } |
2292 | EXPORT_SYMBOL(module_remove_driver); | 2311 | EXPORT_SYMBOL(module_remove_driver); |
2293 | 2312 | ||