diff options
Diffstat (limited to 'drivers/edac/edac_mc_sysfs.c')
-rw-r--r-- | drivers/edac/edac_mc_sysfs.c | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 3706b2bc0987..9aac88027fb3 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c | |||
@@ -380,13 +380,6 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci, | |||
380 | /* generate ..../edac/mc/mc<id>/csrow<index> */ | 380 | /* generate ..../edac/mc/mc<id>/csrow<index> */ |
381 | memset(&csrow->kobj, 0, sizeof(csrow->kobj)); | 381 | memset(&csrow->kobj, 0, sizeof(csrow->kobj)); |
382 | csrow->mci = mci; /* include container up link */ | 382 | csrow->mci = mci; /* include container up link */ |
383 | csrow->kobj.parent = kobj_mci; | ||
384 | csrow->kobj.ktype = &ktype_csrow; | ||
385 | |||
386 | /* name this instance of csrow<id> */ | ||
387 | err = kobject_set_name(&csrow->kobj, "csrow%d", index); | ||
388 | if (err) | ||
389 | goto err_out; | ||
390 | 383 | ||
391 | /* bump the mci instance's kobject's ref count */ | 384 | /* bump the mci instance's kobject's ref count */ |
392 | kobj = kobject_get(&mci->edac_mci_kobj); | 385 | kobj = kobject_get(&mci->edac_mci_kobj); |
@@ -396,12 +389,13 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci, | |||
396 | } | 389 | } |
397 | 390 | ||
398 | /* Instanstiate the csrow object */ | 391 | /* Instanstiate the csrow object */ |
399 | err = kobject_register(&csrow->kobj); | 392 | err = kobject_init_and_add(&csrow->kobj, &ktype_csrow, kobj_mci, |
393 | "csrow%d", index); | ||
400 | if (err) | 394 | if (err) |
401 | goto err_release_top_kobj; | 395 | goto err_release_top_kobj; |
402 | 396 | ||
403 | /* At this point, to release a csrow kobj, one must | 397 | /* At this point, to release a csrow kobj, one must |
404 | * call the kobject_unregister and allow that tear down | 398 | * call the kobject_put and allow that tear down |
405 | * to work the releasing | 399 | * to work the releasing |
406 | */ | 400 | */ |
407 | 401 | ||
@@ -412,11 +406,11 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci, | |||
412 | err = edac_create_channel_files(&csrow->kobj, chan); | 406 | err = edac_create_channel_files(&csrow->kobj, chan); |
413 | if (err) { | 407 | if (err) { |
414 | /* special case the unregister here */ | 408 | /* special case the unregister here */ |
415 | kobject_unregister(&csrow->kobj); | 409 | kobject_put(&csrow->kobj); |
416 | goto err_out; | 410 | goto err_out; |
417 | } | 411 | } |
418 | } | 412 | } |
419 | 413 | kobject_uevent(&csrow->kobj, KOBJ_ADD); | |
420 | return 0; | 414 | return 0; |
421 | 415 | ||
422 | /* error unwind stack */ | 416 | /* error unwind stack */ |
@@ -744,7 +738,6 @@ static struct kobj_type ktype_mc_set_attribs = { | |||
744 | */ | 738 | */ |
745 | static struct kset mc_kset = { | 739 | static struct kset mc_kset = { |
746 | .kobj = {.ktype = &ktype_mc_set_attribs }, | 740 | .kobj = {.ktype = &ktype_mc_set_attribs }, |
747 | .ktype = &ktype_mci, | ||
748 | }; | 741 | }; |
749 | 742 | ||
750 | 743 | ||
@@ -765,14 +758,6 @@ int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci) | |||
765 | /* Init the mci's kobject */ | 758 | /* Init the mci's kobject */ |
766 | memset(kobj_mci, 0, sizeof(*kobj_mci)); | 759 | memset(kobj_mci, 0, sizeof(*kobj_mci)); |
767 | 760 | ||
768 | /* this instance become part of the mc_kset */ | ||
769 | kobj_mci->kset = &mc_kset; | ||
770 | |||
771 | /* set the name of the mc<id> object */ | ||
772 | err = kobject_set_name(kobj_mci, "mc%d", mci->mc_idx); | ||
773 | if (err) | ||
774 | goto fail_out; | ||
775 | |||
776 | /* Record which module 'owns' this control structure | 761 | /* Record which module 'owns' this control structure |
777 | * and bump the ref count of the module | 762 | * and bump the ref count of the module |
778 | */ | 763 | */ |
@@ -784,13 +769,18 @@ int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci) | |||
784 | goto fail_out; | 769 | goto fail_out; |
785 | } | 770 | } |
786 | 771 | ||
772 | /* this instance become part of the mc_kset */ | ||
773 | kobj_mci->kset = &mc_kset; | ||
774 | |||
787 | /* register the mc<id> kobject to the mc_kset */ | 775 | /* register the mc<id> kobject to the mc_kset */ |
788 | err = kobject_register(kobj_mci); | 776 | err = kobject_init_and_add(kobj_mci, &ktype_mci, NULL, |
777 | "mc%d", mci->mc_idx); | ||
789 | if (err) { | 778 | if (err) { |
790 | debugf1("%s()Failed to register '.../edac/mc%d'\n", | 779 | debugf1("%s()Failed to register '.../edac/mc%d'\n", |
791 | __func__, mci->mc_idx); | 780 | __func__, mci->mc_idx); |
792 | goto kobj_reg_fail; | 781 | goto kobj_reg_fail; |
793 | } | 782 | } |
783 | kobject_uevent(kobj_mci, KOBJ_ADD); | ||
794 | 784 | ||
795 | /* At this point, to 'free' the control struct, | 785 | /* At this point, to 'free' the control struct, |
796 | * edac_mc_unregister_sysfs_main_kobj() must be used | 786 | * edac_mc_unregister_sysfs_main_kobj() must be used |
@@ -818,7 +808,7 @@ fail_out: | |||
818 | void edac_mc_unregister_sysfs_main_kobj(struct mem_ctl_info *mci) | 808 | void edac_mc_unregister_sysfs_main_kobj(struct mem_ctl_info *mci) |
819 | { | 809 | { |
820 | /* delete the kobj from the mc_kset */ | 810 | /* delete the kobj from the mc_kset */ |
821 | kobject_unregister(&mci->edac_mci_kobj); | 811 | kobject_put(&mci->edac_mci_kobj); |
822 | } | 812 | } |
823 | 813 | ||
824 | #define EDAC_DEVICE_SYMLINK "device" | 814 | #define EDAC_DEVICE_SYMLINK "device" |
@@ -933,7 +923,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) | |||
933 | fail1: | 923 | fail1: |
934 | for (i--; i >= 0; i--) { | 924 | for (i--; i >= 0; i--) { |
935 | if (csrow->nr_pages > 0) { | 925 | if (csrow->nr_pages > 0) { |
936 | kobject_unregister(&mci->csrows[i].kobj); | 926 | kobject_put(&mci->csrows[i].kobj); |
937 | } | 927 | } |
938 | } | 928 | } |
939 | 929 | ||
@@ -960,7 +950,7 @@ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci) | |||
960 | for (i = 0; i < mci->nr_csrows; i++) { | 950 | for (i = 0; i < mci->nr_csrows; i++) { |
961 | if (mci->csrows[i].nr_pages > 0) { | 951 | if (mci->csrows[i].nr_pages > 0) { |
962 | debugf0("%s() unreg csrow-%d\n", __func__, i); | 952 | debugf0("%s() unreg csrow-%d\n", __func__, i); |
963 | kobject_unregister(&mci->csrows[i].kobj); | 953 | kobject_put(&mci->csrows[i].kobj); |
964 | } | 954 | } |
965 | } | 955 | } |
966 | 956 | ||
@@ -977,7 +967,7 @@ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci) | |||
977 | debugf0("%s() unregister this mci kobj\n", __func__); | 967 | debugf0("%s() unregister this mci kobj\n", __func__); |
978 | 968 | ||
979 | /* unregister this instance's kobject */ | 969 | /* unregister this instance's kobject */ |
980 | kobject_unregister(&mci->edac_mci_kobj); | 970 | kobject_put(&mci->edac_mci_kobj); |
981 | } | 971 | } |
982 | 972 | ||
983 | 973 | ||