diff options
author | Guenter Roeck <linux@roeck-us.net> | 2018-12-10 17:02:19 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2019-02-18 17:23:29 -0500 |
commit | e3a0ee1a8f3d5b404056cb969af9ba5b7ceccf95 (patch) | |
tree | 4f6513825f266948332c2c274e38e17b90d37bd9 /drivers/hwmon | |
parent | 86b9f565002954d32983f424a795f070ec6f6bbf (diff) |
hwmon: (powr1220) Use permission specific SENSOR[_DEVICE]_ATTR variants
Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code,
to improve readability, and to reduce the chance of inconsistencies.
Also replace any remaining S_<PERMS> in the driver with octal values.
The conversion was done automatically with coccinelle. The semantic patches
and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches/hwmon/.
This patch does not introduce functional changes. It was verified by
compiling the old and new files and comparing text and data sizes.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/powr1220.c | 144 |
1 files changed, 52 insertions, 92 deletions
diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c index 3014e4ac741e..16c1c98e0e18 100644 --- a/drivers/hwmon/powr1220.c +++ b/drivers/hwmon/powr1220.c | |||
@@ -177,8 +177,9 @@ exit: | |||
177 | } | 177 | } |
178 | 178 | ||
179 | /* Shows the voltage associated with the specified ADC channel */ | 179 | /* Shows the voltage associated with the specified ADC channel */ |
180 | static ssize_t powr1220_show_voltage(struct device *dev, | 180 | static ssize_t powr1220_voltage_show(struct device *dev, |
181 | struct device_attribute *dev_attr, char *buf) | 181 | struct device_attribute *dev_attr, |
182 | char *buf) | ||
182 | { | 183 | { |
183 | struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); | 184 | struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); |
184 | int adc_val = powr1220_read_adc(dev, attr->index); | 185 | int adc_val = powr1220_read_adc(dev, attr->index); |
@@ -190,8 +191,8 @@ static ssize_t powr1220_show_voltage(struct device *dev, | |||
190 | } | 191 | } |
191 | 192 | ||
192 | /* Shows the maximum setting associated with the specified ADC channel */ | 193 | /* Shows the maximum setting associated with the specified ADC channel */ |
193 | static ssize_t powr1220_show_max(struct device *dev, | 194 | static ssize_t powr1220_max_show(struct device *dev, |
194 | struct device_attribute *dev_attr, char *buf) | 195 | struct device_attribute *dev_attr, char *buf) |
195 | { | 196 | { |
196 | struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); | 197 | struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); |
197 | struct powr1220_data *data = dev_get_drvdata(dev); | 198 | struct powr1220_data *data = dev_get_drvdata(dev); |
@@ -200,100 +201,59 @@ static ssize_t powr1220_show_max(struct device *dev, | |||
200 | } | 201 | } |
201 | 202 | ||
202 | /* Shows the label associated with the specified ADC channel */ | 203 | /* Shows the label associated with the specified ADC channel */ |
203 | static ssize_t powr1220_show_label(struct device *dev, | 204 | static ssize_t powr1220_label_show(struct device *dev, |
204 | struct device_attribute *dev_attr, char *buf) | 205 | struct device_attribute *dev_attr, |
206 | char *buf) | ||
205 | { | 207 | { |
206 | struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); | 208 | struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); |
207 | 209 | ||
208 | return sprintf(buf, "%s\n", input_names[attr->index]); | 210 | return sprintf(buf, "%s\n", input_names[attr->index]); |
209 | } | 211 | } |
210 | 212 | ||
211 | static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, powr1220_show_voltage, NULL, | 213 | static SENSOR_DEVICE_ATTR_RO(in0_input, powr1220_voltage, VMON1); |
212 | VMON1); | 214 | static SENSOR_DEVICE_ATTR_RO(in1_input, powr1220_voltage, VMON2); |
213 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, powr1220_show_voltage, NULL, | 215 | static SENSOR_DEVICE_ATTR_RO(in2_input, powr1220_voltage, VMON3); |
214 | VMON2); | 216 | static SENSOR_DEVICE_ATTR_RO(in3_input, powr1220_voltage, VMON4); |
215 | static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, powr1220_show_voltage, NULL, | 217 | static SENSOR_DEVICE_ATTR_RO(in4_input, powr1220_voltage, VMON5); |
216 | VMON3); | 218 | static SENSOR_DEVICE_ATTR_RO(in5_input, powr1220_voltage, VMON6); |
217 | static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, powr1220_show_voltage, NULL, | 219 | static SENSOR_DEVICE_ATTR_RO(in6_input, powr1220_voltage, VMON7); |
218 | VMON4); | 220 | static SENSOR_DEVICE_ATTR_RO(in7_input, powr1220_voltage, VMON8); |
219 | static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, powr1220_show_voltage, NULL, | 221 | static SENSOR_DEVICE_ATTR_RO(in8_input, powr1220_voltage, VMON9); |
220 | VMON5); | 222 | static SENSOR_DEVICE_ATTR_RO(in9_input, powr1220_voltage, VMON10); |
221 | static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, powr1220_show_voltage, NULL, | 223 | static SENSOR_DEVICE_ATTR_RO(in10_input, powr1220_voltage, VMON11); |
222 | VMON6); | 224 | static SENSOR_DEVICE_ATTR_RO(in11_input, powr1220_voltage, VMON12); |
223 | static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, powr1220_show_voltage, NULL, | 225 | static SENSOR_DEVICE_ATTR_RO(in12_input, powr1220_voltage, VCCA); |
224 | VMON7); | 226 | static SENSOR_DEVICE_ATTR_RO(in13_input, powr1220_voltage, VCCINP); |
225 | static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, powr1220_show_voltage, NULL, | 227 | |
226 | VMON8); | 228 | static SENSOR_DEVICE_ATTR_RO(in0_highest, powr1220_max, VMON1); |
227 | static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, powr1220_show_voltage, NULL, | 229 | static SENSOR_DEVICE_ATTR_RO(in1_highest, powr1220_max, VMON2); |
228 | VMON9); | 230 | static SENSOR_DEVICE_ATTR_RO(in2_highest, powr1220_max, VMON3); |
229 | static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, powr1220_show_voltage, NULL, | 231 | static SENSOR_DEVICE_ATTR_RO(in3_highest, powr1220_max, VMON4); |
230 | VMON10); | 232 | static SENSOR_DEVICE_ATTR_RO(in4_highest, powr1220_max, VMON5); |
231 | static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, powr1220_show_voltage, NULL, | 233 | static SENSOR_DEVICE_ATTR_RO(in5_highest, powr1220_max, VMON6); |
232 | VMON11); | 234 | static SENSOR_DEVICE_ATTR_RO(in6_highest, powr1220_max, VMON7); |
233 | static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, powr1220_show_voltage, NULL, | 235 | static SENSOR_DEVICE_ATTR_RO(in7_highest, powr1220_max, VMON8); |
234 | VMON12); | 236 | static SENSOR_DEVICE_ATTR_RO(in8_highest, powr1220_max, VMON9); |
235 | static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, powr1220_show_voltage, NULL, | 237 | static SENSOR_DEVICE_ATTR_RO(in9_highest, powr1220_max, VMON10); |
236 | VCCA); | 238 | static SENSOR_DEVICE_ATTR_RO(in10_highest, powr1220_max, VMON11); |
237 | static SENSOR_DEVICE_ATTR(in13_input, S_IRUGO, powr1220_show_voltage, NULL, | 239 | static SENSOR_DEVICE_ATTR_RO(in11_highest, powr1220_max, VMON12); |
238 | VCCINP); | 240 | static SENSOR_DEVICE_ATTR_RO(in12_highest, powr1220_max, VCCA); |
239 | 241 | static SENSOR_DEVICE_ATTR_RO(in13_highest, powr1220_max, VCCINP); | |
240 | static SENSOR_DEVICE_ATTR(in0_highest, S_IRUGO, powr1220_show_max, NULL, | 242 | |
241 | VMON1); | 243 | static SENSOR_DEVICE_ATTR_RO(in0_label, powr1220_label, VMON1); |
242 | static SENSOR_DEVICE_ATTR(in1_highest, S_IRUGO, powr1220_show_max, NULL, | 244 | static SENSOR_DEVICE_ATTR_RO(in1_label, powr1220_label, VMON2); |
243 | VMON2); | 245 | static SENSOR_DEVICE_ATTR_RO(in2_label, powr1220_label, VMON3); |
244 | static SENSOR_DEVICE_ATTR(in2_highest, S_IRUGO, powr1220_show_max, NULL, | 246 | static SENSOR_DEVICE_ATTR_RO(in3_label, powr1220_label, VMON4); |
245 | VMON3); | 247 | static SENSOR_DEVICE_ATTR_RO(in4_label, powr1220_label, VMON5); |
246 | static SENSOR_DEVICE_ATTR(in3_highest, S_IRUGO, powr1220_show_max, NULL, | 248 | static SENSOR_DEVICE_ATTR_RO(in5_label, powr1220_label, VMON6); |
247 | VMON4); | 249 | static SENSOR_DEVICE_ATTR_RO(in6_label, powr1220_label, VMON7); |
248 | static SENSOR_DEVICE_ATTR(in4_highest, S_IRUGO, powr1220_show_max, NULL, | 250 | static SENSOR_DEVICE_ATTR_RO(in7_label, powr1220_label, VMON8); |
249 | VMON5); | 251 | static SENSOR_DEVICE_ATTR_RO(in8_label, powr1220_label, VMON9); |
250 | static SENSOR_DEVICE_ATTR(in5_highest, S_IRUGO, powr1220_show_max, NULL, | 252 | static SENSOR_DEVICE_ATTR_RO(in9_label, powr1220_label, VMON10); |
251 | VMON6); | 253 | static SENSOR_DEVICE_ATTR_RO(in10_label, powr1220_label, VMON11); |
252 | static SENSOR_DEVICE_ATTR(in6_highest, S_IRUGO, powr1220_show_max, NULL, | 254 | static SENSOR_DEVICE_ATTR_RO(in11_label, powr1220_label, VMON12); |
253 | VMON7); | 255 | static SENSOR_DEVICE_ATTR_RO(in12_label, powr1220_label, VCCA); |
254 | static SENSOR_DEVICE_ATTR(in7_highest, S_IRUGO, powr1220_show_max, NULL, | 256 | static SENSOR_DEVICE_ATTR_RO(in13_label, powr1220_label, VCCINP); |
255 | VMON8); | ||
256 | static SENSOR_DEVICE_ATTR(in8_highest, S_IRUGO, powr1220_show_max, NULL, | ||
257 | VMON9); | ||
258 | static SENSOR_DEVICE_ATTR(in9_highest, S_IRUGO, powr1220_show_max, NULL, | ||
259 | VMON10); | ||
260 | static SENSOR_DEVICE_ATTR(in10_highest, S_IRUGO, powr1220_show_max, NULL, | ||
261 | VMON11); | ||
262 | static SENSOR_DEVICE_ATTR(in11_highest, S_IRUGO, powr1220_show_max, NULL, | ||
263 | VMON12); | ||
264 | static SENSOR_DEVICE_ATTR(in12_highest, S_IRUGO, powr1220_show_max, NULL, | ||
265 | VCCA); | ||
266 | static SENSOR_DEVICE_ATTR(in13_highest, S_IRUGO, powr1220_show_max, NULL, | ||
267 | VCCINP); | ||
268 | |||
269 | static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, powr1220_show_label, NULL, | ||
270 | VMON1); | ||
271 | static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, powr1220_show_label, NULL, | ||
272 | VMON2); | ||
273 | static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, powr1220_show_label, NULL, | ||
274 | VMON3); | ||
275 | static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, powr1220_show_label, NULL, | ||
276 | VMON4); | ||
277 | static SENSOR_DEVICE_ATTR(in4_label, S_IRUGO, powr1220_show_label, NULL, | ||
278 | VMON5); | ||
279 | static SENSOR_DEVICE_ATTR(in5_label, S_IRUGO, powr1220_show_label, NULL, | ||
280 | VMON6); | ||
281 | static SENSOR_DEVICE_ATTR(in6_label, S_IRUGO, powr1220_show_label, NULL, | ||
282 | VMON7); | ||
283 | static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, powr1220_show_label, NULL, | ||
284 | VMON8); | ||
285 | static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, powr1220_show_label, NULL, | ||
286 | VMON9); | ||
287 | static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, powr1220_show_label, NULL, | ||
288 | VMON10); | ||
289 | static SENSOR_DEVICE_ATTR(in10_label, S_IRUGO, powr1220_show_label, NULL, | ||
290 | VMON11); | ||
291 | static SENSOR_DEVICE_ATTR(in11_label, S_IRUGO, powr1220_show_label, NULL, | ||
292 | VMON12); | ||
293 | static SENSOR_DEVICE_ATTR(in12_label, S_IRUGO, powr1220_show_label, NULL, | ||
294 | VCCA); | ||
295 | static SENSOR_DEVICE_ATTR(in13_label, S_IRUGO, powr1220_show_label, NULL, | ||
296 | VCCINP); | ||
297 | 257 | ||
298 | static struct attribute *powr1220_attrs[] = { | 258 | static struct attribute *powr1220_attrs[] = { |
299 | &sensor_dev_attr_in0_input.dev_attr.attr, | 259 | &sensor_dev_attr_in0_input.dev_attr.attr, |