summaryrefslogtreecommitdiffstats
path: root/drivers/edac/edac_device_sysfs.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2007-12-17 15:54:39 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-24 20:40:28 -0800
commitb2ed215a3338b8b16187be8d136153054118a41e (patch)
tree0abccda52f2c8356f35c857bcf2abbe7661b6e2d /drivers/edac/edac_device_sysfs.c
parent038c5b3e412b0b751cb4b1507506bad3c7ffefae (diff)
downloadop-kernel-dev-b2ed215a3338b8b16187be8d136153054118a41e.zip
op-kernel-dev-b2ed215a3338b8b16187be8d136153054118a41e.tar.gz
Kobject: change drivers/edac to use kobject_init_and_add
Stop using kobject_register, as this way we can control the sending of the uevent properly, after everything is properly initialized. Acked-by: Doug Thompson <dougthompson@xmission.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/edac/edac_device_sysfs.c')
-rw-r--r--drivers/edac/edac_device_sysfs.c39
1 files changed, 12 insertions, 27 deletions
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index 70b837f..10e5b19 100644
--- a/drivers/edac/edac_device_sysfs.c
+++ b/drivers/edac/edac_device_sysfs.c
@@ -246,16 +246,6 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
/* Init the devices's kobject */
memset(&edac_dev->kobj, 0, sizeof(struct kobject));
- edac_dev->kobj.ktype = &ktype_device_ctrl;
-
- /* set this new device under the edac_class kobject */
- edac_dev->kobj.parent = &edac_class->kset.kobj;
-
- /* generate sysfs "..../edac/<name>" */
- debugf4("%s() set name of kobject to: %s\n", __func__, edac_dev->name);
- err = kobject_set_name(&edac_dev->kobj, "%s", edac_dev->name);
- if (err)
- goto err_out;
/* Record which module 'owns' this control structure
* and bump the ref count of the module
@@ -268,12 +258,15 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
}
/* register */
- err = kobject_register(&edac_dev->kobj);
+ err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl,
+ &edac_class->kset.kobj,
+ "%s", edac_dev->name);
if (err) {
debugf1("%s()Failed to register '.../edac/%s'\n",
__func__, edac_dev->name);
goto err_kobj_reg;
}
+ kobject_uevent(&edac_dev->kobj, KOBJ_ADD);
/* At this point, to 'free' the control struct,
* edac_device_unregister_sysfs_main_kobj() must be used
@@ -533,12 +526,6 @@ static int edac_device_create_block(struct edac_device_ctl_info *edac_dev,
/* init this block's kobject */
memset(&block->kobj, 0, sizeof(struct kobject));
- block->kobj.parent = &instance->kobj;
- block->kobj.ktype = &ktype_block_ctrl;
-
- err = kobject_set_name(&block->kobj, "%s", block->name);
- if (err)
- return err;
/* bump the main kobject's reference count for this controller
* and this instance is dependant on the main
@@ -550,7 +537,9 @@ static int edac_device_create_block(struct edac_device_ctl_info *edac_dev,
}
/* Add this block's kobject */
- err = kobject_register(&block->kobj);
+ err = kobject_init_and_add(&block->kobj, &ktype_block_ctrl,
+ &instance->kobj,
+ "%s", block->name);
if (err) {
debugf1("%s() Failed to register instance '%s'\n",
__func__, block->name);
@@ -579,6 +568,7 @@ static int edac_device_create_block(struct edac_device_ctl_info *edac_dev,
goto err_on_attrib;
}
}
+ kobject_uevent(&block->kobj, KOBJ_ADD);
return 0;
@@ -637,15 +627,8 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev,
/* Init the instance's kobject */
memset(&instance->kobj, 0, sizeof(struct kobject));
- /* set this new device under the edac_device main kobject */
- instance->kobj.parent = &edac_dev->kobj;
- instance->kobj.ktype = &ktype_instance_ctrl;
instance->ctl = edac_dev;
- err = kobject_set_name(&instance->kobj, "%s", instance->name);
- if (err)
- goto err_out;
-
/* bump the main kobject's reference count for this controller
* and this instance is dependant on the main
*/
@@ -655,8 +638,9 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev,
goto err_out;
}
- /* Formally register this instance's kobject */
- err = kobject_register(&instance->kobj);
+ /* Formally register this instance's kobject under the edac_device */
+ err = kobject_init_and_add(&instance->kobj, &ktype_instance_ctrl,
+ &edac_dev->kobj, "%s", instance->name);
if (err != 0) {
debugf2("%s() Failed to register instance '%s'\n",
__func__, instance->name);
@@ -679,6 +663,7 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev,
goto err_release_instance_kobj;
}
}
+ kobject_uevent(&instance->kobj, KOBJ_ADD);
debugf4("%s() Registered instance %d '%s' kobject\n",
__func__, idx, instance->name);
OpenPOWER on IntegriCloud