Skip to content

Commit

Permalink
hwmon: (f71805f) use permission-specific DEVICE_ATTR variants
Browse files Browse the repository at this point in the history
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 <[email protected]>
[groeck: Updated description]
Signed-off-by: Guenter Roeck <[email protected]>
  • Loading branch information
JuliaLawall authored and groeck committed Jan 2, 2017
1 parent a81b67d commit 8258e49
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions drivers/hwmon/f71805f.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,23 +946,23 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute
return count;
}

static ssize_t show_alarms_in(struct device *dev, struct device_attribute
static ssize_t alarms_in_show(struct device *dev, struct device_attribute
*devattr, char *buf)
{
struct f71805f_data *data = f71805f_update_device(dev);

return sprintf(buf, "%lu\n", data->alarms & 0x7ff);
}

static ssize_t show_alarms_fan(struct device *dev, struct device_attribute
static ssize_t alarms_fan_show(struct device *dev, struct device_attribute
*devattr, char *buf)
{
struct f71805f_data *data = f71805f_update_device(dev);

return sprintf(buf, "%lu\n", (data->alarms >> 16) & 0x07);
}

static ssize_t show_alarms_temp(struct device *dev, struct device_attribute
static ssize_t alarms_temp_show(struct device *dev, struct device_attribute
*devattr, char *buf)
{
struct f71805f_data *data = f71805f_update_device(dev);
Expand All @@ -980,7 +980,7 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute
return sprintf(buf, "%lu\n", (data->alarms >> bitnr) & 1);
}

static ssize_t show_name(struct device *dev, struct device_attribute
static ssize_t name_show(struct device *dev, struct device_attribute
*devattr, char *buf)
{
struct f71805f_data *data = dev_get_drvdata(dev);
Expand Down Expand Up @@ -1176,11 +1176,11 @@ static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13);
static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 16);
static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 17);
static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 18);
static DEVICE_ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL);
static DEVICE_ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL);
static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL);
static DEVICE_ATTR_RO(alarms_in);
static DEVICE_ATTR_RO(alarms_fan);
static DEVICE_ATTR_RO(alarms_temp);

static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
static DEVICE_ATTR_RO(name);

static struct attribute *f71805f_attributes[] = {
&sensor_dev_attr_in0_input.dev_attr.attr,
Expand Down

0 comments on commit 8258e49

Please sign in to comment.