aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/edac/edac_device_sysfs.c39
-rw-r--r--drivers/edac/edac_mc_sysfs.c28
-rw-r--r--drivers/edac/edac_pci_sysfs.c29
3 files changed, 29 insertions, 67 deletions
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c
index 70b837f23c4..10e5b19a3e3 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);
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
index 905fcd73c26..45b1d363341 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,7 +389,8 @@ 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
@@ -416,7 +410,7 @@ static int edac_create_csrow_object(struct mem_ctl_info *mci,
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 */
@@ -764,15 +758,6 @@ int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci)
764 /* Init the mci's kobject */ 758 /* Init the mci's kobject */
765 memset(kobj_mci, 0, sizeof(*kobj_mci)); 759 memset(kobj_mci, 0, sizeof(*kobj_mci));
766 760
767 /* this instance become part of the mc_kset */
768 kobj_mci->kset = &mc_kset;
769 kobj_mci->ktype = &ktype_mci;
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
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index 69f5dddabdd..834eaa9d614 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -162,14 +162,6 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
162 162
163 debugf0("%s()\n", __func__); 163 debugf0("%s()\n", __func__);
164 164
165 /* Set the parent and the instance's ktype */
166 pci->kobj.parent = &edac_pci_top_main_kobj;
167 pci->kobj.ktype = &ktype_pci_instance;
168
169 err = kobject_set_name(&pci->kobj, "pci%d", idx);
170 if (err)
171 return err;
172
173 /* First bump the ref count on the top main kobj, which will 165 /* First bump the ref count on the top main kobj, which will
174 * track the number of PCI instances we have, and thus nest 166 * track the number of PCI instances we have, and thus nest
175 * properly on keeping the module loaded 167 * 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 } 173 }
182 174
183 /* And now register this new kobject under the main kobj */ 175 /* And now register this new kobject under the main kobj */
184 err = kobject_register(&pci->kobj); 176 err = kobject_init_and_add(&pci->kobj, &ktype_pci_instance,
177 &edac_pci_top_main_kobj, "pci%d", idx);
185 if (err != 0) { 178 if (err != 0) {
186 debugf2("%s() failed to register instance pci%d\n", 179 debugf2("%s() failed to register instance pci%d\n",
187 __func__, idx); 180 __func__, idx);
@@ -189,6 +182,7 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
189 goto error_out; 182 goto error_out;
190 } 183 }
191 184
185 kobject_uevent(&pci->kobj, KOBJ_ADD);
192 debugf1("%s() Register instance 'pci%d' kobject\n", __func__, idx); 186 debugf1("%s() Register instance 'pci%d' kobject\n", __func__, idx);
193 187
194 return 0; 188 return 0;
@@ -364,14 +358,6 @@ int edac_pci_main_kobj_setup(void)
364 goto decrement_count_fail; 358 goto decrement_count_fail;
365 } 359 }
366 360
367 /* Need the kobject hook ups, and name setting */
368 edac_pci_top_main_kobj.ktype = &ktype_edac_pci_main_kobj;
369 edac_pci_top_main_kobj.parent = &edac_class->kset.kobj;
370
371 err = kobject_set_name(&edac_pci_top_main_kobj, "pci");
372 if (err)
373 goto decrement_count_fail;
374
375 /* Bump the reference count on this module to ensure the 361 /* Bump the reference count on this module to ensure the
376 * modules isn't unloaded until we deconstruct the top 362 * modules isn't unloaded until we deconstruct the top
377 * level main kobj for EDAC PCI 363 * level main kobj for EDAC PCI
@@ -383,23 +369,24 @@ int edac_pci_main_kobj_setup(void)
383 } 369 }
384 370
385 /* Instanstiate the pci object */ 371 /* Instanstiate the pci object */
386 /* FIXME: maybe new sysdev_create_subdir() */ 372 err = kobject_init_and_add(&edac_pci_top_main_kobj, &ktype_edac_pci_main_kobj,
387 err = kobject_register(&edac_pci_top_main_kobj); 373 &edac_class->kset.kobj, "pci");
388 if (err) { 374 if (err) {
389 debugf1("Failed to register '.../edac/pci'\n"); 375 debugf1("Failed to register '.../edac/pci'\n");
390 goto kobject_register_fail; 376 goto kobject_init_and_add_fail;
391 } 377 }
392 378
393 /* At this point, to 'release' the top level kobject 379 /* At this point, to 'release' the top level kobject
394 * for EDAC PCI, then edac_pci_main_kobj_teardown() 380 * for EDAC PCI, then edac_pci_main_kobj_teardown()
395 * must be used, for resources to be cleaned up properly 381 * must be used, for resources to be cleaned up properly
396 */ 382 */
383 kobject_uevent(&edac_pci_top_main_kobj, KOBJ_ADD);
397 debugf1("Registered '.../edac/pci' kobject\n"); 384 debugf1("Registered '.../edac/pci' kobject\n");
398 385
399 return 0; 386 return 0;
400 387
401 /* Error unwind statck */ 388 /* Error unwind statck */
402kobject_register_fail: 389kobject_init_and_add_fail:
403 module_put(THIS_MODULE); 390 module_put(THIS_MODULE);
404 391
405decrement_count_fail: 392decrement_count_fail: