diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-02-19 06:04:55 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-02-21 09:06:31 -0500 |
commit | e7100478fa894c45ae33321b5721b5a8f956b814 (patch) | |
tree | b7a7b9b8c723d3bbd09bc92b349a417d1f8814b9 /drivers/edac | |
parent | 61734e1835867e6e38438c8365149748641e3525 (diff) |
edac: only create sdram_scrub_rate where supported
Currently, sdram_scrub_rate sysfs node is created even if the device
doesn't support get/set the scub rate. Change the logic to only
create this device node when the operation is supported.
Reported-by: Felipe Balbi <balbi@ti.com>
Acked-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/edac')
-rw-r--r-- | drivers/edac/edac_mc_sysfs.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c index 0ca1ca71157f..963a91edb259 100644 --- a/drivers/edac/edac_mc_sysfs.c +++ b/drivers/edac/edac_mc_sysfs.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * Written Doug Thompson <norsk5@xmission.com> www.softwarebitmaker.com | 8 | * Written Doug Thompson <norsk5@xmission.com> www.softwarebitmaker.com |
9 | * | 9 | * |
10 | * (c) 2012 - Mauro Carvalho Chehab <mchehab@redhat.com> | 10 | * (c) 2012-2013 - Mauro Carvalho Chehab <mchehab@redhat.com> |
11 | * The entire API were re-written, and ported to use struct device | 11 | * The entire API were re-written, and ported to use struct device |
12 | * | 12 | * |
13 | */ | 13 | */ |
@@ -677,9 +677,6 @@ static ssize_t mci_sdram_scrub_rate_store(struct device *dev, | |||
677 | unsigned long bandwidth = 0; | 677 | unsigned long bandwidth = 0; |
678 | int new_bw = 0; | 678 | int new_bw = 0; |
679 | 679 | ||
680 | if (!mci->set_sdram_scrub_rate) | ||
681 | return -ENODEV; | ||
682 | |||
683 | if (strict_strtoul(data, 10, &bandwidth) < 0) | 680 | if (strict_strtoul(data, 10, &bandwidth) < 0) |
684 | return -EINVAL; | 681 | return -EINVAL; |
685 | 682 | ||
@@ -703,9 +700,6 @@ static ssize_t mci_sdram_scrub_rate_show(struct device *dev, | |||
703 | struct mem_ctl_info *mci = to_mci(dev); | 700 | struct mem_ctl_info *mci = to_mci(dev); |
704 | int bandwidth = 0; | 701 | int bandwidth = 0; |
705 | 702 | ||
706 | if (!mci->get_sdram_scrub_rate) | ||
707 | return -ENODEV; | ||
708 | |||
709 | bandwidth = mci->get_sdram_scrub_rate(mci); | 703 | bandwidth = mci->get_sdram_scrub_rate(mci); |
710 | if (bandwidth < 0) { | 704 | if (bandwidth < 0) { |
711 | edac_printk(KERN_DEBUG, EDAC_MC, "Error reading scrub rate\n"); | 705 | edac_printk(KERN_DEBUG, EDAC_MC, "Error reading scrub rate\n"); |
@@ -866,8 +860,7 @@ DEVICE_ATTR(ce_count, S_IRUGO, mci_ce_count_show, NULL); | |||
866 | DEVICE_ATTR(max_location, S_IRUGO, mci_max_location_show, NULL); | 860 | DEVICE_ATTR(max_location, S_IRUGO, mci_max_location_show, NULL); |
867 | 861 | ||
868 | /* memory scrubber attribute file */ | 862 | /* memory scrubber attribute file */ |
869 | DEVICE_ATTR(sdram_scrub_rate, S_IRUGO | S_IWUSR, mci_sdram_scrub_rate_show, | 863 | DEVICE_ATTR(sdram_scrub_rate, 0, NULL, NULL); |
870 | mci_sdram_scrub_rate_store); | ||
871 | 864 | ||
872 | static struct attribute *mci_attrs[] = { | 865 | static struct attribute *mci_attrs[] = { |
873 | &dev_attr_reset_counters.attr, | 866 | &dev_attr_reset_counters.attr, |
@@ -878,7 +871,6 @@ static struct attribute *mci_attrs[] = { | |||
878 | &dev_attr_ce_noinfo_count.attr, | 871 | &dev_attr_ce_noinfo_count.attr, |
879 | &dev_attr_ue_count.attr, | 872 | &dev_attr_ue_count.attr, |
880 | &dev_attr_ce_count.attr, | 873 | &dev_attr_ce_count.attr, |
881 | &dev_attr_sdram_scrub_rate.attr, | ||
882 | &dev_attr_max_location.attr, | 874 | &dev_attr_max_location.attr, |
883 | NULL | 875 | NULL |
884 | }; | 876 | }; |
@@ -1012,6 +1004,22 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) | |||
1012 | return err; | 1004 | return err; |
1013 | } | 1005 | } |
1014 | 1006 | ||
1007 | if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) { | ||
1008 | if (mci->get_sdram_scrub_rate) { | ||
1009 | dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO; | ||
1010 | dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show; | ||
1011 | } | ||
1012 | if (mci->set_sdram_scrub_rate) { | ||
1013 | dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR; | ||
1014 | dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store; | ||
1015 | } | ||
1016 | err = device_create_file(&mci->dev, | ||
1017 | &dev_attr_sdram_scrub_rate); | ||
1018 | if (err) { | ||
1019 | edac_dbg(1, "failure: create sdram_scrub_rate\n"); | ||
1020 | goto fail2; | ||
1021 | } | ||
1022 | } | ||
1015 | /* | 1023 | /* |
1016 | * Create the dimm/rank devices | 1024 | * Create the dimm/rank devices |
1017 | */ | 1025 | */ |
@@ -1056,6 +1064,7 @@ fail: | |||
1056 | continue; | 1064 | continue; |
1057 | device_unregister(&dimm->dev); | 1065 | device_unregister(&dimm->dev); |
1058 | } | 1066 | } |
1067 | fail2: | ||
1059 | device_unregister(&mci->dev); | 1068 | device_unregister(&mci->dev); |
1060 | bus_unregister(&mci->bus); | 1069 | bus_unregister(&mci->bus); |
1061 | kfree(mci->bus.name); | 1070 | kfree(mci->bus.name); |