if (err)
goto out;
- mod->mkobj.drivers_dir = kobject_add_dir(&mod->mkobj.kobj, "drivers");
- if (!mod->mkobj.drivers_dir) {
- err = -ENOMEM;
- goto out_unreg;
- }
-
err = module_param_sysfs_setup(mod, kparam, num_params);
if (err)
goto out_unreg_drivers;
out_unreg_param:
module_param_sysfs_remove(mod);
out_unreg_drivers:
- kobject_unregister(mod->mkobj.drivers_dir);
-out_unreg:
kobject_del(&mod->mkobj.kobj);
kobject_put(&mod->mkobj.kobj);
out:
{
module_remove_modinfo_attrs(mod);
module_param_sysfs_remove(mod);
- kobject_unregister(mod->mkobj.drivers_dir);
+ if (mod->mkobj.drivers_dir)
+ kobject_unregister(mod->mkobj.drivers_dir);
kobject_unregister(&mod->mkobj.kobj);
}
return driver_name;
}
+static void module_create_drivers_dir(struct module_kobject *mk)
+{
+ if (!mk || mk->drivers_dir)
+ return;
+
+ mk->drivers_dir = kobject_add_dir(&mk->kobj, "drivers");
+}
+
void module_add_driver(struct module *mod, struct device_driver *drv)
{
char *driver_name;
no_warn = sysfs_create_link(&drv->kobj, &mk->kobj, "module");
driver_name = make_driver_name(drv);
if (driver_name) {
+ module_create_drivers_dir(mk);
no_warn = sysfs_create_link(mk->drivers_dir, &drv->kobj,
driver_name);
kfree(driver_name);
ret = kobject_add(&mk->kobj);
BUG_ON(ret < 0);
param_sysfs_setup(mk, kparam, num_params, name_skip);
- mk->drivers_dir = kobject_add_dir(&mk->kobj, "drivers");
kobject_uevent(&mk->kobj, KOBJ_ADD);
}