Commit eabb6f15 authored by Julia Lawall's avatar Julia Lawall Committed by Guenter Roeck

hwmon: (lm78) 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: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
[groeck: Updated description]
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent e33110d0
...@@ -236,22 +236,23 @@ show_in_offset(5); ...@@ -236,22 +236,23 @@ show_in_offset(5);
show_in_offset(6); show_in_offset(6);
/* Temperature */ /* Temperature */
static ssize_t show_temp(struct device *dev, struct device_attribute *da, static ssize_t temp1_input_show(struct device *dev,
char *buf) struct device_attribute *da, char *buf)
{ {
struct lm78_data *data = lm78_update_device(dev); struct lm78_data *data = lm78_update_device(dev);
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp)); return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp));
} }
static ssize_t show_temp_over(struct device *dev, struct device_attribute *da, static ssize_t temp1_max_show(struct device *dev, struct device_attribute *da,
char *buf) char *buf)
{ {
struct lm78_data *data = lm78_update_device(dev); struct lm78_data *data = lm78_update_device(dev);
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over)); return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_over));
} }
static ssize_t set_temp_over(struct device *dev, struct device_attribute *da, static ssize_t temp1_max_store(struct device *dev,
const char *buf, size_t count) struct device_attribute *da, const char *buf,
size_t count)
{ {
struct lm78_data *data = dev_get_drvdata(dev); struct lm78_data *data = dev_get_drvdata(dev);
long val; long val;
...@@ -268,14 +269,15 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *da, ...@@ -268,14 +269,15 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *da,
return count; return count;
} }
static ssize_t show_temp_hyst(struct device *dev, struct device_attribute *da, static ssize_t temp1_max_hyst_show(struct device *dev,
char *buf) struct device_attribute *da, char *buf)
{ {
struct lm78_data *data = lm78_update_device(dev); struct lm78_data *data = lm78_update_device(dev);
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst)); return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_hyst));
} }
static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *da, static ssize_t temp1_max_hyst_store(struct device *dev,
struct device_attribute *da,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct lm78_data *data = dev_get_drvdata(dev); struct lm78_data *data = dev_get_drvdata(dev);
...@@ -293,11 +295,9 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *da, ...@@ -293,11 +295,9 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *da,
return count; return count;
} }
static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); static DEVICE_ATTR_RO(temp1_input);
static DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, static DEVICE_ATTR_RW(temp1_max);
show_temp_over, set_temp_over); static DEVICE_ATTR_RW(temp1_max_hyst);
static DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR,
show_temp_hyst, set_temp_hyst);
/* 3 Fans */ /* 3 Fans */
static ssize_t show_fan(struct device *dev, struct device_attribute *da, static ssize_t show_fan(struct device *dev, struct device_attribute *da,
...@@ -431,22 +431,22 @@ static SENSOR_DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR, ...@@ -431,22 +431,22 @@ static SENSOR_DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR,
static SENSOR_DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2); static SENSOR_DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2);
/* VID */ /* VID */
static ssize_t show_vid(struct device *dev, struct device_attribute *da, static ssize_t cpu0_vid_show(struct device *dev, struct device_attribute *da,
char *buf) char *buf)
{ {
struct lm78_data *data = lm78_update_device(dev); struct lm78_data *data = lm78_update_device(dev);
return sprintf(buf, "%d\n", vid_from_reg(data->vid, 82)); return sprintf(buf, "%d\n", vid_from_reg(data->vid, 82));
} }
static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); static DEVICE_ATTR_RO(cpu0_vid);
/* Alarms */ /* Alarms */
static ssize_t show_alarms(struct device *dev, struct device_attribute *da, static ssize_t alarms_show(struct device *dev, struct device_attribute *da,
char *buf) char *buf)
{ {
struct lm78_data *data = lm78_update_device(dev); struct lm78_data *data = lm78_update_device(dev);
return sprintf(buf, "%u\n", data->alarms); return sprintf(buf, "%u\n", data->alarms);
} }
static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); static DEVICE_ATTR_RO(alarms);
static ssize_t show_alarm(struct device *dev, struct device_attribute *da, static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
char *buf) char *buf)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment