Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Vivien Didelot and committed by
Ingo Molnar
1d240875 1795cd9b

+20 -26
+20 -26
arch/x86/platform/ts5500/ts5500.c
··· 147 147 return ret; 148 148 } 149 149 150 - static ssize_t ts5500_show_id(struct device *dev, 151 - struct device_attribute *attr, char *buf) 150 + static ssize_t id_show(struct device *dev, struct device_attribute *attr, 151 + char *buf) 152 152 { 153 153 struct ts5500_sbc *sbc = dev_get_drvdata(dev); 154 154 155 155 return sprintf(buf, "0x%.2x\n", sbc->id); 156 156 } 157 + static DEVICE_ATTR_RO(id); 157 158 158 - static ssize_t ts5500_show_jumpers(struct device *dev, 159 - struct device_attribute *attr, 160 - char *buf) 159 + static ssize_t jumpers_show(struct device *dev, struct device_attribute *attr, 160 + char *buf) 161 161 { 162 162 struct ts5500_sbc *sbc = dev_get_drvdata(dev); 163 163 164 164 return sprintf(buf, "0x%.2x\n", sbc->jumpers >> 1); 165 165 } 166 + static DEVICE_ATTR_RO(jumpers); 166 167 167 - #define TS5500_SHOW(field) \ 168 - static ssize_t ts5500_show_##field(struct device *dev, \ 169 - struct device_attribute *attr, \ 170 - char *buf) \ 171 - { \ 172 - struct ts5500_sbc *sbc = dev_get_drvdata(dev); \ 173 - return sprintf(buf, "%d\n", sbc->field); \ 174 - } 168 + #define TS5500_ATTR_BOOL(_field) \ 169 + static ssize_t _field##_show(struct device *dev, \ 170 + struct device_attribute *attr, char *buf) \ 171 + { \ 172 + struct ts5500_sbc *sbc = dev_get_drvdata(dev); \ 173 + \ 174 + return sprintf(buf, "%d\n", sbc->_field); \ 175 + } \ 176 + static DEVICE_ATTR_RO(_field) 175 177 176 - TS5500_SHOW(sram) 177 - TS5500_SHOW(rs485) 178 - TS5500_SHOW(adc) 179 - TS5500_SHOW(ereset) 180 - TS5500_SHOW(itr) 181 - 182 - static DEVICE_ATTR(id, S_IRUGO, ts5500_show_id, NULL); 183 - static DEVICE_ATTR(jumpers, S_IRUGO, ts5500_show_jumpers, NULL); 184 - static DEVICE_ATTR(sram, S_IRUGO, ts5500_show_sram, NULL); 185 - static DEVICE_ATTR(rs485, S_IRUGO, ts5500_show_rs485, NULL); 186 - static DEVICE_ATTR(adc, S_IRUGO, ts5500_show_adc, NULL); 187 - static DEVICE_ATTR(ereset, S_IRUGO, ts5500_show_ereset, NULL); 188 - static DEVICE_ATTR(itr, S_IRUGO, ts5500_show_itr, NULL); 178 + TS5500_ATTR_BOOL(sram); 179 + TS5500_ATTR_BOOL(rs485); 180 + TS5500_ATTR_BOOL(adc); 181 + TS5500_ATTR_BOOL(ereset); 182 + TS5500_ATTR_BOOL(itr); 189 183 190 184 static struct attribute *ts5500_attributes[] = { 191 185 &dev_attr_id.attr,