aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2008-01-30 19:25:51 -0500
committerPaul Mackerras <paulus@samba.org>2008-01-30 19:25:51 -0500
commitbd45ac0c5daae35e7c71138172e63df5cf644cf6 (patch)
tree5eb5a599bf6a9d7a8a34e802db932aa9e9555de4 /drivers/edac
parent4eece4ccf997c0e6d8fdad3d842e37b16b8d705f (diff)
parent5bdeae46be6dfe9efa44a548bd622af325f4bdb4 (diff)
Merge branch 'linux-2.6'
Diffstat (limited to 'drivers/edac')
-rw-r--r--drivers/edac/edac_device_sysfs.c49
-rw-r--r--drivers/edac/edac_mc_sysfs.c40
-rw-r--r--drivers/edac/edac_module.c2
-rw-r--r--drivers/edac/edac_pci_sysfs.c35
4 files changed, 44 insertions, 82 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/*
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 */
745static struct kset mc_kset = { 739static 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:
818void edac_mc_unregister_sysfs_main_kobj(struct mem_ctl_info *mci) 808void 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)
933fail1: 923fail1:
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
diff --git a/drivers/edac/edac_module.c b/drivers/edac/edac_module.c
index e0c4a4086055..7e1374afd967 100644
--- a/drivers/edac/edac_module.c
+++ b/drivers/edac/edac_module.c
@@ -31,7 +31,7 @@ struct workqueue_struct *edac_workqueue;
31 * need to export to other files in this modules 31 * need to export to other files in this modules
32 */ 32 */
33static struct sysdev_class edac_class = { 33static struct sysdev_class edac_class = {
34 set_kset_name("edac"), 34 .name = "edac",
35}; 35};
36static int edac_class_valid; 36static int edac_class_valid;
37 37
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index 69f5dddabddf..5b075da99145 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;
@@ -211,7 +205,7 @@ void edac_pci_unregister_sysfs_instance_kobj(struct edac_pci_ctl_info *pci)
211 * function release the main reference count and then 205 * function release the main reference count and then
212 * kfree the memory 206 * kfree the memory
213 */ 207 */
214 kobject_unregister(&pci->kobj); 208 kobject_put(&pci->kobj);
215} 209}
216 210
217/***************************** EDAC PCI sysfs root **********************/ 211/***************************** EDAC PCI sysfs root **********************/
@@ -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:
@@ -424,9 +411,9 @@ static void edac_pci_main_kobj_teardown(void)
424 * main kobj 411 * main kobj
425 */ 412 */
426 if (atomic_dec_return(&edac_pci_sysfs_refcount) == 0) { 413 if (atomic_dec_return(&edac_pci_sysfs_refcount) == 0) {
427 debugf0("%s() called kobject_unregister on main kobj\n", 414 debugf0("%s() called kobject_put on main kobj\n",
428 __func__); 415 __func__);
429 kobject_unregister(&edac_pci_top_main_kobj); 416 kobject_put(&edac_pci_top_main_kobj);
430 } 417 }
431} 418}
432 419