diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2007-12-17 14:54:39 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-01-24 23:40:28 -0500 |
commit | b2ed215a3338b8b16187be8d136153054118a41e (patch) | |
tree | 0abccda52f2c8356f35c857bcf2abbe7661b6e2d /drivers/edac/edac_device_sysfs.c | |
parent | 038c5b3e412b0b751cb4b1507506bad3c7ffefae (diff) |
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.c | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c index 70b837f23c43..10e5b19a3e3b 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) | |||
246 | 246 | ||
247 | /* Init the devices's kobject */ | 247 | /* Init the devices's kobject */ |
248 | memset(&edac_dev->kobj, 0, sizeof(struct kobject)); | 248 | memset(&edac_dev->kobj, 0, sizeof(struct kobject)); |
249 | edac_dev->kobj.ktype = &ktype_device_ctrl; | ||
250 | |||
251 | /* set this new device under the edac_class kobject */ | ||
252 | edac_dev->kobj.parent = &edac_class->kset.kobj; | ||
253 | |||
254 | /* generate sysfs "..../edac/<name>" */ | ||
255 | debugf4("%s() set name of kobject to: %s\n", __func__, edac_dev->name); | ||
256 | err = kobject_set_name(&edac_dev->kobj, "%s", edac_dev->name); | ||
257 | if (err) | ||
258 | goto err_out; | ||
259 | 249 | ||
260 | /* Record which module 'owns' this control structure | 250 | /* Record which module 'owns' this control structure |
261 | * and bump the ref count of the module | 251 | * 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 | } | 258 | } |
269 | 259 | ||
270 | /* register */ | 260 | /* register */ |
271 | err = kobject_register(&edac_dev->kobj); | 261 | err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl, |
262 | &edac_class->kset.kobj, | ||
263 | "%s", edac_dev->name); | ||
272 | if (err) { | 264 | if (err) { |
273 | debugf1("%s()Failed to register '.../edac/%s'\n", | 265 | debugf1("%s()Failed to register '.../edac/%s'\n", |
274 | __func__, edac_dev->name); | 266 | __func__, edac_dev->name); |
275 | goto err_kobj_reg; | 267 | goto err_kobj_reg; |
276 | } | 268 | } |
269 | kobject_uevent(&edac_dev->kobj, KOBJ_ADD); | ||
277 | 270 | ||
278 | /* At this point, to 'free' the control struct, | 271 | /* At this point, to 'free' the control struct, |
279 | * edac_device_unregister_sysfs_main_kobj() must be used | 272 | * 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 | 526 | ||
534 | /* init this block's kobject */ | 527 | /* init this block's kobject */ |
535 | memset(&block->kobj, 0, sizeof(struct kobject)); | 528 | memset(&block->kobj, 0, sizeof(struct kobject)); |
536 | block->kobj.parent = &instance->kobj; | ||
537 | block->kobj.ktype = &ktype_block_ctrl; | ||
538 | |||
539 | err = kobject_set_name(&block->kobj, "%s", block->name); | ||
540 | if (err) | ||
541 | return err; | ||
542 | 529 | ||
543 | /* bump the main kobject's reference count for this controller | 530 | /* bump the main kobject's reference count for this controller |
544 | * and this instance is dependant on the main | 531 | * 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 | } | 537 | } |
551 | 538 | ||
552 | /* Add this block's kobject */ | 539 | /* Add this block's kobject */ |
553 | err = kobject_register(&block->kobj); | 540 | err = kobject_init_and_add(&block->kobj, &ktype_block_ctrl, |
541 | &instance->kobj, | ||
542 | "%s", block->name); | ||
554 | if (err) { | 543 | if (err) { |
555 | debugf1("%s() Failed to register instance '%s'\n", | 544 | debugf1("%s() Failed to register instance '%s'\n", |
556 | __func__, block->name); | 545 | __func__, block->name); |
@@ -579,6 +568,7 @@ static int edac_device_create_block(struct edac_device_ctl_info *edac_dev, | |||
579 | goto err_on_attrib; | 568 | goto err_on_attrib; |
580 | } | 569 | } |
581 | } | 570 | } |
571 | kobject_uevent(&block->kobj, KOBJ_ADD); | ||
582 | 572 | ||
583 | return 0; | 573 | return 0; |
584 | 574 | ||
@@ -637,15 +627,8 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev, | |||
637 | /* Init the instance's kobject */ | 627 | /* Init the instance's kobject */ |
638 | memset(&instance->kobj, 0, sizeof(struct kobject)); | 628 | memset(&instance->kobj, 0, sizeof(struct kobject)); |
639 | 629 | ||
640 | /* set this new device under the edac_device main kobject */ | ||
641 | instance->kobj.parent = &edac_dev->kobj; | ||
642 | instance->kobj.ktype = &ktype_instance_ctrl; | ||
643 | instance->ctl = edac_dev; | 630 | instance->ctl = edac_dev; |
644 | 631 | ||
645 | err = kobject_set_name(&instance->kobj, "%s", instance->name); | ||
646 | if (err) | ||
647 | goto err_out; | ||
648 | |||
649 | /* bump the main kobject's reference count for this controller | 632 | /* bump the main kobject's reference count for this controller |
650 | * and this instance is dependant on the main | 633 | * and this instance is dependant on the main |
651 | */ | 634 | */ |
@@ -655,8 +638,9 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev, | |||
655 | goto err_out; | 638 | goto err_out; |
656 | } | 639 | } |
657 | 640 | ||
658 | /* Formally register this instance's kobject */ | 641 | /* Formally register this instance's kobject under the edac_device */ |
659 | err = kobject_register(&instance->kobj); | 642 | err = kobject_init_and_add(&instance->kobj, &ktype_instance_ctrl, |
643 | &edac_dev->kobj, "%s", instance->name); | ||
660 | if (err != 0) { | 644 | if (err != 0) { |
661 | debugf2("%s() Failed to register instance '%s'\n", | 645 | debugf2("%s() Failed to register instance '%s'\n", |
662 | __func__, instance->name); | 646 | __func__, instance->name); |
@@ -679,6 +663,7 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev, | |||
679 | goto err_release_instance_kobj; | 663 | goto err_release_instance_kobj; |
680 | } | 664 | } |
681 | } | 665 | } |
666 | kobject_uevent(&instance->kobj, KOBJ_ADD); | ||
682 | 667 | ||
683 | debugf4("%s() Registered instance %d '%s' kobject\n", | 668 | debugf4("%s() Registered instance %d '%s' kobject\n", |
684 | __func__, idx, instance->name); | 669 | __func__, idx, instance->name); |