diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-24 15:23:42 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-10 10:45:02 -0400 |
commit | cc301b3ae3f615fe243f023e68e22b8298a6f883 (patch) | |
tree | e3c88d8edb0f6158f151d1e462d33054374c05ed /drivers/edac | |
parent | a5538e531fc1e00ac7185dcfcebf33c37b5d742e (diff) |
edac: store/show methods for device groups weren't working
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/edac')
-rw-r--r-- | drivers/edac/edac_core.h | 2 | ||||
-rw-r--r-- | drivers/edac/edac_mc_sysfs.c | 85 | ||||
-rw-r--r-- | drivers/edac/i7core_edac.c | 10 |
3 files changed, 88 insertions, 9 deletions
diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h index 97071ff1d22..02bbbc9696d 100644 --- a/drivers/edac/edac_core.h +++ b/drivers/edac/edac_core.h | |||
@@ -345,6 +345,8 @@ struct mcidev_sysfs_group { | |||
345 | const char *name; | 345 | const char *name; |
346 | struct mcidev_sysfs_attribute *mcidev_attr; | 346 | struct mcidev_sysfs_attribute *mcidev_attr; |
347 | struct kobject kobj; | 347 | struct kobject kobj; |
348 | |||
349 | struct mem_ctl_info *mci; /* the parent */ | ||
348 | }; | 350 | }; |
349 | 351 | ||
350 | 352 | ||
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 655aa1a1f4f..6088ae6e8ea 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c | |||
@@ -557,6 +557,8 @@ static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr, | |||
557 | struct mem_ctl_info *mem_ctl_info = to_mci(kobj); | 557 | struct mem_ctl_info *mem_ctl_info = to_mci(kobj); |
558 | struct mcidev_sysfs_attribute *mcidev_attr = to_mcidev_attr(attr); | 558 | struct mcidev_sysfs_attribute *mcidev_attr = to_mcidev_attr(attr); |
559 | 559 | ||
560 | debugf1("%s() mem_ctl_info %p\n", __func__, mem_ctl_info); | ||
561 | |||
560 | if (mcidev_attr->show) | 562 | if (mcidev_attr->show) |
561 | return mcidev_attr->show(mem_ctl_info, buffer); | 563 | return mcidev_attr->show(mem_ctl_info, buffer); |
562 | 564 | ||
@@ -569,6 +571,8 @@ static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr, | |||
569 | struct mem_ctl_info *mem_ctl_info = to_mci(kobj); | 571 | struct mem_ctl_info *mem_ctl_info = to_mci(kobj); |
570 | struct mcidev_sysfs_attribute *mcidev_attr = to_mcidev_attr(attr); | 572 | struct mcidev_sysfs_attribute *mcidev_attr = to_mcidev_attr(attr); |
571 | 573 | ||
574 | debugf1("%s() mem_ctl_info %p\n", __func__, mem_ctl_info); | ||
575 | |||
572 | if (mcidev_attr->store) | 576 | if (mcidev_attr->store) |
573 | return mcidev_attr->store(mem_ctl_info, buffer, count); | 577 | return mcidev_attr->store(mem_ctl_info, buffer, count); |
574 | 578 | ||
@@ -726,32 +730,97 @@ void edac_mc_unregister_sysfs_main_kobj(struct mem_ctl_info *mci) | |||
726 | 730 | ||
727 | #define EDAC_DEVICE_SYMLINK "device" | 731 | #define EDAC_DEVICE_SYMLINK "device" |
728 | 732 | ||
733 | #define grp_to_mci(k) (container_of(k, struct mcidev_sysfs_group, kobj)->mci) | ||
734 | |||
735 | /* MCI show/store functions for top most object */ | ||
736 | static ssize_t inst_grp_show(struct kobject *kobj, struct attribute *attr, | ||
737 | char *buffer) | ||
738 | { | ||
739 | struct mem_ctl_info *mem_ctl_info = grp_to_mci(kobj); | ||
740 | struct mcidev_sysfs_attribute *mcidev_attr = to_mcidev_attr(attr); | ||
741 | |||
742 | debugf1("%s() mem_ctl_info %p\n", __func__, mem_ctl_info); | ||
743 | |||
744 | if (mcidev_attr->show) | ||
745 | return mcidev_attr->show(mem_ctl_info, buffer); | ||
746 | |||
747 | return -EIO; | ||
748 | } | ||
749 | |||
750 | static ssize_t inst_grp_store(struct kobject *kobj, struct attribute *attr, | ||
751 | const char *buffer, size_t count) | ||
752 | { | ||
753 | struct mem_ctl_info *mem_ctl_info = grp_to_mci(kobj); | ||
754 | struct mcidev_sysfs_attribute *mcidev_attr = to_mcidev_attr(attr); | ||
755 | |||
756 | debugf1("%s() mem_ctl_info %p\n", __func__, mem_ctl_info); | ||
757 | |||
758 | if (mcidev_attr->store) | ||
759 | return mcidev_attr->store(mem_ctl_info, buffer, count); | ||
760 | |||
761 | return -EIO; | ||
762 | } | ||
763 | |||
764 | /* No memory to release for this kobj */ | ||
765 | static void edac_inst_grp_release(struct kobject *kobj) | ||
766 | { | ||
767 | struct mcidev_sysfs_group *grp; | ||
768 | struct mem_ctl_info *mci; | ||
769 | |||
770 | debugf1("%s()\n", __func__); | ||
771 | |||
772 | grp = container_of(kobj, struct mcidev_sysfs_group, kobj); | ||
773 | mci = grp->mci; | ||
774 | |||
775 | kobject_put(&mci->edac_mci_kobj); | ||
776 | } | ||
777 | |||
778 | /* Intermediate show/store table */ | ||
779 | static struct sysfs_ops inst_grp_ops = { | ||
780 | .show = inst_grp_show, | ||
781 | .store = inst_grp_store | ||
782 | }; | ||
783 | |||
784 | /* the kobj_type instance for a instance group */ | ||
785 | static struct kobj_type ktype_inst_grp = { | ||
786 | .release = edac_inst_grp_release, | ||
787 | .sysfs_ops = &inst_grp_ops, | ||
788 | .default_attrs = (struct attribute **)default_csrow_attr, | ||
789 | }; | ||
790 | |||
791 | |||
729 | /* | 792 | /* |
730 | * edac_create_mci_instance_attributes | 793 | * edac_create_mci_instance_attributes |
731 | * create MC driver specific attributes bellow an specified kobj | 794 | * create MC driver specific attributes bellow an specified kobj |
732 | * This routine calls itself recursively, in order to create an entire | 795 | * This routine calls itself recursively, in order to create an entire |
733 | * object tree. | 796 | * object tree. |
734 | */ | 797 | */ |
735 | static int edac_create_mci_instance_attributes( | 798 | static int edac_create_mci_instance_attributes(struct mem_ctl_info *mci, |
736 | struct mcidev_sysfs_attribute *sysfs_attrib, | 799 | struct mcidev_sysfs_attribute *sysfs_attrib, |
737 | struct kobject *kobj) | 800 | struct kobject *kobj) |
738 | { | 801 | { |
739 | int err; | 802 | int err; |
740 | 803 | ||
804 | debugf1("%s()\n", __func__); | ||
805 | |||
741 | while (sysfs_attrib) { | 806 | while (sysfs_attrib) { |
742 | if (sysfs_attrib->grp) { | 807 | if (sysfs_attrib->grp) { |
743 | struct kobject *newkobj = &sysfs_attrib->grp->kobj; | 808 | struct kobject *newkobj = &sysfs_attrib->grp->kobj; |
744 | debugf0("%s() grp %s\n", __func__, | 809 | debugf0("%s() grp %s, mci %p\n", __func__, |
745 | sysfs_attrib->grp->name); | 810 | sysfs_attrib->grp->name, mci); |
811 | |||
812 | sysfs_attrib->grp->mci = mci; | ||
746 | 813 | ||
747 | err = kobject_init_and_add(newkobj, NULL, | 814 | err = kobject_init_and_add(newkobj, &ktype_inst_grp, |
748 | kobj, | 815 | kobj, |
749 | sysfs_attrib->grp->name); | 816 | sysfs_attrib->grp->name); |
750 | if (err) | 817 | if (err) |
751 | return err; | 818 | return err; |
752 | 819 | ||
753 | err = edac_create_mci_instance_attributes( | 820 | err = edac_create_mci_instance_attributes(mci, |
754 | sysfs_attrib->grp->mcidev_attr, newkobj); | 821 | sysfs_attrib->grp->mcidev_attr, |
822 | newkobj); | ||
823 | |||
755 | if (err) | 824 | if (err) |
756 | return err; | 825 | return err; |
757 | } else if (sysfs_attrib->attr.name) { | 826 | } else if (sysfs_attrib->attr.name) { |
@@ -780,6 +849,8 @@ static void edac_remove_mci_instance_attributes( | |||
780 | struct mcidev_sysfs_attribute *sysfs_attrib, | 849 | struct mcidev_sysfs_attribute *sysfs_attrib, |
781 | struct kobject *kobj) | 850 | struct kobject *kobj) |
782 | { | 851 | { |
852 | debugf1("%s()\n", __func__); | ||
853 | |||
783 | /* loop if there are attributes and until we hit a NULL entry */ | 854 | /* loop if there are attributes and until we hit a NULL entry */ |
784 | while (sysfs_attrib) { | 855 | while (sysfs_attrib) { |
785 | if (sysfs_attrib->grp) { | 856 | if (sysfs_attrib->grp) { |
@@ -832,7 +903,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) | |||
832 | * then create them now for the driver. | 903 | * then create them now for the driver. |
833 | */ | 904 | */ |
834 | if (mci->mc_driver_sysfs_attributes) { | 905 | if (mci->mc_driver_sysfs_attributes) { |
835 | err = edac_create_mci_instance_attributes( | 906 | err = edac_create_mci_instance_attributes(mci, |
836 | mci->mc_driver_sysfs_attributes, | 907 | mci->mc_driver_sysfs_attributes, |
837 | &mci->edac_mci_kobj); | 908 | &mci->edac_mci_kobj); |
838 | if (err) { | 909 | if (err) { |
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c index afa5281e8df..e013004745d 100644 --- a/drivers/edac/i7core_edac.c +++ b/drivers/edac/i7core_edac.c | |||
@@ -784,10 +784,13 @@ static ssize_t i7core_inject_store_##param( \ | |||
784 | struct mem_ctl_info *mci, \ | 784 | struct mem_ctl_info *mci, \ |
785 | const char *data, size_t count) \ | 785 | const char *data, size_t count) \ |
786 | { \ | 786 | { \ |
787 | struct i7core_pvt *pvt = mci->pvt_info; \ | 787 | struct i7core_pvt *pvt; \ |
788 | long value; \ | 788 | long value; \ |
789 | int rc; \ | 789 | int rc; \ |
790 | \ | 790 | \ |
791 | debugf1("%s()\n", __func__); \ | ||
792 | pvt = mci->pvt_info; \ | ||
793 | \ | ||
791 | if (pvt->inject.enable) \ | 794 | if (pvt->inject.enable) \ |
792 | disable_inject(mci); \ | 795 | disable_inject(mci); \ |
793 | \ | 796 | \ |
@@ -808,7 +811,10 @@ static ssize_t i7core_inject_show_##param( \ | |||
808 | struct mem_ctl_info *mci, \ | 811 | struct mem_ctl_info *mci, \ |
809 | char *data) \ | 812 | char *data) \ |
810 | { \ | 813 | { \ |
811 | struct i7core_pvt *pvt = mci->pvt_info; \ | 814 | struct i7core_pvt *pvt; \ |
815 | \ | ||
816 | pvt = mci->pvt_info; \ | ||
817 | debugf1("%s() pvt=%p\n", __func__, pvt); \ | ||
812 | if (pvt->inject.param < 0) \ | 818 | if (pvt->inject.param < 0) \ |
813 | return sprintf(data, "any\n"); \ | 819 | return sprintf(data, "any\n"); \ |
814 | else \ | 820 | else \ |