aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVivien Didelot <vivien.didelot@savoirfairelinux.com>2014-07-08 18:57:47 -0400
committerIngo Molnar <mingo@kernel.org>2014-07-16 15:17:40 -0400
commit1d2408754d2c1376d67c00852548758e1ec2a94c (patch)
tree3972d0cd4f87c8fe937ea86ac9b677f9dbc9d4d6
parent1795cd9b3a91d4b5473c97f491d63892442212ab (diff)
x86/platform/ts5500: Use the DEVICE_ATTR_RO() macro
Use the DEVICE_ATTR_RO() helper macro to simplify the declaration of read-only sysfs attributes in the TS5500 code.. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Acked-by: Thomas Gleixner <tglx@linutronix.de> Cc: Savoir-faire Linux Inc. <kernel@savoirfairelinux.com> Link: http://lkml.kernel.org/r/1404860269-11837-2-git-send-email-vivien.didelot@savoirfairelinux.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/platform/ts5500/ts5500.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/arch/x86/platform/ts5500/ts5500.c b/arch/x86/platform/ts5500/ts5500.c
index 9471b9456f25..1bbf17bdb0cf 100644
--- a/arch/x86/platform/ts5500/ts5500.c
+++ b/arch/x86/platform/ts5500/ts5500.c
@@ -147,45 +147,39 @@ cleanup:
147 return ret; 147 return ret;
148} 148}
149 149
150static ssize_t ts5500_show_id(struct device *dev, 150static ssize_t id_show(struct device *dev, struct device_attribute *attr,
151 struct device_attribute *attr, char *buf) 151 char *buf)
152{ 152{
153 struct ts5500_sbc *sbc = dev_get_drvdata(dev); 153 struct ts5500_sbc *sbc = dev_get_drvdata(dev);
154 154
155 return sprintf(buf, "0x%.2x\n", sbc->id); 155 return sprintf(buf, "0x%.2x\n", sbc->id);
156} 156}
157static DEVICE_ATTR_RO(id);
157 158
158static ssize_t ts5500_show_jumpers(struct device *dev, 159static ssize_t jumpers_show(struct device *dev, struct device_attribute *attr,
159 struct device_attribute *attr, 160 char *buf)
160 char *buf)
161{ 161{
162 struct ts5500_sbc *sbc = dev_get_drvdata(dev); 162 struct ts5500_sbc *sbc = dev_get_drvdata(dev);
163 163
164 return sprintf(buf, "0x%.2x\n", sbc->jumpers >> 1); 164 return sprintf(buf, "0x%.2x\n", sbc->jumpers >> 1);
165} 165}
166 166static DEVICE_ATTR_RO(jumpers);
167#define TS5500_SHOW(field) \ 167
168 static ssize_t ts5500_show_##field(struct device *dev, \ 168#define TS5500_ATTR_BOOL(_field) \
169 struct device_attribute *attr, \ 169 static ssize_t _field##_show(struct device *dev, \
170 char *buf) \ 170 struct device_attribute *attr, char *buf) \
171 { \ 171 { \
172 struct ts5500_sbc *sbc = dev_get_drvdata(dev); \ 172 struct ts5500_sbc *sbc = dev_get_drvdata(dev); \
173 return sprintf(buf, "%d\n", sbc->field); \ 173 \
174 } 174 return sprintf(buf, "%d\n", sbc->_field); \
175 175 } \
176TS5500_SHOW(sram) 176 static DEVICE_ATTR_RO(_field)
177TS5500_SHOW(rs485) 177
178TS5500_SHOW(adc) 178TS5500_ATTR_BOOL(sram);
179TS5500_SHOW(ereset) 179TS5500_ATTR_BOOL(rs485);
180TS5500_SHOW(itr) 180TS5500_ATTR_BOOL(adc);
181 181TS5500_ATTR_BOOL(ereset);
182static DEVICE_ATTR(id, S_IRUGO, ts5500_show_id, NULL); 182TS5500_ATTR_BOOL(itr);
183static DEVICE_ATTR(jumpers, S_IRUGO, ts5500_show_jumpers, NULL);
184static DEVICE_ATTR(sram, S_IRUGO, ts5500_show_sram, NULL);
185static DEVICE_ATTR(rs485, S_IRUGO, ts5500_show_rs485, NULL);
186static DEVICE_ATTR(adc, S_IRUGO, ts5500_show_adc, NULL);
187static DEVICE_ATTR(ereset, S_IRUGO, ts5500_show_ereset, NULL);
188static DEVICE_ATTR(itr, S_IRUGO, ts5500_show_itr, NULL);
189 183
190static struct attribute *ts5500_attributes[] = { 184static struct attribute *ts5500_attributes[] = {
191 &dev_attr_id.attr, 185 &dev_attr_id.attr,