diff options
Diffstat (limited to 'drivers/edac/edac_mc_sysfs.c')
-rw-r--r-- | drivers/edac/edac_mc_sysfs.c | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 670d2829c547..c84eecb191ef 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c | |||
@@ -157,7 +157,7 @@ struct dev_ch_attribute { | |||
157 | }; | 157 | }; |
158 | 158 | ||
159 | #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \ | 159 | #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \ |
160 | struct dev_ch_attribute dev_attr_legacy_##_name = \ | 160 | static struct dev_ch_attribute dev_attr_legacy_##_name = \ |
161 | { __ATTR(_name, _mode, _show, _store), (_var) } | 161 | { __ATTR(_name, _mode, _show, _store), (_var) } |
162 | 162 | ||
163 | #define to_channel(k) (container_of(k, struct dev_ch_attribute, attr)->channel) | 163 | #define to_channel(k) (container_of(k, struct dev_ch_attribute, attr)->channel) |
@@ -850,20 +850,20 @@ static const struct file_operations debug_fake_inject_fops = { | |||
850 | #endif | 850 | #endif |
851 | 851 | ||
852 | /* default Control file */ | 852 | /* default Control file */ |
853 | DEVICE_ATTR(reset_counters, S_IWUSR, NULL, mci_reset_counters_store); | 853 | static DEVICE_ATTR(reset_counters, S_IWUSR, NULL, mci_reset_counters_store); |
854 | 854 | ||
855 | /* default Attribute files */ | 855 | /* default Attribute files */ |
856 | DEVICE_ATTR(mc_name, S_IRUGO, mci_ctl_name_show, NULL); | 856 | static DEVICE_ATTR(mc_name, S_IRUGO, mci_ctl_name_show, NULL); |
857 | DEVICE_ATTR(size_mb, S_IRUGO, mci_size_mb_show, NULL); | 857 | static DEVICE_ATTR(size_mb, S_IRUGO, mci_size_mb_show, NULL); |
858 | DEVICE_ATTR(seconds_since_reset, S_IRUGO, mci_seconds_show, NULL); | 858 | static DEVICE_ATTR(seconds_since_reset, S_IRUGO, mci_seconds_show, NULL); |
859 | DEVICE_ATTR(ue_noinfo_count, S_IRUGO, mci_ue_noinfo_show, NULL); | 859 | static DEVICE_ATTR(ue_noinfo_count, S_IRUGO, mci_ue_noinfo_show, NULL); |
860 | DEVICE_ATTR(ce_noinfo_count, S_IRUGO, mci_ce_noinfo_show, NULL); | 860 | static DEVICE_ATTR(ce_noinfo_count, S_IRUGO, mci_ce_noinfo_show, NULL); |
861 | DEVICE_ATTR(ue_count, S_IRUGO, mci_ue_count_show, NULL); | 861 | static DEVICE_ATTR(ue_count, S_IRUGO, mci_ue_count_show, NULL); |
862 | DEVICE_ATTR(ce_count, S_IRUGO, mci_ce_count_show, NULL); | 862 | static DEVICE_ATTR(ce_count, S_IRUGO, mci_ce_count_show, NULL); |
863 | DEVICE_ATTR(max_location, S_IRUGO, mci_max_location_show, NULL); | 863 | static DEVICE_ATTR(max_location, S_IRUGO, mci_max_location_show, NULL); |
864 | 864 | ||
865 | /* memory scrubber attribute file */ | 865 | /* memory scrubber attribute file */ |
866 | DEVICE_ATTR(sdram_scrub_rate, 0, NULL, NULL); | 866 | static DEVICE_ATTR(sdram_scrub_rate, 0, NULL, NULL); |
867 | 867 | ||
868 | static struct attribute *mci_attrs[] = { | 868 | static struct attribute *mci_attrs[] = { |
869 | &dev_attr_reset_counters.attr, | 869 | &dev_attr_reset_counters.attr, |
@@ -989,7 +989,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) | |||
989 | 989 | ||
990 | err = bus_register(mci->bus); | 990 | err = bus_register(mci->bus); |
991 | if (err < 0) | 991 | if (err < 0) |
992 | return err; | 992 | goto fail_free_name; |
993 | 993 | ||
994 | /* get the /sys/devices/system/edac subsys reference */ | 994 | /* get the /sys/devices/system/edac subsys reference */ |
995 | mci->dev.type = &mci_attr_type; | 995 | mci->dev.type = &mci_attr_type; |
@@ -1005,9 +1005,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) | |||
1005 | err = device_add(&mci->dev); | 1005 | err = device_add(&mci->dev); |
1006 | if (err < 0) { | 1006 | if (err < 0) { |
1007 | edac_dbg(1, "failure: create device %s\n", dev_name(&mci->dev)); | 1007 | edac_dbg(1, "failure: create device %s\n", dev_name(&mci->dev)); |
1008 | bus_unregister(mci->bus); | 1008 | goto fail_unregister_bus; |
1009 | kfree(mci->bus->name); | ||
1010 | return err; | ||
1011 | } | 1009 | } |
1012 | 1010 | ||
1013 | if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) { | 1011 | if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) { |
@@ -1015,15 +1013,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) | |||
1015 | dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO; | 1013 | dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO; |
1016 | dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show; | 1014 | dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show; |
1017 | } | 1015 | } |
1016 | |||
1018 | if (mci->set_sdram_scrub_rate) { | 1017 | if (mci->set_sdram_scrub_rate) { |
1019 | dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR; | 1018 | dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR; |
1020 | dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store; | 1019 | dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store; |
1021 | } | 1020 | } |
1022 | err = device_create_file(&mci->dev, | 1021 | |
1023 | &dev_attr_sdram_scrub_rate); | 1022 | err = device_create_file(&mci->dev, &dev_attr_sdram_scrub_rate); |
1024 | if (err) { | 1023 | if (err) { |
1025 | edac_dbg(1, "failure: create sdram_scrub_rate\n"); | 1024 | edac_dbg(1, "failure: create sdram_scrub_rate\n"); |
1026 | goto fail2; | 1025 | goto fail_unregister_dev; |
1027 | } | 1026 | } |
1028 | } | 1027 | } |
1029 | /* | 1028 | /* |
@@ -1032,8 +1031,9 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) | |||
1032 | for (i = 0; i < mci->tot_dimms; i++) { | 1031 | for (i = 0; i < mci->tot_dimms; i++) { |
1033 | struct dimm_info *dimm = mci->dimms[i]; | 1032 | struct dimm_info *dimm = mci->dimms[i]; |
1034 | /* Only expose populated DIMMs */ | 1033 | /* Only expose populated DIMMs */ |
1035 | if (dimm->nr_pages == 0) | 1034 | if (!dimm->nr_pages) |
1036 | continue; | 1035 | continue; |
1036 | |||
1037 | #ifdef CONFIG_EDAC_DEBUG | 1037 | #ifdef CONFIG_EDAC_DEBUG |
1038 | edac_dbg(1, "creating dimm%d, located at ", i); | 1038 | edac_dbg(1, "creating dimm%d, located at ", i); |
1039 | if (edac_debug_level >= 1) { | 1039 | if (edac_debug_level >= 1) { |
@@ -1048,14 +1048,14 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) | |||
1048 | err = edac_create_dimm_object(mci, dimm, i); | 1048 | err = edac_create_dimm_object(mci, dimm, i); |
1049 | if (err) { | 1049 | if (err) { |
1050 | edac_dbg(1, "failure: create dimm %d obj\n", i); | 1050 | edac_dbg(1, "failure: create dimm %d obj\n", i); |
1051 | goto fail; | 1051 | goto fail_unregister_dimm; |
1052 | } | 1052 | } |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | #ifdef CONFIG_EDAC_LEGACY_SYSFS | 1055 | #ifdef CONFIG_EDAC_LEGACY_SYSFS |
1056 | err = edac_create_csrow_objects(mci); | 1056 | err = edac_create_csrow_objects(mci); |
1057 | if (err < 0) | 1057 | if (err < 0) |
1058 | goto fail; | 1058 | goto fail_unregister_dimm; |
1059 | #endif | 1059 | #endif |
1060 | 1060 | ||
1061 | #ifdef CONFIG_EDAC_DEBUG | 1061 | #ifdef CONFIG_EDAC_DEBUG |
@@ -1063,16 +1063,19 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) | |||
1063 | #endif | 1063 | #endif |
1064 | return 0; | 1064 | return 0; |
1065 | 1065 | ||
1066 | fail: | 1066 | fail_unregister_dimm: |
1067 | for (i--; i >= 0; i--) { | 1067 | for (i--; i >= 0; i--) { |
1068 | struct dimm_info *dimm = mci->dimms[i]; | 1068 | struct dimm_info *dimm = mci->dimms[i]; |
1069 | if (dimm->nr_pages == 0) | 1069 | if (!dimm->nr_pages) |
1070 | continue; | 1070 | continue; |
1071 | |||
1071 | device_unregister(&dimm->dev); | 1072 | device_unregister(&dimm->dev); |
1072 | } | 1073 | } |
1073 | fail2: | 1074 | fail_unregister_dev: |
1074 | device_unregister(&mci->dev); | 1075 | device_unregister(&mci->dev); |
1076 | fail_unregister_bus: | ||
1075 | bus_unregister(mci->bus); | 1077 | bus_unregister(mci->bus); |
1078 | fail_free_name: | ||
1076 | kfree(mci->bus->name); | 1079 | kfree(mci->bus->name); |
1077 | return err; | 1080 | return err; |
1078 | } | 1081 | } |