aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/edac_mc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/edac/edac_mc.c')
-rw-r--r--drivers/edac/edac_mc.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index d37a4c4a312..e6ecc7da38a 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -278,8 +278,6 @@ static int edac_sysfs_memctrl_setup(void)
278 if (!err) { 278 if (!err) {
279 /* Init the MC's kobject */ 279 /* Init the MC's kobject */
280 memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj)); 280 memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj));
281 kobject_init(&edac_memctrl_kobj);
282
283 edac_memctrl_kobj.parent = &edac_class.kset.kobj; 281 edac_memctrl_kobj.parent = &edac_class.kset.kobj;
284 edac_memctrl_kobj.ktype = &ktype_memctrl; 282 edac_memctrl_kobj.ktype = &ktype_memctrl;
285 283
@@ -314,9 +312,6 @@ static void edac_sysfs_memctrl_teardown(void)
314 /* Unregister the MC's kobject */ 312 /* Unregister the MC's kobject */
315 kobject_unregister(&edac_memctrl_kobj); 313 kobject_unregister(&edac_memctrl_kobj);
316 314
317 /* release the master edac mc kobject */
318 kobject_put(&edac_memctrl_kobj);
319
320 /* Unregister the 'edac' object */ 315 /* Unregister the 'edac' object */
321 sysdev_class_unregister(&edac_class); 316 sysdev_class_unregister(&edac_class);
322#endif /* DISABLE_EDAC_SYSFS */ 317#endif /* DISABLE_EDAC_SYSFS */
@@ -594,8 +589,6 @@ static int edac_sysfs_pci_setup(void)
594 debugf1("%s()\n", __func__); 589 debugf1("%s()\n", __func__);
595 590
596 memset(&edac_pci_kobj, 0, sizeof(edac_pci_kobj)); 591 memset(&edac_pci_kobj, 0, sizeof(edac_pci_kobj));
597
598 kobject_init(&edac_pci_kobj);
599 edac_pci_kobj.parent = &edac_class.kset.kobj; 592 edac_pci_kobj.parent = &edac_class.kset.kobj;
600 edac_pci_kobj.ktype = &ktype_edac_pci; 593 edac_pci_kobj.ktype = &ktype_edac_pci;
601 594
@@ -619,7 +612,6 @@ static void edac_sysfs_pci_teardown(void)
619 debugf0("%s()\n", __func__); 612 debugf0("%s()\n", __func__);
620 613
621 kobject_unregister(&edac_pci_kobj); 614 kobject_unregister(&edac_pci_kobj);
622 kobject_put(&edac_pci_kobj);
623#endif 615#endif
624} 616}
625 617
@@ -829,7 +821,6 @@ static int edac_create_csrow_object(struct kobject *edac_mci_kobj,
829 821
830 /* generate ..../edac/mc/mc<id>/csrow<index> */ 822 /* generate ..../edac/mc/mc<id>/csrow<index> */
831 823
832 kobject_init(&csrow->kobj);
833 csrow->kobj.parent = edac_mci_kobj; 824 csrow->kobj.parent = edac_mci_kobj;
834 csrow->kobj.ktype = &ktype_csrow; 825 csrow->kobj.ktype = &ktype_csrow;
835 826
@@ -1104,7 +1095,6 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
1104 debugf0("%s() idx=%d\n", __func__, mci->mc_idx); 1095 debugf0("%s() idx=%d\n", __func__, mci->mc_idx);
1105 1096
1106 memset(edac_mci_kobj, 0, sizeof(*edac_mci_kobj)); 1097 memset(edac_mci_kobj, 0, sizeof(*edac_mci_kobj));
1107 kobject_init(edac_mci_kobj);
1108 1098
1109 /* set the name of the mc<id> object */ 1099 /* set the name of the mc<id> object */
1110 err = kobject_set_name(edac_mci_kobj,"mc%d",mci->mc_idx); 1100 err = kobject_set_name(edac_mci_kobj,"mc%d",mci->mc_idx);
@@ -1123,10 +1113,8 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
1123 /* create a symlink for the device */ 1113 /* create a symlink for the device */
1124 err = sysfs_create_link(edac_mci_kobj, &mci->pdev->dev.kobj, 1114 err = sysfs_create_link(edac_mci_kobj, &mci->pdev->dev.kobj,
1125 EDAC_DEVICE_SYMLINK); 1115 EDAC_DEVICE_SYMLINK);
1126 if (err) { 1116 if (err)
1127 kobject_unregister(edac_mci_kobj); 1117 goto fail0;
1128 return err;
1129 }
1130 1118
1131 /* Make directories for each CSROW object 1119 /* Make directories for each CSROW object
1132 * under the mc<id> kobject 1120 * under the mc<id> kobject
@@ -1139,7 +1127,7 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
1139 if (csrow->nr_pages > 0) { 1127 if (csrow->nr_pages > 0) {
1140 err = edac_create_csrow_object(edac_mci_kobj,csrow,i); 1128 err = edac_create_csrow_object(edac_mci_kobj,csrow,i);
1141 if (err) 1129 if (err)
1142 goto fail; 1130 goto fail1;
1143 } 1131 }
1144 } 1132 }
1145 1133
@@ -1150,16 +1138,14 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
1150 1138
1151 1139
1152 /* CSROW error: backout what has already been registered, */ 1140 /* CSROW error: backout what has already been registered, */
1153fail: 1141fail1:
1154 for ( i--; i >= 0; i--) { 1142 for ( i--; i >= 0; i--) {
1155 if (csrow->nr_pages > 0) { 1143 if (csrow->nr_pages > 0)
1156 kobject_unregister(&mci->csrows[i].kobj); 1144 kobject_unregister(&mci->csrows[i].kobj);
1157 kobject_put(&mci->csrows[i].kobj);
1158 }
1159 } 1145 }
1160 1146
1147fail0:
1161 kobject_unregister(edac_mci_kobj); 1148 kobject_unregister(edac_mci_kobj);
1162 kobject_put(edac_mci_kobj);
1163 1149
1164 return err; 1150 return err;
1165} 1151}
@@ -1177,16 +1163,13 @@ static void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)
1177 1163
1178 /* remove all csrow kobjects */ 1164 /* remove all csrow kobjects */
1179 for (i = 0; i < mci->nr_csrows; i++) { 1165 for (i = 0; i < mci->nr_csrows; i++) {
1180 if (mci->csrows[i].nr_pages > 0) { 1166 if (mci->csrows[i].nr_pages > 0)
1181 kobject_unregister(&mci->csrows[i].kobj); 1167 kobject_unregister(&mci->csrows[i].kobj);
1182 kobject_put(&mci->csrows[i].kobj);
1183 }
1184 } 1168 }
1185 1169
1186 sysfs_remove_link(&mci->edac_mci_kobj, EDAC_DEVICE_SYMLINK); 1170 sysfs_remove_link(&mci->edac_mci_kobj, EDAC_DEVICE_SYMLINK);
1187 1171
1188 kobject_unregister(&mci->edac_mci_kobj); 1172 kobject_unregister(&mci->edac_mci_kobj);
1189 kobject_put(&mci->edac_mci_kobj);
1190#endif /* DISABLE_EDAC_SYSFS */ 1173#endif /* DISABLE_EDAC_SYSFS */
1191} 1174}
1192 1175