diff options
author | Douglas Thompson <dougthompson@xmission.com> | 2007-07-19 04:50:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-19 13:04:55 -0400 |
commit | 42a8e397a80c277afb2aeb22232bc70114035bb1 (patch) | |
tree | b178b3379d2de5607b5ddb29a2def3472e9d99fe /drivers/edac/edac_device_sysfs.c | |
parent | 456a2f9552e7849475f4aea1a9aa4c0e54b3ddda (diff) |
drivers/edac: add device sysfs attributes
Added new controls for the edac_device and edac_mc sysfs folder.
These can be initialized by the low level driver to provide misc
controls into the low level driver for its use
Signed-off-by: Douglas Thompson <dougthompson@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/edac/edac_device_sysfs.c')
-rw-r--r-- | drivers/edac/edac_device_sysfs.c | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/drivers/edac/edac_device_sysfs.c b/drivers/edac/edac_device_sysfs.c index 849d569dd2ce..32b2a8e53dc7 100644 --- a/drivers/edac/edac_device_sysfs.c +++ b/drivers/edac/edac_device_sysfs.c | |||
@@ -9,8 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/sysdev.h> | ||
14 | #include <linux/ctype.h> | 12 | #include <linux/ctype.h> |
15 | 13 | ||
16 | #include "edac_core.h" | 14 | #include "edac_core.h" |
@@ -622,6 +620,34 @@ static void edac_device_delete_instances(struct edac_device_ctl_info *edac_dev) | |||
622 | /******************* edac_dev sysfs ctor/dtor code *************/ | 620 | /******************* edac_dev sysfs ctor/dtor code *************/ |
623 | 621 | ||
624 | /* | 622 | /* |
623 | * edac_device_add_sysfs_attributes | ||
624 | * add some attributes to this instance's main kobject | ||
625 | */ | ||
626 | static int edac_device_add_sysfs_attributes( | ||
627 | struct edac_device_ctl_info *edac_dev) | ||
628 | { | ||
629 | int err; | ||
630 | struct edac_dev_sysfs_attribute *sysfs_attrib; | ||
631 | |||
632 | /* point to the start of the array and iterate over it | ||
633 | * adding each attribute listed to this mci instance's kobject | ||
634 | */ | ||
635 | sysfs_attrib = edac_dev->sysfs_attributes; | ||
636 | |||
637 | while (sysfs_attrib->attr.name != NULL) { | ||
638 | err = sysfs_create_file(&edac_dev->kobj, | ||
639 | (struct attribute*) sysfs_attrib); | ||
640 | if (err) { | ||
641 | return err; | ||
642 | } | ||
643 | |||
644 | sysfs_attrib++; | ||
645 | } | ||
646 | |||
647 | return 0; | ||
648 | } | ||
649 | |||
650 | /* | ||
625 | * edac_device_create_sysfs() Constructor | 651 | * edac_device_create_sysfs() Constructor |
626 | * | 652 | * |
627 | * Create a new edac_device kobject instance, | 653 | * Create a new edac_device kobject instance, |
@@ -642,6 +668,18 @@ int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev) | |||
642 | 668 | ||
643 | debugf0("%s() idx=%d\n", __func__, edac_dev->dev_idx); | 669 | debugf0("%s() idx=%d\n", __func__, edac_dev->dev_idx); |
644 | 670 | ||
671 | /* If the low level driver requests some sysfs entries | ||
672 | * then go create them here | ||
673 | */ | ||
674 | if (edac_dev->sysfs_attributes != NULL) { | ||
675 | err = edac_device_add_sysfs_attributes(edac_dev); | ||
676 | if (err) { | ||
677 | debugf0("%s() failed to add sysfs attribs\n", | ||
678 | __func__); | ||
679 | goto err_unreg_object; | ||
680 | } | ||
681 | } | ||
682 | |||
645 | /* create a symlink from the edac device | 683 | /* create a symlink from the edac device |
646 | * to the platform 'device' being used for this | 684 | * to the platform 'device' being used for this |
647 | */ | 685 | */ |
@@ -650,7 +688,7 @@ int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev) | |||
650 | if (err) { | 688 | if (err) { |
651 | debugf0("%s() sysfs_create_link() returned err= %d\n", | 689 | debugf0("%s() sysfs_create_link() returned err= %d\n", |
652 | __func__, err); | 690 | __func__, err); |
653 | return err; | 691 | goto err_unreg_object; |
654 | } | 692 | } |
655 | 693 | ||
656 | debugf0("%s() calling create-instances, idx=%d\n", | 694 | debugf0("%s() calling create-instances, idx=%d\n", |
@@ -659,14 +697,17 @@ int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev) | |||
659 | /* Create the first level instance directories */ | 697 | /* Create the first level instance directories */ |
660 | err = edac_device_create_instances(edac_dev); | 698 | err = edac_device_create_instances(edac_dev); |
661 | if (err) { | 699 | if (err) { |
662 | goto error0; | 700 | goto err_remove_link; |
663 | } | 701 | } |
664 | 702 | ||
665 | return 0; | 703 | return 0; |
666 | 704 | ||
667 | /* Error unwind stack */ | 705 | /* Error unwind stack */ |
706 | err_remove_link: | ||
707 | /* remove the sym link */ | ||
708 | sysfs_remove_link(&edac_dev->kobj, EDAC_DEVICE_SYMLINK); | ||
668 | 709 | ||
669 | error0: | 710 | err_unreg_object: |
670 | edac_device_unregister_main_kobj(edac_dev); | 711 | edac_device_unregister_main_kobj(edac_dev); |
671 | 712 | ||
672 | return err; | 713 | return err; |