summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2016-12-22 07:05:30 -0500
committerGuenter Roeck <linux@roeck-us.net>2017-01-02 13:19:45 -0500
commit4cd0183dcf2a9be3338acda63fc4b745f6ef587e (patch)
treedbfa4ebd917d3869e46ed24e5aaacd8fe2e4c0f3
parent14c05198bc74ab7e57ade977f653c15e0da77530 (diff)
hwmon: (emc2103) use permission-specific DEVICE_ATTR variants
Use DEVICE_ATTR_RO for read only attributes and DEVICE_ATTR_RW for read/write attributes. This simplifies the source code, improves readbility, and reduces the chance of inconsistencies. The conversion was done automatically using coccinelle. It was validated by compiling both the old and the new source code and comparing its text, data, and bss size. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> [groeck: Updated description] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/emc2103.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c
index 4b870ee9b0d3..1ed9a7aa953d 100644
--- a/drivers/hwmon/emc2103.c
+++ b/drivers/hwmon/emc2103.c
@@ -284,7 +284,7 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *da,
284} 284}
285 285
286static ssize_t 286static ssize_t
287show_fan(struct device *dev, struct device_attribute *da, char *buf) 287fan1_input_show(struct device *dev, struct device_attribute *da, char *buf)
288{ 288{
289 struct emc2103_data *data = emc2103_update_device(dev); 289 struct emc2103_data *data = emc2103_update_device(dev);
290 int rpm = 0; 290 int rpm = 0;
@@ -294,7 +294,7 @@ show_fan(struct device *dev, struct device_attribute *da, char *buf)
294} 294}
295 295
296static ssize_t 296static ssize_t
297show_fan_div(struct device *dev, struct device_attribute *da, char *buf) 297fan1_div_show(struct device *dev, struct device_attribute *da, char *buf)
298{ 298{
299 struct emc2103_data *data = emc2103_update_device(dev); 299 struct emc2103_data *data = emc2103_update_device(dev);
300 int fan_div = 8 / data->fan_multiplier; 300 int fan_div = 8 / data->fan_multiplier;
@@ -307,8 +307,8 @@ show_fan_div(struct device *dev, struct device_attribute *da, char *buf)
307 * of least surprise; the user doesn't expect the fan target to change just 307 * of least surprise; the user doesn't expect the fan target to change just
308 * because the divider changed. 308 * because the divider changed.
309 */ 309 */
310static ssize_t set_fan_div(struct device *dev, struct device_attribute *da, 310static ssize_t fan1_div_store(struct device *dev, struct device_attribute *da,
311 const char *buf, size_t count) 311 const char *buf, size_t count)
312{ 312{
313 struct emc2103_data *data = emc2103_update_device(dev); 313 struct emc2103_data *data = emc2103_update_device(dev);
314 struct i2c_client *client = data->client; 314 struct i2c_client *client = data->client;
@@ -369,7 +369,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *da,
369} 369}
370 370
371static ssize_t 371static ssize_t
372show_fan_target(struct device *dev, struct device_attribute *da, char *buf) 372fan1_target_show(struct device *dev, struct device_attribute *da, char *buf)
373{ 373{
374 struct emc2103_data *data = emc2103_update_device(dev); 374 struct emc2103_data *data = emc2103_update_device(dev);
375 int rpm = 0; 375 int rpm = 0;
@@ -382,8 +382,9 @@ show_fan_target(struct device *dev, struct device_attribute *da, char *buf)
382 return sprintf(buf, "%d\n", rpm); 382 return sprintf(buf, "%d\n", rpm);
383} 383}
384 384
385static ssize_t set_fan_target(struct device *dev, struct device_attribute *da, 385static ssize_t fan1_target_store(struct device *dev,
386 const char *buf, size_t count) 386 struct device_attribute *da, const char *buf,
387 size_t count)
387{ 388{
388 struct emc2103_data *data = emc2103_update_device(dev); 389 struct emc2103_data *data = emc2103_update_device(dev);
389 struct i2c_client *client = data->client; 390 struct i2c_client *client = data->client;
@@ -412,7 +413,7 @@ static ssize_t set_fan_target(struct device *dev, struct device_attribute *da,
412} 413}
413 414
414static ssize_t 415static ssize_t
415show_fan_fault(struct device *dev, struct device_attribute *da, char *buf) 416fan1_fault_show(struct device *dev, struct device_attribute *da, char *buf)
416{ 417{
417 struct emc2103_data *data = emc2103_update_device(dev); 418 struct emc2103_data *data = emc2103_update_device(dev);
418 bool fault = ((data->fan_tach & 0x1fe0) == 0x1fe0); 419 bool fault = ((data->fan_tach & 0x1fe0) == 0x1fe0);
@@ -420,14 +421,15 @@ show_fan_fault(struct device *dev, struct device_attribute *da, char *buf)
420} 421}
421 422
422static ssize_t 423static ssize_t
423show_pwm_enable(struct device *dev, struct device_attribute *da, char *buf) 424pwm1_enable_show(struct device *dev, struct device_attribute *da, char *buf)
424{ 425{
425 struct emc2103_data *data = emc2103_update_device(dev); 426 struct emc2103_data *data = emc2103_update_device(dev);
426 return sprintf(buf, "%d\n", data->fan_rpm_control ? 3 : 0); 427 return sprintf(buf, "%d\n", data->fan_rpm_control ? 3 : 0);
427} 428}
428 429
429static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *da, 430static ssize_t pwm1_enable_store(struct device *dev,
430 const char *buf, size_t count) 431 struct device_attribute *da, const char *buf,
432 size_t count)
431{ 433{
432 struct emc2103_data *data = dev_get_drvdata(dev); 434 struct emc2103_data *data = dev_get_drvdata(dev);
433 struct i2c_client *client = data->client; 435 struct i2c_client *client = data->client;
@@ -512,14 +514,12 @@ static SENSOR_DEVICE_ATTR(temp4_min_alarm, S_IRUGO, show_temp_min_alarm,
512static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_temp_max_alarm, 514static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_temp_max_alarm,
513 NULL, 3); 515 NULL, 3);
514 516
515static DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL); 517static DEVICE_ATTR_RO(fan1_input);
516static DEVICE_ATTR(fan1_div, S_IRUGO | S_IWUSR, show_fan_div, set_fan_div); 518static DEVICE_ATTR_RW(fan1_div);
517static DEVICE_ATTR(fan1_target, S_IRUGO | S_IWUSR, show_fan_target, 519static DEVICE_ATTR_RW(fan1_target);
518 set_fan_target); 520static DEVICE_ATTR_RO(fan1_fault);
519static DEVICE_ATTR(fan1_fault, S_IRUGO, show_fan_fault, NULL);
520 521
521static DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, show_pwm_enable, 522static DEVICE_ATTR_RW(pwm1_enable);
522 set_pwm_enable);
523 523
524/* sensors present on all models */ 524/* sensors present on all models */
525static struct attribute *emc2103_attributes[] = { 525static struct attribute *emc2103_attributes[] = {