Commit 57549f33 authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (ds620) Use permission specific SENSOR[_DEVICE]_ATTR variants

Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code,
to improve readbility, 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: default avatarGuenter Roeck <linux@roeck-us.net>
parent 0ad85c07
...@@ -139,7 +139,7 @@ static struct ds620_data *ds620_update_client(struct device *dev) ...@@ -139,7 +139,7 @@ static struct ds620_data *ds620_update_client(struct device *dev)
return ret; return ret;
} }
static ssize_t show_temp(struct device *dev, struct device_attribute *da, static ssize_t temp_show(struct device *dev, struct device_attribute *da,
char *buf) char *buf)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
...@@ -151,8 +151,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da, ...@@ -151,8 +151,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da,
return sprintf(buf, "%d\n", ((data->temp[attr->index] / 8) * 625) / 10); return sprintf(buf, "%d\n", ((data->temp[attr->index] / 8) * 625) / 10);
} }
static ssize_t set_temp(struct device *dev, struct device_attribute *da, static ssize_t temp_store(struct device *dev, struct device_attribute *da,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int res; int res;
long val; long val;
...@@ -176,7 +176,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, ...@@ -176,7 +176,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
return count; return count;
} }
static ssize_t show_alarm(struct device *dev, struct device_attribute *da, static ssize_t alarm_show(struct device *dev, struct device_attribute *da,
char *buf) char *buf)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
...@@ -207,13 +207,11 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *da, ...@@ -207,13 +207,11 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
return sprintf(buf, "%d\n", !!(conf & attr->index)); return sprintf(buf, "%d\n", !!(conf & attr->index));
} }
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0);
static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp, set_temp, 1); static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, 1);
static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp, set_temp, 2); static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, 2);
static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, DS620_REG_CONFIG_TLF);
DS620_REG_CONFIG_TLF); static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, DS620_REG_CONFIG_THF);
static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL,
DS620_REG_CONFIG_THF);
static struct attribute *ds620_attrs[] = { static struct attribute *ds620_attrs[] = {
&sensor_dev_attr_temp1_input.dev_attr.attr, &sensor_dev_attr_temp1_input.dev_attr.attr,
......
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