diff options
author | Guenter Roeck <linux@roeck-us.net> | 2018-12-10 17:02:21 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2019-02-18 17:23:29 -0500 |
commit | 1acd2e295ec4fb65feb47d0631b45ad22e9b01eb (patch) | |
tree | 860e91c9f5dd712ec264f094586968d5a1cac72c /drivers/hwmon/tc654.c | |
parent | ecd52d7bb674001f58c9b6026f24c3a0e9ac8350 (diff) |
hwmon: (tc654) 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/tc654.c')
-rw-r--r-- | drivers/hwmon/tc654.c | 60 |
1 files changed, 27 insertions, 33 deletions
diff --git a/drivers/hwmon/tc654.c b/drivers/hwmon/tc654.c index 18136e1f95fd..81dd229d7db4 100644 --- a/drivers/hwmon/tc654.c +++ b/drivers/hwmon/tc654.c | |||
@@ -200,7 +200,7 @@ out: | |||
200 | * sysfs attributes | 200 | * sysfs attributes |
201 | */ | 201 | */ |
202 | 202 | ||
203 | static ssize_t show_fan(struct device *dev, struct device_attribute *da, | 203 | static ssize_t fan_show(struct device *dev, struct device_attribute *da, |
204 | char *buf) | 204 | char *buf) |
205 | { | 205 | { |
206 | int nr = to_sensor_dev_attr(da)->index; | 206 | int nr = to_sensor_dev_attr(da)->index; |
@@ -218,7 +218,7 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *da, | |||
218 | return sprintf(buf, "%d\n", val); | 218 | return sprintf(buf, "%d\n", val); |
219 | } | 219 | } |
220 | 220 | ||
221 | static ssize_t show_fan_min(struct device *dev, struct device_attribute *da, | 221 | static ssize_t fan_min_show(struct device *dev, struct device_attribute *da, |
222 | char *buf) | 222 | char *buf) |
223 | { | 223 | { |
224 | int nr = to_sensor_dev_attr(da)->index; | 224 | int nr = to_sensor_dev_attr(da)->index; |
@@ -231,8 +231,8 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute *da, | |||
231 | TC654_FAN_FAULT_FROM_REG(data->fan_fault[nr])); | 231 | TC654_FAN_FAULT_FROM_REG(data->fan_fault[nr])); |
232 | } | 232 | } |
233 | 233 | ||
234 | static ssize_t set_fan_min(struct device *dev, struct device_attribute *da, | 234 | static ssize_t fan_min_store(struct device *dev, struct device_attribute *da, |
235 | const char *buf, size_t count) | 235 | const char *buf, size_t count) |
236 | { | 236 | { |
237 | int nr = to_sensor_dev_attr(da)->index; | 237 | int nr = to_sensor_dev_attr(da)->index; |
238 | struct tc654_data *data = dev_get_drvdata(dev); | 238 | struct tc654_data *data = dev_get_drvdata(dev); |
@@ -255,7 +255,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *da, | |||
255 | return ret < 0 ? ret : count; | 255 | return ret < 0 ? ret : count; |
256 | } | 256 | } |
257 | 257 | ||
258 | static ssize_t show_fan_alarm(struct device *dev, struct device_attribute *da, | 258 | static ssize_t fan_alarm_show(struct device *dev, struct device_attribute *da, |
259 | char *buf) | 259 | char *buf) |
260 | { | 260 | { |
261 | int nr = to_sensor_dev_attr(da)->index; | 261 | int nr = to_sensor_dev_attr(da)->index; |
@@ -275,8 +275,8 @@ static ssize_t show_fan_alarm(struct device *dev, struct device_attribute *da, | |||
275 | 275 | ||
276 | static const u8 TC654_FAN_PULSE_SHIFT[] = { 1, 3 }; | 276 | static const u8 TC654_FAN_PULSE_SHIFT[] = { 1, 3 }; |
277 | 277 | ||
278 | static ssize_t show_fan_pulses(struct device *dev, struct device_attribute *da, | 278 | static ssize_t fan_pulses_show(struct device *dev, |
279 | char *buf) | 279 | struct device_attribute *da, char *buf) |
280 | { | 280 | { |
281 | int nr = to_sensor_dev_attr(da)->index; | 281 | int nr = to_sensor_dev_attr(da)->index; |
282 | struct tc654_data *data = tc654_update_client(dev); | 282 | struct tc654_data *data = tc654_update_client(dev); |
@@ -289,8 +289,9 @@ static ssize_t show_fan_pulses(struct device *dev, struct device_attribute *da, | |||
289 | return sprintf(buf, "%d\n", val); | 289 | return sprintf(buf, "%d\n", val); |
290 | } | 290 | } |
291 | 291 | ||
292 | static ssize_t set_fan_pulses(struct device *dev, struct device_attribute *da, | 292 | static ssize_t fan_pulses_store(struct device *dev, |
293 | const char *buf, size_t count) | 293 | struct device_attribute *da, const char *buf, |
294 | size_t count) | ||
294 | { | 295 | { |
295 | int nr = to_sensor_dev_attr(da)->index; | 296 | int nr = to_sensor_dev_attr(da)->index; |
296 | struct tc654_data *data = dev_get_drvdata(dev); | 297 | struct tc654_data *data = dev_get_drvdata(dev); |
@@ -329,8 +330,8 @@ static ssize_t set_fan_pulses(struct device *dev, struct device_attribute *da, | |||
329 | return ret < 0 ? ret : count; | 330 | return ret < 0 ? ret : count; |
330 | } | 331 | } |
331 | 332 | ||
332 | static ssize_t show_pwm_mode(struct device *dev, | 333 | static ssize_t pwm_mode_show(struct device *dev, struct device_attribute *da, |
333 | struct device_attribute *da, char *buf) | 334 | char *buf) |
334 | { | 335 | { |
335 | struct tc654_data *data = tc654_update_client(dev); | 336 | struct tc654_data *data = tc654_update_client(dev); |
336 | 337 | ||
@@ -340,9 +341,8 @@ static ssize_t show_pwm_mode(struct device *dev, | |||
340 | return sprintf(buf, "%d\n", !!(data->config & TC654_REG_CONFIG_DUTYC)); | 341 | return sprintf(buf, "%d\n", !!(data->config & TC654_REG_CONFIG_DUTYC)); |
341 | } | 342 | } |
342 | 343 | ||
343 | static ssize_t set_pwm_mode(struct device *dev, | 344 | static ssize_t pwm_mode_store(struct device *dev, struct device_attribute *da, |
344 | struct device_attribute *da, | 345 | const char *buf, size_t count) |
345 | const char *buf, size_t count) | ||
346 | { | 346 | { |
347 | struct tc654_data *data = dev_get_drvdata(dev); | 347 | struct tc654_data *data = dev_get_drvdata(dev); |
348 | struct i2c_client *client = data->client; | 348 | struct i2c_client *client = data->client; |
@@ -371,7 +371,7 @@ static ssize_t set_pwm_mode(struct device *dev, | |||
371 | static const int tc654_pwm_map[16] = { 77, 88, 102, 112, 124, 136, 148, 160, | 371 | static const int tc654_pwm_map[16] = { 77, 88, 102, 112, 124, 136, 148, 160, |
372 | 172, 184, 196, 207, 219, 231, 243, 255}; | 372 | 172, 184, 196, 207, 219, 231, 243, 255}; |
373 | 373 | ||
374 | static ssize_t show_pwm(struct device *dev, struct device_attribute *da, | 374 | static ssize_t pwm_show(struct device *dev, struct device_attribute *da, |
375 | char *buf) | 375 | char *buf) |
376 | { | 376 | { |
377 | struct tc654_data *data = tc654_update_client(dev); | 377 | struct tc654_data *data = tc654_update_client(dev); |
@@ -388,8 +388,8 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *da, | |||
388 | return sprintf(buf, "%d\n", pwm); | 388 | return sprintf(buf, "%d\n", pwm); |
389 | } | 389 | } |
390 | 390 | ||
391 | static ssize_t set_pwm(struct device *dev, struct device_attribute *da, | 391 | static ssize_t pwm_store(struct device *dev, struct device_attribute *da, |
392 | const char *buf, size_t count) | 392 | const char *buf, size_t count) |
393 | { | 393 | { |
394 | struct tc654_data *data = dev_get_drvdata(dev); | 394 | struct tc654_data *data = dev_get_drvdata(dev); |
395 | struct i2c_client *client = data->client; | 395 | struct i2c_client *client = data->client; |
@@ -423,22 +423,16 @@ out: | |||
423 | return ret < 0 ? ret : count; | 423 | return ret < 0 ? ret : count; |
424 | } | 424 | } |
425 | 425 | ||
426 | static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); | 426 | static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); |
427 | static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); | 427 | static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); |
428 | static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, | 428 | static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); |
429 | set_fan_min, 0); | 429 | static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); |
430 | static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, | 430 | static SENSOR_DEVICE_ATTR_RO(fan1_alarm, fan_alarm, 0); |
431 | set_fan_min, 1); | 431 | static SENSOR_DEVICE_ATTR_RO(fan2_alarm, fan_alarm, 1); |
432 | static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_fan_alarm, NULL, 0); | 432 | static SENSOR_DEVICE_ATTR_RW(fan1_pulses, fan_pulses, 0); |
433 | static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_fan_alarm, NULL, 1); | 433 | static SENSOR_DEVICE_ATTR_RW(fan2_pulses, fan_pulses, 1); |
434 | static SENSOR_DEVICE_ATTR(fan1_pulses, S_IWUSR | S_IRUGO, show_fan_pulses, | 434 | static SENSOR_DEVICE_ATTR_RW(pwm1_mode, pwm_mode, 0); |
435 | set_fan_pulses, 0); | 435 | static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); |
436 | static SENSOR_DEVICE_ATTR(fan2_pulses, S_IWUSR | S_IRUGO, show_fan_pulses, | ||
437 | set_fan_pulses, 1); | ||
438 | static SENSOR_DEVICE_ATTR(pwm1_mode, S_IWUSR | S_IRUGO, | ||
439 | show_pwm_mode, set_pwm_mode, 0); | ||
440 | static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, | ||
441 | set_pwm, 0); | ||
442 | 436 | ||
443 | /* Driver data */ | 437 | /* Driver data */ |
444 | static struct attribute *tc654_attrs[] = { | 438 | static struct attribute *tc654_attrs[] = { |