diff options
author | Takashi Iwai <tiwai@suse.de> | 2015-02-04 05:48:53 -0500 |
---|---|---|
committer | Borislav Petkov <bp@suse.de> | 2015-02-23 07:08:09 -0500 |
commit | e339f1ec979a4ab14b497114e39b8ab70bd0215d (patch) | |
tree | 73b213cf415b2ccf03afc9f23b31137f5062b16a /drivers/edac/amd64_edac.c | |
parent | 4e8d230de9c1dff8e587ae769e46fcddb3d98f1c (diff) |
EDAC: amd64: Use static attribute groups
Instead of calling device_create_file() and device_remove_file()
manually, pass the static attribute groups with the new
edac_mc_add_mc_with_groups(). The conditional creation of inject sysfs
files is done by a proper is_visible callback.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: http://lkml.kernel.org/r/1423046938-18111-4-git-send-email-tiwai@suse.de
Signed-off-by: Borislav Petkov <bp@suse.de>
Diffstat (limited to 'drivers/edac/amd64_edac.c')
-rw-r--r-- | drivers/edac/amd64_edac.c | 47 |
1 files changed, 11 insertions, 36 deletions
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 5907c1718f8c..3d6a511a9025 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c | |||
@@ -2663,34 +2663,6 @@ static bool ecc_enabled(struct pci_dev *F3, u16 nid) | |||
2663 | return true; | 2663 | return true; |
2664 | } | 2664 | } |
2665 | 2665 | ||
2666 | static int set_mc_sysfs_attrs(struct mem_ctl_info *mci) | ||
2667 | { | ||
2668 | struct amd64_pvt *pvt = mci->pvt_info; | ||
2669 | int rc; | ||
2670 | |||
2671 | rc = amd64_create_sysfs_dbg_files(mci); | ||
2672 | if (rc < 0) | ||
2673 | return rc; | ||
2674 | |||
2675 | if (pvt->fam >= 0x10) { | ||
2676 | rc = amd64_create_sysfs_inject_files(mci); | ||
2677 | if (rc < 0) | ||
2678 | return rc; | ||
2679 | } | ||
2680 | |||
2681 | return 0; | ||
2682 | } | ||
2683 | |||
2684 | static void del_mc_sysfs_attrs(struct mem_ctl_info *mci) | ||
2685 | { | ||
2686 | struct amd64_pvt *pvt = mci->pvt_info; | ||
2687 | |||
2688 | amd64_remove_sysfs_dbg_files(mci); | ||
2689 | |||
2690 | if (pvt->fam >= 0x10) | ||
2691 | amd64_remove_sysfs_inject_files(mci); | ||
2692 | } | ||
2693 | |||
2694 | static void setup_mci_misc_attrs(struct mem_ctl_info *mci, | 2666 | static void setup_mci_misc_attrs(struct mem_ctl_info *mci, |
2695 | struct amd64_family_type *fam) | 2667 | struct amd64_family_type *fam) |
2696 | { | 2668 | { |
@@ -2778,6 +2750,16 @@ static struct amd64_family_type *per_family_init(struct amd64_pvt *pvt) | |||
2778 | return fam_type; | 2750 | return fam_type; |
2779 | } | 2751 | } |
2780 | 2752 | ||
2753 | static const struct attribute_group *amd64_edac_attr_groups[] = { | ||
2754 | #ifdef CONFIG_EDAC_DEBUG | ||
2755 | &amd64_edac_dbg_group, | ||
2756 | #endif | ||
2757 | #ifdef CONFIG_EDAC_AMD64_ERROR_INJECTION | ||
2758 | &amd64_edac_inj_group, | ||
2759 | #endif | ||
2760 | NULL | ||
2761 | }; | ||
2762 | |||
2781 | static int init_one_instance(struct pci_dev *F2) | 2763 | static int init_one_instance(struct pci_dev *F2) |
2782 | { | 2764 | { |
2783 | struct amd64_pvt *pvt = NULL; | 2765 | struct amd64_pvt *pvt = NULL; |
@@ -2844,14 +2826,10 @@ static int init_one_instance(struct pci_dev *F2) | |||
2844 | mci->edac_cap = EDAC_FLAG_NONE; | 2826 | mci->edac_cap = EDAC_FLAG_NONE; |
2845 | 2827 | ||
2846 | ret = -ENODEV; | 2828 | ret = -ENODEV; |
2847 | if (edac_mc_add_mc(mci)) { | 2829 | if (edac_mc_add_mc_with_groups(mci, amd64_edac_attr_groups)) { |
2848 | edac_dbg(1, "failed edac_mc_add_mc()\n"); | 2830 | edac_dbg(1, "failed edac_mc_add_mc()\n"); |
2849 | goto err_add_mc; | 2831 | goto err_add_mc; |
2850 | } | 2832 | } |
2851 | if (set_mc_sysfs_attrs(mci)) { | ||
2852 | edac_dbg(1, "failed edac_mc_add_mc()\n"); | ||
2853 | goto err_add_sysfs; | ||
2854 | } | ||
2855 | 2833 | ||
2856 | /* register stuff with EDAC MCE */ | 2834 | /* register stuff with EDAC MCE */ |
2857 | if (report_gart_errors) | 2835 | if (report_gart_errors) |
@@ -2865,8 +2843,6 @@ static int init_one_instance(struct pci_dev *F2) | |||
2865 | 2843 | ||
2866 | return 0; | 2844 | return 0; |
2867 | 2845 | ||
2868 | err_add_sysfs: | ||
2869 | edac_mc_del_mc(mci->pdev); | ||
2870 | err_add_mc: | 2846 | err_add_mc: |
2871 | edac_mc_free(mci); | 2847 | edac_mc_free(mci); |
2872 | 2848 | ||
@@ -2940,7 +2916,6 @@ static void remove_one_instance(struct pci_dev *pdev) | |||
2940 | mci = find_mci_by_dev(&pdev->dev); | 2916 | mci = find_mci_by_dev(&pdev->dev); |
2941 | WARN_ON(!mci); | 2917 | WARN_ON(!mci); |
2942 | 2918 | ||
2943 | del_mc_sysfs_attrs(mci); | ||
2944 | /* Remove from EDAC CORE tracking list */ | 2919 | /* Remove from EDAC CORE tracking list */ |
2945 | mci = edac_mc_del_mc(&pdev->dev); | 2920 | mci = edac_mc_del_mc(&pdev->dev); |
2946 | if (!mci) | 2921 | if (!mci) |