aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2006-12-05 09:37:56 -0500
committerDavid Howells <dhowells@warthog.cambridge.redhat.com>2006-12-05 09:37:56 -0500
commit4c1ac1b49122b805adfa4efc620592f68dccf5db (patch)
tree87557f4bc2fd4fe65b7570489c2f610c45c0adcd /kernel/module.c
parentc4028958b6ecad064b1a6303a6a5906d4fe48d73 (diff)
parentd916faace3efc0bf19fe9a615a1ab8fa1a24cd93 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: drivers/infiniband/core/iwcm.c drivers/net/chelsio/cxgb2.c drivers/net/wireless/bcm43xx/bcm43xx_main.c drivers/net/wireless/prism54/islpci_eth.c drivers/usb/core/hub.h drivers/usb/input/hid-core.c net/core/netpoll.c Fix up merge failures with Linus's head and fix new compilation failures. Signed-Off-By: David Howells <dhowells@redhat.com>
Diffstat (limited to 'kernel/module.c')
-rw-r--r--kernel/module.c31
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
1111out_unreg_drivers:
1112 kobject_unregister(mod->drivers_dir);
1113out_unreg_param:
1114 module_param_sysfs_remove(mod);
1103out_unreg: 1115out_unreg:
1104 kobject_unregister(&mod->mkobj.kobj); 1116 kobject_del(&mod->mkobj.kobj);
1117 kobject_put(&mod->mkobj.kobj);
1105out: 1118out:
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
2276void module_add_driver(struct module *mod, struct device_driver *drv) 2290void 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}
2284EXPORT_SYMBOL(module_add_driver); 2301EXPORT_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}
2292EXPORT_SYMBOL(module_remove_driver); 2311EXPORT_SYMBOL(module_remove_driver);
2293 2312