Commit 66efcd2b authored by Guenter Roeck's avatar Guenter Roeck

hwmon: (adm1025) 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/.

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 8c082675
...@@ -174,7 +174,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev) ...@@ -174,7 +174,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
*/ */
static ssize_t static ssize_t
show_in(struct device *dev, struct device_attribute *attr, char *buf) in_show(struct device *dev, struct device_attribute *attr, char *buf)
{ {
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
struct adm1025_data *data = adm1025_update_device(dev); struct adm1025_data *data = adm1025_update_device(dev);
...@@ -183,7 +183,7 @@ show_in(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -183,7 +183,7 @@ show_in(struct device *dev, struct device_attribute *attr, char *buf)
} }
static ssize_t static ssize_t
show_in_min(struct device *dev, struct device_attribute *attr, char *buf) in_min_show(struct device *dev, struct device_attribute *attr, char *buf)
{ {
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
struct adm1025_data *data = adm1025_update_device(dev); struct adm1025_data *data = adm1025_update_device(dev);
...@@ -192,7 +192,7 @@ show_in_min(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -192,7 +192,7 @@ show_in_min(struct device *dev, struct device_attribute *attr, char *buf)
} }
static ssize_t static ssize_t
show_in_max(struct device *dev, struct device_attribute *attr, char *buf) in_max_show(struct device *dev, struct device_attribute *attr, char *buf)
{ {
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
struct adm1025_data *data = adm1025_update_device(dev); struct adm1025_data *data = adm1025_update_device(dev);
...@@ -201,7 +201,7 @@ show_in_max(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -201,7 +201,7 @@ show_in_max(struct device *dev, struct device_attribute *attr, char *buf)
} }
static ssize_t static ssize_t
show_temp(struct device *dev, struct device_attribute *attr, char *buf) temp_show(struct device *dev, struct device_attribute *attr, char *buf)
{ {
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
struct adm1025_data *data = adm1025_update_device(dev); struct adm1025_data *data = adm1025_update_device(dev);
...@@ -209,7 +209,7 @@ show_temp(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -209,7 +209,7 @@ show_temp(struct device *dev, struct device_attribute *attr, char *buf)
} }
static ssize_t static ssize_t
show_temp_min(struct device *dev, struct device_attribute *attr, char *buf) temp_min_show(struct device *dev, struct device_attribute *attr, char *buf)
{ {
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
struct adm1025_data *data = adm1025_update_device(dev); struct adm1025_data *data = adm1025_update_device(dev);
...@@ -217,14 +217,14 @@ show_temp_min(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -217,14 +217,14 @@ show_temp_min(struct device *dev, struct device_attribute *attr, char *buf)
} }
static ssize_t static ssize_t
show_temp_max(struct device *dev, struct device_attribute *attr, char *buf) temp_max_show(struct device *dev, struct device_attribute *attr, char *buf)
{ {
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
struct adm1025_data *data = adm1025_update_device(dev); struct adm1025_data *data = adm1025_update_device(dev);
return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[index])); return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[index]));
} }
static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, static ssize_t in_min_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
...@@ -245,7 +245,7 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, ...@@ -245,7 +245,7 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
return count; return count;
} }
static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, static ssize_t in_max_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
...@@ -266,22 +266,28 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, ...@@ -266,22 +266,28 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
return count; return count;
} }
#define set_in(offset) \ static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0);
static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0);
show_in, NULL, offset); \ static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0);
static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1);
show_in_min, set_in_min, offset); \ static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1);
static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \ static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1);
show_in_max, set_in_max, offset) static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2);
set_in(0); static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2);
set_in(1); static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2);
set_in(2); static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3);
set_in(3); static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3);
set_in(4); static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3);
set_in(5); static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4);
static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4);
static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4);
const char *buf, size_t count) static SENSOR_DEVICE_ATTR_RO(in5_input, in, 5);
static SENSOR_DEVICE_ATTR_RW(in5_min, in_min, 5);
static SENSOR_DEVICE_ATTR_RW(in5_max, in_max, 5);
static ssize_t temp_min_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{ {
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
struct adm1025_data *data = dev_get_drvdata(dev); struct adm1025_data *data = dev_get_drvdata(dev);
...@@ -301,8 +307,9 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, ...@@ -301,8 +307,9 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
return count; return count;
} }
static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, static ssize_t temp_max_store(struct device *dev,
const char *buf, size_t count) struct device_attribute *attr, const char *buf,
size_t count)
{ {
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
struct adm1025_data *data = dev_get_drvdata(dev); struct adm1025_data *data = dev_get_drvdata(dev);
...@@ -322,15 +329,12 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, ...@@ -322,15 +329,12 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
return count; return count;
} }
#define set_temp(offset) \ static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0);
static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0);
show_temp, NULL, offset - 1); \ static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0);
static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1);
show_temp_min, set_temp_min, offset - 1); \ static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1);
static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1);
show_temp_max, set_temp_max, offset - 1)
set_temp(1);
set_temp(2);
static ssize_t static ssize_t
alarms_show(struct device *dev, struct device_attribute *attr, char *buf) alarms_show(struct device *dev, struct device_attribute *attr, char *buf)
...@@ -341,21 +345,21 @@ alarms_show(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -341,21 +345,21 @@ alarms_show(struct device *dev, struct device_attribute *attr, char *buf)
static DEVICE_ATTR_RO(alarms); static DEVICE_ATTR_RO(alarms);
static ssize_t static ssize_t
show_alarm(struct device *dev, struct device_attribute *attr, char *buf) alarm_show(struct device *dev, struct device_attribute *attr, char *buf)
{ {
int bitnr = to_sensor_dev_attr(attr)->index; int bitnr = to_sensor_dev_attr(attr)->index;
struct adm1025_data *data = adm1025_update_device(dev); struct adm1025_data *data = adm1025_update_device(dev);
return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1);
} }
static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0);
static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1);
static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2);
static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3);
static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 8);
static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 9); static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 9);
static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 5); static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 5);
static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 4); static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 4);
static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_alarm, NULL, 14); static SENSOR_DEVICE_ATTR_RO(temp1_fault, alarm, 14);
static ssize_t static ssize_t
cpu0_vid_show(struct device *dev, struct device_attribute *attr, char *buf) cpu0_vid_show(struct device *dev, struct device_attribute *attr, 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