diff options
author | Andi Kleen <andi@firstfloor.org> | 2009-05-27 15:56:52 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-05-28 12:24:15 -0400 |
commit | b56f642d2bf8c1f7c6499c1e55b23311a33cc796 (patch) | |
tree | 1bb766756da14454a027565c14914999b1a16191 /arch/x86 | |
parent | 88921be30296e126896ee4d30758f989d1c4ddfb (diff) |
x86, mce: use extended sysattrs for the check_interval attribute.
Instead of using own callbacks use the generic ones provided by
the sysdev later.
This finally allows to get rid of the ugly ACCESSOR macros. Should
also save some text size.
[ Impact: cleanup ]
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/cpu/mcheck/mce.c | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index 495c96808668..3cac9da7ce24 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c | |||
@@ -1054,28 +1054,6 @@ DEFINE_PER_CPU(struct sys_device, mce_dev); | |||
1054 | __cpuinitdata | 1054 | __cpuinitdata |
1055 | void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu); | 1055 | void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu); |
1056 | 1056 | ||
1057 | /* Why are there no generic functions for this? */ | ||
1058 | #define ACCESSOR(name, var, start) \ | ||
1059 | static ssize_t show_ ## name(struct sys_device *s, \ | ||
1060 | struct sysdev_attribute *attr, \ | ||
1061 | char *buf) { \ | ||
1062 | return sprintf(buf, "%Lx\n", (u64)var); \ | ||
1063 | } \ | ||
1064 | static ssize_t set_ ## name(struct sys_device *s, \ | ||
1065 | struct sysdev_attribute *attr, \ | ||
1066 | const char *buf, size_t siz) { \ | ||
1067 | char *end; \ | ||
1068 | u64 new = simple_strtoull(buf, &end, 0); \ | ||
1069 | \ | ||
1070 | if (end == buf) \ | ||
1071 | return -EINVAL; \ | ||
1072 | var = new; \ | ||
1073 | start; \ | ||
1074 | \ | ||
1075 | return end-buf; \ | ||
1076 | } \ | ||
1077 | static SYSDEV_ATTR(name, 0644, show_ ## name, set_ ## name); | ||
1078 | |||
1079 | static struct sysdev_attribute *bank_attrs; | 1057 | static struct sysdev_attribute *bank_attrs; |
1080 | 1058 | ||
1081 | static ssize_t show_bank(struct sys_device *s, struct sysdev_attribute *attr, | 1059 | static ssize_t show_bank(struct sys_device *s, struct sysdev_attribute *attr, |
@@ -1126,13 +1104,26 @@ static ssize_t set_trigger(struct sys_device *s, struct sysdev_attribute *attr, | |||
1126 | return len; | 1104 | return len; |
1127 | } | 1105 | } |
1128 | 1106 | ||
1107 | static ssize_t store_int_with_restart(struct sys_device *s, | ||
1108 | struct sysdev_attribute *attr, | ||
1109 | const char *buf, size_t size) | ||
1110 | { | ||
1111 | ssize_t ret = sysdev_store_int(s, attr, buf, size); | ||
1112 | mce_restart(); | ||
1113 | return ret; | ||
1114 | } | ||
1115 | |||
1129 | static SYSDEV_ATTR(trigger, 0644, show_trigger, set_trigger); | 1116 | static SYSDEV_ATTR(trigger, 0644, show_trigger, set_trigger); |
1130 | static SYSDEV_INT_ATTR(tolerant, 0644, tolerant); | 1117 | static SYSDEV_INT_ATTR(tolerant, 0644, tolerant); |
1131 | 1118 | ||
1132 | ACCESSOR(check_interval, check_interval, mce_restart()) | 1119 | static struct sysdev_ext_attribute attr_check_interval = { |
1120 | _SYSDEV_ATTR(check_interval, 0644, sysdev_show_int, | ||
1121 | store_int_with_restart), | ||
1122 | &check_interval | ||
1123 | }; | ||
1133 | 1124 | ||
1134 | static struct sysdev_attribute *mce_attrs[] = { | 1125 | static struct sysdev_attribute *mce_attrs[] = { |
1135 | &attr_tolerant.attr, &attr_check_interval, &attr_trigger, | 1126 | &attr_tolerant.attr, &attr_check_interval.attr, &attr_trigger, |
1136 | NULL | 1127 | NULL |
1137 | }; | 1128 | }; |
1138 | 1129 | ||