aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/edac_device_sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/edac/edac_device_sysfs.c')
-rw-r--r--drivers/edac/edac_device_sysfs.c49
1 files changed, 17 insertions, 32 deletions
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index 70b837f23c43..53764577035f 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
@@ -310,7 +303,7 @@ void edac_device_unregister_sysfs_main_kobj(
310 * a) module_put() this module 303 * a) module_put() this module
311 * b) 'kfree' the memory 304 * b) 'kfree' the memory
312 */ 305 */
313 kobject_unregister(&edac_dev->kobj); 306 kobject_put(&edac_dev->kobj);
314} 307}
315 308
316/* edac_dev -> instance information */ 309/* edac_dev -> instance information */
@@ -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,12 +568,13 @@ 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
585 /* Error unwind stack */ 575 /* Error unwind stack */
586err_on_attrib: 576err_on_attrib:
587 kobject_unregister(&block->kobj); 577 kobject_put(&block->kobj);
588 578
589err_out: 579err_out:
590 return err; 580 return err;
@@ -615,7 +605,7 @@ static void edac_device_delete_block(struct edac_device_ctl_info *edac_dev,
615 /* unregister this block's kobject, SEE: 605 /* unregister this block's kobject, SEE:
616 * edac_device_ctrl_block_release() callback operation 606 * edac_device_ctrl_block_release() callback operation
617 */ 607 */
618 kobject_unregister(&block->kobj); 608 kobject_put(&block->kobj);
619} 609}
620 610
621/* instance ctor/dtor code */ 611/* instance ctor/dtor code */
@@ -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);
@@ -687,7 +672,7 @@ static int edac_device_create_instance(struct edac_device_ctl_info *edac_dev,
687 672
688 /* error unwind stack */ 673 /* error unwind stack */
689err_release_instance_kobj: 674err_release_instance_kobj:
690 kobject_unregister(&instance->kobj); 675 kobject_put(&instance->kobj);
691 676
692err_out: 677err_out:
693 return err; 678 return err;
@@ -712,7 +697,7 @@ static void edac_device_delete_instance(struct edac_device_ctl_info *edac_dev,
712 /* unregister this instance's kobject, SEE: 697 /* unregister this instance's kobject, SEE:
713 * edac_device_ctrl_instance_release() for callback operation 698 * edac_device_ctrl_instance_release() for callback operation
714 */ 699 */
715 kobject_unregister(&instance->kobj); 700 kobject_put(&instance->kobj);
716} 701}
717 702
718/* 703/*