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

hwmon: (via686a) use permission-specific DEVICE_ATTR variants

Use DEVICE_ATTR_RO for read-only 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>

authored by

Julia Lawall and committed by
Guenter Roeck
8b2bd7ae 1664d7fd

+4 -4
+4 -4
drivers/hwmon/via686a.c
··· 580 580 show_fan_offset(2); 581 581 582 582 /* Alarms */ 583 - static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, 583 + static ssize_t alarms_show(struct device *dev, struct device_attribute *attr, 584 584 char *buf) 585 585 { 586 586 struct via686a_data *data = via686a_update_device(dev); 587 587 return sprintf(buf, "%u\n", data->alarms); 588 588 } 589 589 590 - static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 590 + static DEVICE_ATTR_RO(alarms); 591 591 592 592 static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, 593 593 char *buf) ··· 607 607 static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6); 608 608 static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7); 609 609 610 - static ssize_t show_name(struct device *dev, struct device_attribute 610 + static ssize_t name_show(struct device *dev, struct device_attribute 611 611 *devattr, char *buf) 612 612 { 613 613 struct via686a_data *data = dev_get_drvdata(dev); 614 614 return sprintf(buf, "%s\n", data->name); 615 615 } 616 - static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 616 + static DEVICE_ATTR_RO(name); 617 617 618 618 static struct attribute *via686a_attributes[] = { 619 619 &sensor_dev_attr_in0_input.dev_attr.attr,