提交 b2ed215a 编写于 作者: G Greg Kroah-Hartman

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: NDoug Thompson <dougthompson@xmission.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 038c5b3e
...@@ -246,16 +246,6 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) ...@@ -246,16 +246,6 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
/* Init the devices's kobject */ /* Init the devices's kobject */
memset(&edac_dev->kobj, 0, sizeof(struct 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 /* Record which module 'owns' this control structure
* and bump the ref count of the module * 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) ...@@ -268,12 +258,15 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
} }
/* register */ /* 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) { if (err) {
debugf1("%s()Failed to register '.../edac/%s'\n", debugf1("%s()Failed to register '.../edac/%s'\n",
__func__, edac_dev->name); __func__, edac_dev->name);
goto err_kobj_reg; goto err_kobj_reg;
} }
kobject_uevent(&edac_dev->kobj, KOBJ_ADD);
/* At this point, to 'free' the control struct, /* At this point, to 'free' the control struct,
* edac_device_unregister_sysfs_main_kobj() must be used * 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, ...@@ -533,12 +526,6 @@ static int edac_device_create_block(struct edac_device_ctl_info *edac_dev,
/* init this block's kobject */ /* init this block's kobject */
memset(&block->kobj, 0, sizeof(struct 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 /* bump the main kobject's reference count for this controller
* and this instance is dependant on the main * 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, ...@@ -550,7 +537,9 @@ static int edac_device_create_block(struct edac_device_ctl_info *edac_dev,
} }
/* Add this block's kobject */ /* 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) { if (err) {
debugf1("%s() Failed to register instance '%s'\n", debugf1("%s() Failed to register instance '%s'\n",
__func__, block->name); __func__, block->name);
...@@ -579,6 +568,7 @@ static int edac_device_create_block(struct edac_device_ctl_info *edac_dev, ...@@ -579,6 +568,7 @@ static int edac_device_create_block(struct edac_device_ctl_info *edac_dev,
goto err_on_attrib; goto err_on_attrib;
} }
} }
kobject_uevent(&block->kobj, KOBJ_ADD);
return 0; return 0;
...@@ -637,15 +627,8 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev, ...@@ -637,15 +627,8 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev,
/* Init the instance's kobject */ /* Init the instance's kobject */
memset(&instance->kobj, 0, sizeof(struct 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; 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 /* bump the main kobject's reference count for this controller
* and this instance is dependant on the main * 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, ...@@ -655,8 +638,9 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev,
goto err_out; goto err_out;
} }
/* Formally register this instance's kobject */ /* Formally register this instance's kobject under the edac_device */
err = kobject_register(&instance->kobj); err = kobject_init_and_add(&instance->kobj, &ktype_instance_ctrl,
&edac_dev->kobj, "%s", instance->name);
if (err != 0) { if (err != 0) {
debugf2("%s() Failed to register instance '%s'\n", debugf2("%s() Failed to register instance '%s'\n",
__func__, instance->name); __func__, instance->name);
...@@ -679,6 +663,7 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev, ...@@ -679,6 +663,7 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev,
goto err_release_instance_kobj; goto err_release_instance_kobj;
} }
} }
kobject_uevent(&instance->kobj, KOBJ_ADD);
debugf4("%s() Registered instance %d '%s' kobject\n", debugf4("%s() Registered instance %d '%s' kobject\n",
__func__, idx, instance->name); __func__, idx, instance->name);
......
...@@ -380,13 +380,6 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci, ...@@ -380,13 +380,6 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci,
/* generate ..../edac/mc/mc<id>/csrow<index> */ /* generate ..../edac/mc/mc<id>/csrow<index> */
memset(&csrow->kobj, 0, sizeof(csrow->kobj)); memset(&csrow->kobj, 0, sizeof(csrow->kobj));
csrow->mci = mci; /* include container up link */ csrow->mci = mci; /* include container up link */
csrow->kobj.parent = kobj_mci;
csrow->kobj.ktype = &ktype_csrow;
/* name this instance of csrow<id> */
err = kobject_set_name(&csrow->kobj, "csrow%d", index);
if (err)
goto err_out;
/* bump the mci instance's kobject's ref count */ /* bump the mci instance's kobject's ref count */
kobj = kobject_get(&mci->edac_mci_kobj); kobj = kobject_get(&mci->edac_mci_kobj);
...@@ -396,7 +389,8 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci, ...@@ -396,7 +389,8 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci,
} }
/* Instanstiate the csrow object */ /* Instanstiate the csrow object */
err = kobject_register(&csrow->kobj); err = kobject_init_and_add(&csrow->kobj, &ktype_csrow, kobj_mci,
"csrow%d", index);
if (err) if (err)
goto err_release_top_kobj; goto err_release_top_kobj;
...@@ -416,7 +410,7 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci, ...@@ -416,7 +410,7 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci,
goto err_out; goto err_out;
} }
} }
kobject_uevent(&csrow->kobj, KOBJ_ADD);
return 0; return 0;
/* error unwind stack */ /* error unwind stack */
...@@ -764,15 +758,6 @@ int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci) ...@@ -764,15 +758,6 @@ int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci)
/* Init the mci's kobject */ /* Init the mci's kobject */
memset(kobj_mci, 0, sizeof(*kobj_mci)); memset(kobj_mci, 0, sizeof(*kobj_mci));
/* this instance become part of the mc_kset */
kobj_mci->kset = &mc_kset;
kobj_mci->ktype = &ktype_mci;
/* set the name of the mc<id> object */
err = kobject_set_name(kobj_mci, "mc%d", mci->mc_idx);
if (err)
goto fail_out;
/* Record which module 'owns' this control structure /* Record which module 'owns' this control structure
* and bump the ref count of the module * and bump the ref count of the module
*/ */
...@@ -784,13 +769,18 @@ int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci) ...@@ -784,13 +769,18 @@ int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci)
goto fail_out; goto fail_out;
} }
/* this instance become part of the mc_kset */
kobj_mci->kset = &mc_kset;
/* register the mc<id> kobject to the mc_kset */ /* register the mc<id> kobject to the mc_kset */
err = kobject_register(kobj_mci); err = kobject_init_and_add(kobj_mci, &ktype_mci, NULL,
"mc%d", mci->mc_idx);
if (err) { if (err) {
debugf1("%s()Failed to register '.../edac/mc%d'\n", debugf1("%s()Failed to register '.../edac/mc%d'\n",
__func__, mci->mc_idx); __func__, mci->mc_idx);
goto kobj_reg_fail; goto kobj_reg_fail;
} }
kobject_uevent(kobj_mci, KOBJ_ADD);
/* At this point, to 'free' the control struct, /* At this point, to 'free' the control struct,
* edac_mc_unregister_sysfs_main_kobj() must be used * edac_mc_unregister_sysfs_main_kobj() must be used
......
...@@ -162,14 +162,6 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx) ...@@ -162,14 +162,6 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
debugf0("%s()\n", __func__); debugf0("%s()\n", __func__);
/* Set the parent and the instance's ktype */
pci->kobj.parent = &edac_pci_top_main_kobj;
pci->kobj.ktype = &ktype_pci_instance;
err = kobject_set_name(&pci->kobj, "pci%d", idx);
if (err)
return err;
/* First bump the ref count on the top main kobj, which will /* First bump the ref count on the top main kobj, which will
* track the number of PCI instances we have, and thus nest * track the number of PCI instances we have, and thus nest
* properly on keeping the module loaded * properly on keeping the module loaded
...@@ -181,7 +173,8 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx) ...@@ -181,7 +173,8 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
} }
/* And now register this new kobject under the main kobj */ /* And now register this new kobject under the main kobj */
err = kobject_register(&pci->kobj); err = kobject_init_and_add(&pci->kobj, &ktype_pci_instance,
&edac_pci_top_main_kobj, "pci%d", idx);
if (err != 0) { if (err != 0) {
debugf2("%s() failed to register instance pci%d\n", debugf2("%s() failed to register instance pci%d\n",
__func__, idx); __func__, idx);
...@@ -189,6 +182,7 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx) ...@@ -189,6 +182,7 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
goto error_out; goto error_out;
} }
kobject_uevent(&pci->kobj, KOBJ_ADD);
debugf1("%s() Register instance 'pci%d' kobject\n", __func__, idx); debugf1("%s() Register instance 'pci%d' kobject\n", __func__, idx);
return 0; return 0;
...@@ -364,14 +358,6 @@ int edac_pci_main_kobj_setup(void) ...@@ -364,14 +358,6 @@ int edac_pci_main_kobj_setup(void)
goto decrement_count_fail; goto decrement_count_fail;
} }
/* Need the kobject hook ups, and name setting */
edac_pci_top_main_kobj.ktype = &ktype_edac_pci_main_kobj;
edac_pci_top_main_kobj.parent = &edac_class->kset.kobj;
err = kobject_set_name(&edac_pci_top_main_kobj, "pci");
if (err)
goto decrement_count_fail;
/* Bump the reference count on this module to ensure the /* Bump the reference count on this module to ensure the
* modules isn't unloaded until we deconstruct the top * modules isn't unloaded until we deconstruct the top
* level main kobj for EDAC PCI * level main kobj for EDAC PCI
...@@ -383,23 +369,24 @@ int edac_pci_main_kobj_setup(void) ...@@ -383,23 +369,24 @@ int edac_pci_main_kobj_setup(void)
} }
/* Instanstiate the pci object */ /* Instanstiate the pci object */
/* FIXME: maybe new sysdev_create_subdir() */ err = kobject_init_and_add(&edac_pci_top_main_kobj, &ktype_edac_pci_main_kobj,
err = kobject_register(&edac_pci_top_main_kobj); &edac_class->kset.kobj, "pci");
if (err) { if (err) {
debugf1("Failed to register '.../edac/pci'\n"); debugf1("Failed to register '.../edac/pci'\n");
goto kobject_register_fail; goto kobject_init_and_add_fail;
} }
/* At this point, to 'release' the top level kobject /* At this point, to 'release' the top level kobject
* for EDAC PCI, then edac_pci_main_kobj_teardown() * for EDAC PCI, then edac_pci_main_kobj_teardown()
* must be used, for resources to be cleaned up properly * must be used, for resources to be cleaned up properly
*/ */
kobject_uevent(&edac_pci_top_main_kobj, KOBJ_ADD);
debugf1("Registered '.../edac/pci' kobject\n"); debugf1("Registered '.../edac/pci' kobject\n");
return 0; return 0;
/* Error unwind statck */ /* Error unwind statck */
kobject_register_fail: kobject_init_and_add_fail:
module_put(THIS_MODULE); module_put(THIS_MODULE);
decrement_count_fail: decrement_count_fail:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册