hwmon: (adm1025) Use permission specific SENSOR[_DEVICE]_ATTR variants
Subsystems (6)
Guenter Roeck
maintainerPATCH 1/16 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/hwmon/.
This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes.
--- drivers/hwmon/adm1025.c | 98 +++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 47 deletions(-)
drivers/hwmon/adm1025.c +51 -47
@@ -174,7 +174,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)*/ 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;struct adm1025_data *data =adm1025_update_device (dev);
@@ -183,7 +183,7 @@ show_in(struct device *dev, struct device_attribute *attr, char *buf) }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;struct adm1025_data *data =adm1025_update_device (dev);
@@ -192,7 +192,7 @@ show_in_min(struct device *dev, struct device_attribute *attr, char *buf) }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;struct adm1025_data *data =adm1025_update_device (dev);
@@ -201,7 +201,7 @@ show_in_max(struct device *dev, struct device_attribute *attr, char *buf) }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;struct adm1025_data *data =adm1025_update_device (dev);
@@ -209,7 +209,7 @@ show_temp(struct device *dev, struct device_attribute *attr, char *buf) }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;struct adm1025_data *data =adm1025_update_device (dev);
@@ -217,15 +217,15 @@ show_temp_min(struct device *dev, struct device_attribute *attr, char *buf) }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;struct adm1025_data *data =adm1025_update_device (dev);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, -const char *buf,size_t count) +static ssize_t in_min_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {int index =to_sensor_dev_attr (attr)->index;struct adm1025_data *data =dev_get_drvdata (dev);
@@ -245,8 +245,8 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,return count; } -static ssize_t set_in_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t in_max_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {int index =to_sensor_dev_attr (attr)->index;struct adm1025_data *data =dev_get_drvdata (dev);
@@ -266,22 +266,28 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,return count; } -#define set_in (offset) \ -static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ - show_in, NULL, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ - show_in_min, set_in_min, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \ - show_in_max, set_in_max, offset) -set_in (0 ); -set_in (1 ); -set_in (2 ); -set_in (3 ); -set_in (4 ); -set_in (5 ); - -static ssize_t set_temp_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0); +static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0); +static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0); +static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1); +static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1); +static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1); +static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2); +static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2); +static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2); +static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3); +static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3); +static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3); +static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4); +static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4); +static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4); +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;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,return count; } -static ssize_t set_temp_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_max_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {int index =to_sensor_dev_attr (attr)->index;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,return count; } -#define set_temp (offset) \ -static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ - show_temp, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ - show_temp_min, set_temp_min, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ - show_temp_max, set_temp_max, offset - 1) -set_temp (1 ); -set_temp (2 ); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1);static ssize_t 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 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;struct adm1025_data *data =adm1025_update_device (dev);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(in1_alarm, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); -static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 9); -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 5); -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 4); -static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_alarm, NULL, 14); +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0); +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2); +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 8); +static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 9); +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 5); +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 4); +static SENSOR_DEVICE_ATTR_RO(temp1_fault, alarm, 14);static ssize_t cpu0_vid_show (struct device *dev,struct device_attribute *attr,char *buf)
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 2/16 hwmon: (adm1026) 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.
--- drivers/hwmon/adm1026.c | 416 +++++++++++++++++++++++++----------------------- 1 file changed, 216 insertions(+), 200 deletions(-)
drivers/hwmon/adm1026.c +216 -200
@@ -477,24 +477,24 @@ static struct adm1026_data *adm1026_update_device(struct device *dev)return data; } -static ssize_t show_in (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;struct adm1026_data *data =adm1026_update_device (dev);return sprintf (buf,"%d\n" ,INS_FROM_REG (nr, data->in[nr])); } -static ssize_t show_in_min (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in_min_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;struct adm1026_data *data =adm1026_update_device (dev);return sprintf (buf,"%d\n" ,INS_FROM_REG (nr, data->in_min[nr])); } -static ssize_t set_in_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t in_min_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -513,16 +513,16 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,mutex_unlock (&data->update_lock);return count; } -static ssize_t show_in_max (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in_max_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;struct adm1026_data *data =adm1026_update_device (dev);return sprintf (buf,"%d\n" ,INS_FROM_REG (nr, data->in_max[nr])); } -static ssize_t set_in_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t in_max_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -542,48 +542,72 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,return count; } -#define in_reg (offset) \ -static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in, \ - NULL, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ - show_in_min, set_in_min, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ - show_in_max, set_in_max, offset); - - -in_reg (0 ); -in_reg (1 ); -in_reg (2 ); -in_reg (3 ); -in_reg (4 ); -in_reg (5 ); -in_reg (6 ); -in_reg (7 ); -in_reg (8 ); -in_reg (9 ); -in_reg (10 ); -in_reg (11 ); -in_reg (12 ); -in_reg (13 ); -in_reg (14 ); -in_reg (15 ); - -static ssize_t show_in16 (struct device *dev,struct device_attribute *attr, +static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0); +static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0); +static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0); +static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1); +static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1); +static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1); +static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2); +static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2); +static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2); +static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3); +static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3); +static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3); +static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4); +static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4); +static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4); +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 SENSOR_DEVICE_ATTR_RO(in6_input, in, 6); +static SENSOR_DEVICE_ATTR_RW(in6_min, in_min, 6); +static SENSOR_DEVICE_ATTR_RW(in6_max, in_max, 6); +static SENSOR_DEVICE_ATTR_RO(in7_input, in, 7); +static SENSOR_DEVICE_ATTR_RW(in7_min, in_min, 7); +static SENSOR_DEVICE_ATTR_RW(in7_max, in_max, 7); +static SENSOR_DEVICE_ATTR_RO(in8_input, in, 8); +static SENSOR_DEVICE_ATTR_RW(in8_min, in_min, 8); +static SENSOR_DEVICE_ATTR_RW(in8_max, in_max, 8); +static SENSOR_DEVICE_ATTR_RO(in9_input, in, 9); +static SENSOR_DEVICE_ATTR_RW(in9_min, in_min, 9); +static SENSOR_DEVICE_ATTR_RW(in9_max, in_max, 9); +static SENSOR_DEVICE_ATTR_RO(in10_input, in, 10); +static SENSOR_DEVICE_ATTR_RW(in10_min, in_min, 10); +static SENSOR_DEVICE_ATTR_RW(in10_max, in_max, 10); +static SENSOR_DEVICE_ATTR_RO(in11_input, in, 11); +static SENSOR_DEVICE_ATTR_RW(in11_min, in_min, 11); +static SENSOR_DEVICE_ATTR_RW(in11_max, in_max, 11); +static SENSOR_DEVICE_ATTR_RO(in12_input, in, 12); +static SENSOR_DEVICE_ATTR_RW(in12_min, in_min, 12); +static SENSOR_DEVICE_ATTR_RW(in12_max, in_max, 12); +static SENSOR_DEVICE_ATTR_RO(in13_input, in, 13); +static SENSOR_DEVICE_ATTR_RW(in13_min, in_min, 13); +static SENSOR_DEVICE_ATTR_RW(in13_max, in_max, 13); +static SENSOR_DEVICE_ATTR_RO(in14_input, in, 14); +static SENSOR_DEVICE_ATTR_RW(in14_min, in_min, 14); +static SENSOR_DEVICE_ATTR_RW(in14_max, in_max, 14); +static SENSOR_DEVICE_ATTR_RO(in15_input, in, 15); +static SENSOR_DEVICE_ATTR_RW(in15_min, in_min, 15); +static SENSOR_DEVICE_ATTR_RW(in15_max, in_max, 15); + +static ssize_t in16_show (struct device *dev,struct device_attribute *attr,char *buf) {struct adm1026_data *data =adm1026_update_device (dev);return sprintf (buf,"%d\n" ,INS_FROM_REG (16 , data->in[16 ]) -NEG12_OFFSET ); } -static ssize_t show_in16_min (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in16_min_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct adm1026_data *data =adm1026_update_device (dev);return sprintf (buf,"%d\n" ,INS_FROM_REG (16 , data->in_min[16 ]) -NEG12_OFFSET ); } -static ssize_t set_in16_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t in16_min_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct adm1026_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -603,15 +627,16 @@ static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr,mutex_unlock (&data->update_lock);return count; } -static ssize_t show_in16_max (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in16_max_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct adm1026_data *data =adm1026_update_device (dev);return sprintf (buf,"%d\n" ,INS_FROM_REG (16 , data->in_max[16 ]) -NEG12_OFFSET ); } -static ssize_t set_in16_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t in16_max_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct adm1026_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -632,17 +657,14 @@ static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr,return count; } -static SENSOR_DEVICE_ATTR(in16_input, S_IRUGO, show_in16, NULL, 16); -static SENSOR_DEVICE_ATTR(in16_min, S_IRUGO | S_IWUSR, show_in16_min, - set_in16_min, 16); -static SENSOR_DEVICE_ATTR(in16_max, S_IRUGO | S_IWUSR, show_in16_max, - set_in16_max, 16); - +static SENSOR_DEVICE_ATTR_RO(in16_input, in16, 16); +static SENSOR_DEVICE_ATTR_RW(in16_min, in16_min, 16); +static SENSOR_DEVICE_ATTR_RW(in16_max, in16_max, 16);/* Now add fan read/write functions */ -static ssize_t show_fan (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t fan_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -650,8 +672,8 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" ,FAN_FROM_REG (data->fan[nr], data->fan_div[nr])); } -static ssize_t show_fan_min (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t fan_min_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -659,8 +681,9 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" ,FAN_FROM_REG (data->fan_min[nr], data->fan_div[nr])); } -static ssize_t set_fan_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t fan_min_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -681,20 +704,22 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,return count; } -#define fan_offset (offset) \ -static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \ - offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ - show_fan_min, set_fan_min, offset - 1); - -fan_offset (1 ); -fan_offset (2 ); -fan_offset (3 ); -fan_offset (4 ); -fan_offset (5 ); -fan_offset (6 ); -fan_offset (7 ); -fan_offset (8 ); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); +static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 2); +static SENSOR_DEVICE_ATTR_RW(fan3_min, fan_min, 2); +static SENSOR_DEVICE_ATTR_RO(fan4_input, fan, 3); +static SENSOR_DEVICE_ATTR_RW(fan4_min, fan_min, 3); +static SENSOR_DEVICE_ATTR_RO(fan5_input, fan, 4); +static SENSOR_DEVICE_ATTR_RW(fan5_min, fan_min, 4); +static SENSOR_DEVICE_ATTR_RO(fan6_input, fan, 5); +static SENSOR_DEVICE_ATTR_RW(fan6_min, fan_min, 5); +static SENSOR_DEVICE_ATTR_RO(fan7_input, fan, 6); +static SENSOR_DEVICE_ATTR_RW(fan7_min, fan_min, 6); +static SENSOR_DEVICE_ATTR_RO(fan8_input, fan, 7); +static SENSOR_DEVICE_ATTR_RW(fan8_min, fan_min, 7);/* Adjust fan_min to account for new fan divisor */ static void fixup_fan_min (struct device *dev,int fan,int old_div)
@@ -715,16 +740,17 @@ static void fixup_fan_min(struct device *dev, int fan, int old_div) }/* Now add fan_div read/write functions */ -static ssize_t show_fan_div (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t fan_div_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;struct adm1026_data *data =adm1026_update_device (dev);return sprintf (buf,"%d\n" , data->fan_div[nr]); } -static ssize_t set_fan_div (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t fan_div_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -765,38 +791,35 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,return count; } -#define fan_offset_div (offset) \ -static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ - show_fan_div, set_fan_div, offset - 1); - -fan_offset_div (1 ); -fan_offset_div (2 ); -fan_offset_div (3 ); -fan_offset_div (4 ); -fan_offset_div (5 ); -fan_offset_div (6 ); -fan_offset_div (7 ); -fan_offset_div (8 ); +static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0); +static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1); +static SENSOR_DEVICE_ATTR_RW(fan3_div, fan_div, 2); +static SENSOR_DEVICE_ATTR_RW(fan4_div, fan_div, 3); +static SENSOR_DEVICE_ATTR_RW(fan5_div, fan_div, 4); +static SENSOR_DEVICE_ATTR_RW(fan6_div, fan_div, 5); +static SENSOR_DEVICE_ATTR_RW(fan7_div, fan_div, 6); +static SENSOR_DEVICE_ATTR_RW(fan8_div, fan_div, 7);/* Temps */ -static ssize_t show_temp (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t temp_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;struct adm1026_data *data =adm1026_update_device (dev);return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp[nr])); } -static ssize_t show_temp_min (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t temp_min_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;struct adm1026_data *data =adm1026_update_device (dev);return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp_min[nr])); } -static ssize_t set_temp_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_min_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -816,16 +839,17 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,mutex_unlock (&data->update_lock);return count; } -static ssize_t show_temp_max (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t temp_max_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;struct adm1026_data *data =adm1026_update_device (dev);return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp_max[nr])); } -static ssize_t set_temp_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_max_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -846,30 +870,27 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,return count; } -#define temp_reg (offset) \ -static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \ - NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ - show_temp_min, set_temp_min, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ - show_temp_max, set_temp_max, offset - 1); - - -temp_reg (1 ); -temp_reg (2 ); -temp_reg (3 ); - -static ssize_t show_temp_offset (struct device *dev, -struct device_attribute *attr,char *buf) +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2); + +static ssize_t temp_offset_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;struct adm1026_data *data =adm1026_update_device (dev);return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp_offset[nr])); } -static ssize_t set_temp_offset (struct device *dev, -struct device_attribute *attr,const char *buf, -size_t count) +static ssize_t temp_offset_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -890,16 +911,13 @@ static ssize_t set_temp_offset(struct device *dev,return count; } -#define temp_offset_reg (offset) \ -static SENSOR_DEVICE_ATTR(temp##offset##_offset, S_IRUGO | S_IWUSR, \ - show_temp_offset, set_temp_offset, offset - 1); - -temp_offset_reg (1 ); -temp_offset_reg (2 ); -temp_offset_reg (3 ); +static SENSOR_DEVICE_ATTR_RW(temp1_offset, temp_offset, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_offset, temp_offset, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_offset, temp_offset, 2); -static ssize_t show_temp_auto_point1_temp_hyst (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t temp_auto_point1_temp_hyst_show (struct device *dev, +struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -907,8 +925,9 @@ static ssize_t show_temp_auto_point1_temp_hyst(struct device *dev,return sprintf (buf,"%d\n" ,TEMP_FROM_REG (ADM1026_FAN_ACTIVATION_TEMP_HYST + data->temp_tmin[nr])); } -static ssize_t show_temp_auto_point2_temp (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t temp_auto_point2_temp_show (struct device *dev, +struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -916,16 +935,18 @@ static ssize_t show_temp_auto_point2_temp(struct device *dev,return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp_tmin[nr] +ADM1026_FAN_CONTROL_TEMP_RANGE )); } -static ssize_t show_temp_auto_point1_temp (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t temp_auto_point1_temp_show (struct device *dev, +struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;struct adm1026_data *data =adm1026_update_device (dev);return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp_tmin[nr])); } -static ssize_t set_temp_auto_point1_temp (struct device *dev, -struct device_attribute *attr,const char *buf,size_t count) +static ssize_t temp_auto_point1_temp_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -946,18 +967,18 @@ static ssize_t set_temp_auto_point1_temp(struct device *dev,return count; } -#define temp_auto_point (offset) \ -static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp, \ - S_IRUGO | S_IWUSR, show_temp_auto_point1_temp, \ - set_temp_auto_point1_temp, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp_hyst, S_IRUGO,\ - show_temp_auto_point1_temp_hyst, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_auto_point2_temp, S_IRUGO, \ - show_temp_auto_point2_temp, NULL, offset - 1); - -temp_auto_point (1 ); -temp_auto_point (2 ); -temp_auto_point (3 ); +static SENSOR_DEVICE_ATTR_RW(temp1_auto_point1_temp, temp_auto_point1_temp, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_auto_point1_temp_hyst, + temp_auto_point1_temp_hyst, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_auto_point2_temp, temp_auto_point2_temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_auto_point1_temp, temp_auto_point1_temp, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_auto_point1_temp_hyst, + temp_auto_point1_temp_hyst, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_auto_point2_temp, temp_auto_point2_temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_auto_point1_temp, temp_auto_point1_temp, 2); +static SENSOR_DEVICE_ATTR_RO(temp3_auto_point1_temp_hyst, + temp_auto_point1_temp_hyst, 2); +static SENSOR_DEVICE_ATTR_RO(temp3_auto_point2_temp, temp_auto_point2_temp, 2);static ssize_t show_temp_crit_enable (struct device *dev,struct device_attribute *attr,char *buf)
@@ -988,24 +1009,24 @@ static ssize_t set_temp_crit_enable(struct device *dev,return count; } -#define temp_crit_enable (offset) \ -static DEVICE_ATTR(temp##offset##_crit_enable, S_IRUGO | S_IWUSR, \ - show_temp_crit_enable, set_temp_crit_enable); +static DEVICE_ATTR(temp1_crit_enable, 0644, show_temp_crit_enable, + set_temp_crit_enable); +static DEVICE_ATTR(temp2_crit_enable, 0644, show_temp_crit_enable, + set_temp_crit_enable); +static DEVICE_ATTR(temp3_crit_enable, 0644, show_temp_crit_enable, + set_temp_crit_enable); -temp_crit_enable (1 ); -temp_crit_enable (2 ); -temp_crit_enable (3 ); - -static ssize_t show_temp_crit (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t temp_crit_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;struct adm1026_data *data =adm1026_update_device (dev);return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp_crit[nr])); } -static ssize_t set_temp_crit (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_crit_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -1026,13 +1047,9 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,return count; } -#define temp_crit_reg (offset) \ -static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IRUGO | S_IWUSR, \ - show_temp_crit, set_temp_crit, offset - 1); - -temp_crit_reg (1 ); -temp_crit_reg (2 ); -temp_crit_reg (3 ); +static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp_crit, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_crit, temp_crit, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_crit, temp_crit, 2);static ssize_t analog_out_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -1110,7 +1127,7 @@ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,static DEVICE_ATTR_RO (alarms); -static ssize_t show_alarm (struct device *dev,struct device_attribute *attr, +static ssize_t alarm_show (struct device *dev,struct device_attribute *attr,char *buf) {struct adm1026_data *data =adm1026_update_device (dev);
@@ -1118,34 +1135,34 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%ld\n" , (data->alarms >> bitnr) &1 ); } -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 0); -static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(in9_alarm, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(in11_alarm, S_IRUGO, show_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(in12_alarm, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(in13_alarm, S_IRUGO, show_alarm, NULL, 4); -static SENSOR_DEVICE_ATTR(in14_alarm, S_IRUGO, show_alarm, NULL, 5); -static SENSOR_DEVICE_ATTR(in15_alarm, S_IRUGO, show_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(in16_alarm, S_IRUGO, show_alarm, NULL, 7); -static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 8); -static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 9); -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 10); -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 11); -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 12); -static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 13); -static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 14); -static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 15); -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 SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, 19); -static SENSOR_DEVICE_ATTR(fan5_alarm, S_IRUGO, show_alarm, NULL, 20); -static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_alarm, NULL, 21); -static SENSOR_DEVICE_ATTR(fan7_alarm, S_IRUGO, show_alarm, NULL, 22); -static SENSOR_DEVICE_ATTR(fan8_alarm, S_IRUGO, show_alarm, NULL, 23); -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 24); -static SENSOR_DEVICE_ATTR(in10_alarm, S_IRUGO, show_alarm, NULL, 25); -static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 26); +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 0); +static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(in9_alarm, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(in11_alarm, alarm, 2); +static SENSOR_DEVICE_ATTR_RO(in12_alarm, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(in13_alarm, alarm, 4); +static SENSOR_DEVICE_ATTR_RO(in14_alarm, alarm, 5); +static SENSOR_DEVICE_ATTR_RO(in15_alarm, alarm, 6); +static SENSOR_DEVICE_ATTR_RO(in16_alarm, alarm, 7); +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 8); +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 9); +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 10); +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 11); +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 12); +static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 13); +static SENSOR_DEVICE_ATTR_RO(in6_alarm, alarm, 14); +static SENSOR_DEVICE_ATTR_RO(in7_alarm, alarm, 15); +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 16); +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 17); +static SENSOR_DEVICE_ATTR_RO(fan3_alarm, alarm, 18); +static SENSOR_DEVICE_ATTR_RO(fan4_alarm, alarm, 19); +static SENSOR_DEVICE_ATTR_RO(fan5_alarm, alarm, 20); +static SENSOR_DEVICE_ATTR_RO(fan6_alarm, alarm, 21); +static SENSOR_DEVICE_ATTR_RO(fan7_alarm, alarm, 22); +static SENSOR_DEVICE_ATTR_RO(fan8_alarm, alarm, 23); +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 24); +static SENSOR_DEVICE_ATTR_RO(in10_alarm, alarm, 25); +static SENSOR_DEVICE_ATTR_RO(in8_alarm, alarm, 26);static ssize_t alarm_mask_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -1188,7 +1205,6 @@ static ssize_t alarm_mask_store(struct device *dev,static DEVICE_ATTR_RW (alarm_mask); -static ssize_t gpio_show (struct device *dev,struct device_attribute *attr,char *buf) {
@@ -1371,23 +1387,23 @@ static ssize_t pwm1_enable_store(struct device *dev,/* enable PWM fan control */ static DEVICE_ATTR_RW (pwm1); -static DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, pwm1_show, pwm1_store); -static DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, pwm1_show, pwm1_store); +static DEVICE_ATTR(pwm2, 0644, pwm1_show, pwm1_store); +static DEVICE_ATTR(pwm3, 0644, pwm1_show, pwm1_store);static DEVICE_ATTR_RW (pwm1_enable); -static DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, pwm1_enable_show, +static DEVICE_ATTR(pwm2_enable, 0644, pwm1_enable_show, pwm1_enable_store); -static DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, pwm1_enable_show, +static DEVICE_ATTR(pwm3_enable, 0644, pwm1_enable_show, pwm1_enable_store);static DEVICE_ATTR_RW (temp1_auto_point1_pwm); -static DEVICE_ATTR(temp2_auto_point1_pwm, S_IRUGO | S_IWUSR, - temp1_auto_point1_pwm_show, temp1_auto_point1_pwm_store); -static DEVICE_ATTR(temp3_auto_point1_pwm, S_IRUGO | S_IWUSR, - temp1_auto_point1_pwm_show, temp1_auto_point1_pwm_store); +static DEVICE_ATTR(temp2_auto_point1_pwm, 0644, + temp1_auto_point1_pwm_show, temp1_auto_point1_pwm_store); +static DEVICE_ATTR(temp3_auto_point1_pwm, 0644, + temp1_auto_point1_pwm_show, temp1_auto_point1_pwm_store);static DEVICE_ATTR_RO (temp1_auto_point2_pwm); -static DEVICE_ATTR(temp2_auto_point2_pwm, S_IRUGO, temp1_auto_point2_pwm_show, +static DEVICE_ATTR(temp2_auto_point2_pwm, 0444, temp1_auto_point2_pwm_show, NULL); -static DEVICE_ATTR(temp3_auto_point2_pwm, S_IRUGO, temp1_auto_point2_pwm_show, +static DEVICE_ATTR(temp3_auto_point2_pwm, 0444, temp1_auto_point2_pwm_show, NULL);static struct attribute *adm1026_attributes[] = {
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 3/16 hwmon: (adm9240) Use permission specific SENSOR[_DEVICE]_ATTR variants
In reply to Guenter RoeckUse 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.
--- drivers/hwmon/adm9240.c | 135 +++++++++++++++++++++++------------------------- 1 file changed, 65 insertions(+), 70 deletions(-)
drivers/hwmon/adm9240.c +65 -70
@@ -269,16 +269,16 @@ static ssize_t temp1_input_show(struct device *dev,return sprintf (buf,"%d\n" , data->temp /128 *500 );/* 9-bit value */ } -static ssize_t show_max (struct device *dev,struct device_attribute *devattr, -char *buf) +static ssize_t max_show (struct device *dev,struct device_attribute *devattr, +char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct adm9240_data *data =adm9240_update_device (dev);return sprintf (buf,"%d\n" , data->temp_max[attr->index] *1000 ); } -static ssize_t set_max (struct device *dev,struct device_attribute *devattr, -const char *buf,size_t count) +static ssize_t max_store (struct device *dev,struct device_attribute *devattr, +const char *buf,size_t count) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct adm9240_data *data =dev_get_drvdata (dev);
@@ -299,14 +299,12 @@ static ssize_t set_max(struct device *dev, struct device_attribute *devattr, }static DEVICE_ATTR_RO (temp1_input); -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, - show_max, set_max, 0); -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, - show_max, set_max, 1); +static SENSOR_DEVICE_ATTR_RW(temp1_max, max, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, max, 1);/* voltage */ -static ssize_t show_in (struct device *dev,struct device_attribute *devattr, -char *buf) +static ssize_t in_show (struct device *dev,struct device_attribute *devattr, +char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct adm9240_data *data =adm9240_update_device (dev);
@@ -314,8 +312,8 @@ static ssize_t show_in(struct device *dev, struct device_attribute *devattr, attr->index)); } -static ssize_t show_in_min (struct device *dev, -struct device_attribute *devattr,char *buf) +static ssize_t in_min_show (struct device *dev, +struct device_attribute *devattr,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct adm9240_data *data =adm9240_update_device (dev);
@@ -323,8 +321,8 @@ static ssize_t show_in_min(struct device *dev, attr->index)); } -static ssize_t show_in_max (struct device *dev, -struct device_attribute *devattr,char *buf) +static ssize_t in_max_show (struct device *dev, +struct device_attribute *devattr,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct adm9240_data *data =adm9240_update_device (dev);
@@ -332,9 +330,9 @@ static ssize_t show_in_max(struct device *dev, attr->index)); } -static ssize_t set_in_min (struct device *dev, -struct device_attribute *devattr, -const char *buf,size_t count) +static ssize_t in_min_store (struct device *dev, +struct device_attribute *devattr,const char *buf, +size_t count) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct adm9240_data *data =dev_get_drvdata (dev);
@@ -354,9 +352,9 @@ static ssize_t set_in_min(struct device *dev,return count; } -static ssize_t set_in_max (struct device *dev, -struct device_attribute *devattr, -const char *buf,size_t count) +static ssize_t in_max_store (struct device *dev, +struct device_attribute *devattr,const char *buf, +size_t count) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct adm9240_data *data =dev_get_drvdata (dev);
@@ -376,24 +374,28 @@ static ssize_t set_in_max(struct device *dev,return count; } -#define vin (nr) \ -static SENSOR_DEVICE_ATTR(in##nr##_input, S_IRUGO, \ - show_in, NULL, nr); \ -static SENSOR_DEVICE_ATTR(in##nr##_min, S_IRUGO | S_IWUSR, \ - show_in_min, set_in_min, nr); \ -static SENSOR_DEVICE_ATTR(in##nr##_max, S_IRUGO | S_IWUSR, \ - show_in_max, set_in_max, nr); - -vin (0 ); -vin (1 ); -vin (2 ); -vin (3 ); -vin (4 ); -vin (5 ); +static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0); +static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0); +static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0); +static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1); +static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1); +static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1); +static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2); +static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2); +static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2); +static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3); +static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3); +static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3); +static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4); +static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4); +static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4); +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);/* fans */ -static ssize_t show_fan (struct device *dev, -struct device_attribute *devattr,char *buf) +static ssize_t fan_show (struct device *dev,struct device_attribute *devattr, +char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct adm9240_data *data =adm9240_update_device (dev);
@@ -401,8 +403,8 @@ static ssize_t show_fan(struct device *dev, 1 << data->fan_div[attr->index])); } -static ssize_t show_fan_min (struct device *dev, -struct device_attribute *devattr,char *buf) +static ssize_t fan_min_show (struct device *dev, +struct device_attribute *devattr,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct adm9240_data *data =adm9240_update_device (dev);
@@ -410,8 +412,8 @@ static ssize_t show_fan_min(struct device *dev, 1 << data->fan_div[attr->index])); } -static ssize_t show_fan_div (struct device *dev, -struct device_attribute *devattr,char *buf) +static ssize_t fan_div_show (struct device *dev, +struct device_attribute *devattr,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct adm9240_data *data =adm9240_update_device (dev);
@@ -429,9 +431,9 @@ static ssize_t show_fan_div(struct device *dev,* - otherwise: select fan clock divider to suit fan speed low limit, * measurement code may adjust registers to ensure fan speed reading */ -static ssize_t set_fan_min (struct device *dev, -struct device_attribute *devattr, -const char *buf,size_t count) +static ssize_t fan_min_store (struct device *dev, +struct device_attribute *devattr, +const char *buf,size_t count) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct adm9240_data *data =dev_get_drvdata (dev);
@@ -489,16 +491,12 @@ static ssize_t set_fan_min(struct device *dev,return count; } -#define fan (nr) \ -static SENSOR_DEVICE_ATTR(fan##nr##_input, S_IRUGO, \ - show_fan, NULL, nr - 1); \ -static SENSOR_DEVICE_ATTR(fan##nr##_div, S_IRUGO, \ - show_fan_div, NULL, nr - 1); \ -static SENSOR_DEVICE_ATTR(fan##nr##_min, S_IRUGO | S_IWUSR, \ - show_fan_min, set_fan_min, nr - 1); - -fan (1 ); -fan (2 ); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); +static SENSOR_DEVICE_ATTR_RO(fan1_div, fan_div, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); +static SENSOR_DEVICE_ATTR_RO(fan2_div, fan_div, 1);/* alarms */ static ssize_t alarms_show(struct device *dev,
@@ -509,22 +507,22 @@ static ssize_t alarms_show(struct device *dev, }static DEVICE_ATTR_RO (alarms); -static ssize_t show_alarm (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t alarm_show (struct device *dev,struct device_attribute *attr, +char *buf) {int bitnr =to_sensor_dev_attr (attr)->index;struct adm9240_data *data =adm9240_update_device (dev);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(in1_alarm, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); -static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 9); -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4); -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7); +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0); +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2); +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 8); +static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 9); +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 4); +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 6); +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 7);/* vid */ static ssize_t cpu0_vid_show(struct device *dev,
@@ -564,9 +562,8 @@ static ssize_t aout_output_store(struct device *dev, }static DEVICE_ATTR_RW (aout_output); -static ssize_t chassis_clear (struct device *dev, -struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t alarm_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct adm9240_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -583,8 +580,7 @@ static ssize_t chassis_clear(struct device *dev,return count; } -static SENSOR_DEVICE_ATTR(intrusion0_alarm, S_IRUGO | S_IWUSR, show_alarm, - chassis_clear, 12); +static SENSOR_DEVICE_ATTR_RW(intrusion0_alarm, alarm, 12);static struct attribute *adm9240_attrs[] = { &sensor_dev_attr_in0_input.dev_attr.attr,
@@ -632,7 +628,6 @@ static struct attribute *adm9240_attrs[] = {ATTRIBUTE_GROUPS (adm9240); -/*** sensor chip detect and driver install ***/ /* Return 0 if detection is successful, -ENODEV otherwise */
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 4/16 hwmon: (thmc50) Use permission specific SENSOR[_DEVICE]_ATTR variants
In reply to Guenter RoeckUse 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.
--- drivers/hwmon/thmc50.c | 83 +++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 42 deletions(-)
drivers/hwmon/thmc50.c +41 -42
@@ -128,16 +128,16 @@ static struct thmc50_data *thmc50_update_device(struct device *dev)return data; } -static ssize_t show_analog_out (struct device *dev, +static ssize_t analog_out_show (struct device *dev,struct device_attribute *attr,char *buf) {struct thmc50_data *data =thmc50_update_device (dev);return sprintf (buf,"%d\n" , data->analog_out); } -static ssize_t set_analog_out (struct device *dev, -struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t analog_out_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {struct thmc50_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -166,14 +166,14 @@ static ssize_t set_analog_out(struct device *dev, }/* There is only one PWM mode = DC */ -static ssize_t show_pwm_mode (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t pwm_mode_show (struct device *dev, +struct device_attribute *attr,char *buf) {return sprintf (buf,"0\n" ); }/* Temperatures */ -static ssize_t show_temp (struct device *dev,struct device_attribute *attr, +static ssize_t temp_show (struct device *dev,struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;
@@ -181,16 +181,17 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" , data->temp_input[nr] *1000 ); } -static ssize_t show_temp_min (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t temp_min_show (struct device *dev, +struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct thmc50_data *data =thmc50_update_device (dev);return sprintf (buf,"%d\n" , data->temp_min[nr] *1000 ); } -static ssize_t set_temp_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_min_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct thmc50_data *data =dev_get_drvdata (dev);
@@ -210,16 +211,17 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,return count; } -static ssize_t show_temp_max (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t temp_max_show (struct device *dev, +struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct thmc50_data *data =thmc50_update_device (dev);return sprintf (buf,"%d\n" , data->temp_max[nr] *1000 ); } -static ssize_t set_temp_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_max_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct thmc50_data *data =dev_get_drvdata (dev);
@@ -239,16 +241,15 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,return count; } -static ssize_t show_temp_critical (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t temp_critical_show (struct device *dev, +struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct thmc50_data *data =thmc50_update_device (dev);return sprintf (buf,"%d\n" , data->temp_critical[nr] *1000 ); } -static ssize_t show_alarm (struct device *dev,struct device_attribute *attr, +static ssize_t alarm_show (struct device *dev,struct device_attribute *attr,char *buf) {int index =to_sensor_dev_attr (attr)->index;
@@ -257,29 +258,27 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%u\n" , (data->alarms >> index) &1 ); } -#define temp_reg (offset) \ -static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \ - NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ - show_temp_min, set_temp_min, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ - show_temp_max, set_temp_max, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IRUGO, \ - show_temp_critical, NULL, offset - 1); - -temp_reg (1 ); -temp_reg (2 ); -temp_reg (3 ); - -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5); -static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 7); -static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 2); - -static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_analog_out, - set_analog_out, 0); -static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); +static SENSOR_DEVICE_ATTR_RO(temp1_crit, temp_critical, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_crit, temp_critical, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2); +static SENSOR_DEVICE_ATTR_RO(temp3_crit, temp_critical, 2); + +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 5); +static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 7); +static SENSOR_DEVICE_ATTR_RO(temp3_fault, alarm, 2); + +static SENSOR_DEVICE_ATTR_RW(pwm1, analog_out, 0); +static SENSOR_DEVICE_ATTR_RO(pwm1_mode, pwm_mode, 0);static struct attribute *thmc50_attributes[] = { &sensor_dev_attr_temp1_max.dev_attr.attr,
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 5/16 hwmon: (adm1031) Use permission specific SENSOR[_DEVICE]_ATTR variants
In reply to Guenter RoeckUse 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.
--- drivers/hwmon/adm1031.c | 201 +++++++++++++++++++++++------------------------- 1 file changed, 97 insertions(+), 104 deletions(-)
drivers/hwmon/adm1031.c +97 -104
@@ -331,7 +331,7 @@ get_fan_auto_nearest(struct adm1031_data *data, int chan, u8 val, u8 reg)return -EINVAL ; } -static ssize_t show_fan_auto_channel (struct device *dev, +static ssize_t fan_auto_channel_show (struct device *dev,struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;
@@ -340,8 +340,8 @@ static ssize_t show_fan_auto_channel(struct device *dev, }static ssize_t -set_fan_auto_channel (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +fan_auto_channel_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct adm1031_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -392,13 +392,11 @@ set_fan_auto_channel(struct device *dev, struct device_attribute *attr,return count; } -static SENSOR_DEVICE_ATTR(auto_fan1_channel, S_IRUGO | S_IWUSR, - show_fan_auto_channel, set_fan_auto_channel, 0); -static SENSOR_DEVICE_ATTR(auto_fan2_channel, S_IRUGO | S_IWUSR, - show_fan_auto_channel, set_fan_auto_channel, 1); +static SENSOR_DEVICE_ATTR_RW(auto_fan1_channel, fan_auto_channel, 0); +static SENSOR_DEVICE_ATTR_RW(auto_fan2_channel, fan_auto_channel, 1);/* Auto Temps */ -static ssize_t show_auto_temp_off (struct device *dev, +static ssize_t auto_temp_off_show (struct device *dev,struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;
@@ -406,7 +404,7 @@ static ssize_t show_auto_temp_off(struct device *dev,return sprintf (buf,"%d\n" ,AUTO_TEMP_OFF_FROM_REG (data->auto_temp[nr])); } -static ssize_t show_auto_temp_min (struct device *dev, +static ssize_t auto_temp_min_show (struct device *dev,struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;
@@ -415,8 +413,8 @@ static ssize_t show_auto_temp_min(struct device *dev, AUTO_TEMP_MIN_FROM_REG(data->auto_temp[nr])); }static ssize_t -set_auto_temp_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +auto_temp_min_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct adm1031_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -436,7 +434,7 @@ set_auto_temp_min(struct device *dev, struct device_attribute *attr,mutex_unlock (&data->update_lock);return count; } -static ssize_t show_auto_temp_max (struct device *dev, +static ssize_t auto_temp_max_show (struct device *dev,struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;
@@ -445,8 +443,8 @@ static ssize_t show_auto_temp_max(struct device *dev, AUTO_TEMP_MAX_FROM_REG(data->auto_temp[nr])); }static ssize_t -set_auto_temp_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +auto_temp_max_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct adm1031_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -468,28 +466,26 @@ set_auto_temp_max(struct device *dev, struct device_attribute *attr,return count; } -#define auto_temp_reg (offset) \ -static SENSOR_DEVICE_ATTR(auto_temp##offset##_off, S_IRUGO, \ - show_auto_temp_off, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(auto_temp##offset##_min, S_IRUGO | S_IWUSR, \ - show_auto_temp_min, set_auto_temp_min, offset - 1); \ -static SENSOR_DEVICE_ATTR(auto_temp##offset##_max, S_IRUGO | S_IWUSR, \ - show_auto_temp_max, set_auto_temp_max, offset - 1) - -auto_temp_reg (1 ); -auto_temp_reg (2 ); -auto_temp_reg (3 ); +static SENSOR_DEVICE_ATTR_RO(auto_temp1_off, auto_temp_off, 0); +static SENSOR_DEVICE_ATTR_RW(auto_temp1_min, auto_temp_min, 0); +static SENSOR_DEVICE_ATTR_RW(auto_temp1_max, auto_temp_max, 0); +static SENSOR_DEVICE_ATTR_RO(auto_temp2_off, auto_temp_off, 1); +static SENSOR_DEVICE_ATTR_RW(auto_temp2_min, auto_temp_min, 1); +static SENSOR_DEVICE_ATTR_RW(auto_temp2_max, auto_temp_max, 1); +static SENSOR_DEVICE_ATTR_RO(auto_temp3_off, auto_temp_off, 2); +static SENSOR_DEVICE_ATTR_RW(auto_temp3_min, auto_temp_min, 2); +static SENSOR_DEVICE_ATTR_RW(auto_temp3_max, auto_temp_max, 2);/* pwm */ -static ssize_t show_pwm (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t pwm_show (struct device *dev,struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct adm1031_data *data =adm1031_update_device (dev);return sprintf (buf,"%d\n" ,PWM_FROM_REG (data->pwm[nr])); } -static ssize_t set_pwm (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t pwm_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct adm1031_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -517,12 +513,10 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,return count; } -static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, set_pwm, 0); -static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm, set_pwm, 1); -static SENSOR_DEVICE_ATTR(auto_fan1_min_pwm, S_IRUGO | S_IWUSR, - show_pwm, set_pwm, 0); -static SENSOR_DEVICE_ATTR(auto_fan2_min_pwm, S_IRUGO | S_IWUSR, - show_pwm, set_pwm, 1); +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1); +static SENSOR_DEVICE_ATTR_RW(auto_fan1_min_pwm, pwm, 0); +static SENSOR_DEVICE_ATTR_RW(auto_fan2_min_pwm, pwm, 1);/* Fans */
@@ -572,9 +566,8 @@ static int trust_fan_readings(struct adm1031_data *data, int chan)return res; } - -static ssize_t show_fan (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t fan_show (struct device *dev,struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct adm1031_data *data =adm1031_update_device (dev);
@@ -585,15 +578,15 @@ static ssize_t show_fan(struct device *dev,return sprintf (buf,"%d\n" , value); } -static ssize_t show_fan_div (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t fan_div_show (struct device *dev,struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct adm1031_data *data =adm1031_update_device (dev);return sprintf (buf,"%d\n" ,FAN_DIV_FROM_REG (data->fan_div[nr])); } -static ssize_t show_fan_min (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t fan_min_show (struct device *dev,struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct adm1031_data *data =adm1031_update_device (dev);
@@ -601,8 +594,9 @@ static ssize_t show_fan_min(struct device *dev,FAN_FROM_REG (data->fan_min[nr], FAN_DIV_FROM_REG(data->fan_div[nr]))); } -static ssize_t set_fan_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t fan_min_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct adm1031_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -625,8 +619,9 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,mutex_unlock (&data->update_lock);return count; } -static ssize_t set_fan_div (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t fan_div_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct adm1031_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -673,21 +668,16 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,return count; } -#define fan_offset (offset) \ -static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ - show_fan, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ - show_fan_min, set_fan_min, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ - show_fan_div, set_fan_div, offset - 1) - -fan_offset (1 ); -fan_offset (2 ); - +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1);/* Temps */ -static ssize_t show_temp (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t temp_show (struct device *dev,struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct adm1031_data *data =adm1031_update_device (dev);
@@ -697,7 +687,7 @@ static ssize_t show_temp(struct device *dev, (((data->ext_temp[nr] >> ((nr -1 ) *3 )) &7 ));return sprintf (buf,"%d\n" ,TEMP_FROM_REG_EXT (data->temp[nr], ext)); } -static ssize_t show_temp_offset (struct device *dev, +static ssize_t temp_offset_show (struct device *dev,struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;
@@ -705,30 +695,30 @@ static ssize_t show_temp_offset(struct device *dev,return sprintf (buf,"%d\n" ,TEMP_OFFSET_FROM_REG (data->temp_offset[nr])); } -static ssize_t show_temp_min (struct device *dev, +static ssize_t temp_min_show (struct device *dev,struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct adm1031_data *data =adm1031_update_device (dev);return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp_min[nr])); } -static ssize_t show_temp_max (struct device *dev, +static ssize_t temp_max_show (struct device *dev,struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct adm1031_data *data =adm1031_update_device (dev);return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp_max[nr])); } -static ssize_t show_temp_crit (struct device *dev, +static ssize_t temp_crit_show (struct device *dev,struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct adm1031_data *data =adm1031_update_device (dev);return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp_crit[nr])); } -static ssize_t set_temp_offset (struct device *dev, -struct device_attribute *attr,const char *buf, -size_t count) +static ssize_t temp_offset_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {struct adm1031_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -748,8 +738,9 @@ static ssize_t set_temp_offset(struct device *dev,mutex_unlock (&data->update_lock);return count; } -static ssize_t set_temp_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_min_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct adm1031_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -769,8 +760,9 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,mutex_unlock (&data->update_lock);return count; } -static ssize_t set_temp_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_max_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct adm1031_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -790,8 +782,9 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,mutex_unlock (&data->update_lock);return count; } -static ssize_t set_temp_crit (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_crit_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct adm1031_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -812,21 +805,21 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,return count; } -#define temp_reg (offset) \ -static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ - show_temp, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_offset, S_IRUGO | S_IWUSR, \ - show_temp_offset, set_temp_offset, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ - show_temp_min, set_temp_min, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ - show_temp_max, set_temp_max, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IRUGO | S_IWUSR, \ - show_temp_crit, set_temp_crit, offset - 1) - -temp_reg (1 ); -temp_reg (2 ); -temp_reg (3 ); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_offset, temp_offset, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp_crit, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_offset, temp_offset, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_crit, temp_crit, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_offset, temp_offset, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_crit, temp_crit, 2);/* Alarms */ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,
@@ -838,29 +831,29 @@ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,static DEVICE_ATTR_RO (alarms); -static ssize_t show_alarm (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t alarm_show (struct device *dev,struct device_attribute *attr, +char *buf) {int bitnr =to_sensor_dev_attr (attr)->index;struct adm1031_data *data =adm1031_update_device (dev);return sprintf (buf,"%d\n" , (data->alarm >> bitnr) &1 ); } -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 0); -static SENSOR_DEVICE_ATTR(fan1_fault, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 4); -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 5); -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 7); -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 8); -static SENSOR_DEVICE_ATTR(fan2_fault, S_IRUGO, show_alarm, NULL, 9); -static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_alarm, NULL, 10); -static SENSOR_DEVICE_ATTR(temp3_min_alarm, S_IRUGO, show_alarm, NULL, 11); -static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 12); -static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 13); -static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 14); +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 0); +static SENSOR_DEVICE_ATTR_RO(fan1_fault, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 2); +static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(temp2_crit_alarm, alarm, 4); +static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 5); +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 6); +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, 7); +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 8); +static SENSOR_DEVICE_ATTR_RO(fan2_fault, alarm, 9); +static SENSOR_DEVICE_ATTR_RO(temp3_max_alarm, alarm, 10); +static SENSOR_DEVICE_ATTR_RO(temp3_min_alarm, alarm, 11); +static SENSOR_DEVICE_ATTR_RO(temp3_crit_alarm, alarm, 12); +static SENSOR_DEVICE_ATTR_RO(temp3_fault, alarm, 13); +static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 14);/* Update Interval */ static const unsigned int update_intervals[] = {
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 6/16 hwmon: (lm87) Use permission specific SENSOR[_DEVICE]_ATTR variants
In reply to Guenter RoeckUse 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.
--- drivers/hwmon/lm87.c | 165 +++++++++++++++++++++++++++------------------------ 1 file changed, 87 insertions(+), 78 deletions(-)
drivers/hwmon/lm87.c +87 -78
@@ -276,8 +276,8 @@ static struct lm87_data *lm87_update_device(struct device *dev)* Sysfs stuff */ -static ssize_t show_in_input (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in_input_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct lm87_data *data =lm87_update_device (dev);int nr =to_sensor_dev_attr (attr)->index;
@@ -286,8 +286,8 @@ static ssize_t show_in_input(struct device *dev, struct device_attribute *attr, data->in_scale[nr])); } -static ssize_t show_in_min (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t in_min_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct lm87_data *data =lm87_update_device (dev);int nr =to_sensor_dev_attr (attr)->index;
@@ -296,8 +296,8 @@ static ssize_t show_in_min(struct device *dev, data->in_scale[nr])); } -static ssize_t show_in_max (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t in_max_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct lm87_data *data =lm87_update_device (dev);int nr =to_sensor_dev_attr (attr)->index;
@@ -306,8 +306,8 @@ static ssize_t show_in_max(struct device *dev, data->in_scale[nr])); } -static ssize_t set_in_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t in_min_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct i2c_client *client =dev_get_drvdata (dev);struct lm87_data *data =i2c_get_clientdata (client);
@@ -327,8 +327,8 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,return count; } -static ssize_t set_in_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t in_max_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct i2c_client *client =dev_get_drvdata (dev);struct lm87_data *data =i2c_get_clientdata (client);
@@ -348,23 +348,32 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,return count; } -#define set_in (offset) \ -static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ - show_in_input, NULL, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ - show_in_min, set_in_min, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ - show_in_max, set_in_max, offset) -set_in (0 ); -set_in (1 ); -set_in (2 ); -set_in (3 ); -set_in (4 ); -set_in (5 ); -set_in (6 ); -set_in (7 ); - -static ssize_t show_temp_input (struct device *dev, +static SENSOR_DEVICE_ATTR_RO(in0_input, in_input, 0); +static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0); +static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0); +static SENSOR_DEVICE_ATTR_RO(in1_input, in_input, 1); +static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1); +static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1); +static SENSOR_DEVICE_ATTR_RO(in2_input, in_input, 2); +static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2); +static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2); +static SENSOR_DEVICE_ATTR_RO(in3_input, in_input, 3); +static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3); +static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3); +static SENSOR_DEVICE_ATTR_RO(in4_input, in_input, 4); +static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4); +static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4); +static SENSOR_DEVICE_ATTR_RO(in5_input, in_input, 5); +static SENSOR_DEVICE_ATTR_RW(in5_min, in_min, 5); +static SENSOR_DEVICE_ATTR_RW(in5_max, in_max, 5); +static SENSOR_DEVICE_ATTR_RO(in6_input, in_input, 6); +static SENSOR_DEVICE_ATTR_RW(in6_min, in_min, 6); +static SENSOR_DEVICE_ATTR_RW(in6_max, in_max, 6); +static SENSOR_DEVICE_ATTR_RO(in7_input, in_input, 7); +static SENSOR_DEVICE_ATTR_RW(in7_min, in_min, 7); +static SENSOR_DEVICE_ATTR_RW(in7_max, in_max, 7); + +static ssize_t temp_input_show (struct device *dev,struct device_attribute *attr,char *buf) {struct lm87_data *data =lm87_update_device (dev);
@@ -373,7 +382,7 @@ static ssize_t show_temp_input(struct device *dev,return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp[nr])); } -static ssize_t show_temp_low (struct device *dev, +static ssize_t temp_low_show (struct device *dev,struct device_attribute *attr,char *buf) {struct lm87_data *data =lm87_update_device (dev);
@@ -383,7 +392,7 @@ static ssize_t show_temp_low(struct device *dev, TEMP_FROM_REG(data->temp_low[nr])); } -static ssize_t show_temp_high (struct device *dev, +static ssize_t temp_high_show (struct device *dev,struct device_attribute *attr,char *buf) {struct lm87_data *data =lm87_update_device (dev);
@@ -393,8 +402,9 @@ static ssize_t show_temp_high(struct device *dev, TEMP_FROM_REG(data->temp_high[nr])); } -static ssize_t set_temp_low (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_low_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct i2c_client *client =dev_get_drvdata (dev);struct lm87_data *data =i2c_get_clientdata (client);
@@ -413,8 +423,9 @@ static ssize_t set_temp_low(struct device *dev, struct device_attribute *attr,return count; } -static ssize_t set_temp_high (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_high_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct i2c_client *client =dev_get_drvdata (dev);struct lm87_data *data =i2c_get_clientdata (client);
@@ -433,16 +444,15 @@ static ssize_t set_temp_high(struct device *dev, struct device_attribute *attr,return count; } -#define set_temp (offset) \ -static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ - show_temp_input, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ - show_temp_high, set_temp_high, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ - show_temp_low, set_temp_low, offset - 1) -set_temp (1 ); -set_temp (2 ); -set_temp (3 ); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_input, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_low, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_high, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp_input, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_low, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_high, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp_input, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_low, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_high, 2);static ssize_t temp1_crit_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -460,9 +470,9 @@ static ssize_t temp2_crit_show(struct device *dev,static DEVICE_ATTR_RO (temp1_crit);static DEVICE_ATTR_RO (temp2_crit); -static DEVICE_ATTR(temp3_crit, S_IRUGO, temp2_crit_show, NULL); +static DEVICE_ATTR(temp3_crit, 0444, temp2_crit_show, NULL); -static ssize_t show_fan_input (struct device *dev, +static ssize_t fan_input_show (struct device *dev,struct device_attribute *attr,char *buf) {struct lm87_data *data =lm87_update_device (dev);
@@ -472,8 +482,8 @@ static ssize_t show_fan_input(struct device *dev, FAN_DIV_FROM_REG(data->fan_div[nr]))); } -static ssize_t show_fan_min (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t fan_min_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct lm87_data *data =lm87_update_device (dev);int nr =to_sensor_dev_attr (attr)->index;
@@ -482,8 +492,8 @@ static ssize_t show_fan_min(struct device *dev, FAN_DIV_FROM_REG(data->fan_div[nr]))); } -static ssize_t show_fan_div (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t fan_div_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct lm87_data *data =lm87_update_device (dev);int nr =to_sensor_dev_attr (attr)->index;
@@ -492,8 +502,9 @@ static ssize_t show_fan_div(struct device *dev, FAN_DIV_FROM_REG(data->fan_div[nr])); } -static ssize_t set_fan_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t fan_min_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct i2c_client *client =dev_get_drvdata (dev);struct lm87_data *data =i2c_get_clientdata (client);
@@ -519,8 +530,9 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,* of least surprise; the user doesn't expect the fan minimum to change just * because the divider changed. */ -static ssize_t set_fan_div (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t fan_div_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct i2c_client *client =dev_get_drvdata (dev);struct lm87_data *data =i2c_get_clientdata (client);
@@ -575,15 +587,12 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,return count; } -#define set_fan (offset) \ -static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ - show_fan_input, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ - show_fan_min, set_fan_min, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ - show_fan_div, set_fan_div, offset - 1) -set_fan (1 ); -set_fan (2 ); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan_input, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan_input, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1);static ssize_t alarms_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -653,28 +662,28 @@ static ssize_t aout_output_store(struct device *dev, }static DEVICE_ATTR_RW (aout_output); -static ssize_t show_alarm (struct device *dev,struct device_attribute *attr, +static ssize_t alarm_show (struct device *dev,struct device_attribute *attr,char *buf) {struct lm87_data *data =lm87_update_device (dev);int bitnr =to_sensor_dev_attr (attr)->index;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(in1_alarm, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); -static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 9); -static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 7); -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4); -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5); -static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 5); -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7); -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 14); -static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 15); +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0); +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2); +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 8); +static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 9); +static SENSOR_DEVICE_ATTR_RO(in6_alarm, alarm, 6); +static SENSOR_DEVICE_ATTR_RO(in7_alarm, alarm, 7); +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 4); +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 5); +static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, 5); +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 6); +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 7); +static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 14); +static SENSOR_DEVICE_ATTR_RO(temp3_fault, alarm, 15);/* * Real code
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 7/16 hwmon: (lm78) Use permission specific SENSOR[_DEVICE]_ATTR variants
In reply to Guenter RoeckUse 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.
--- drivers/hwmon/lm78.c | 114 +++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 58 deletions(-)
drivers/hwmon/lm78.c +56 -58
@@ -73,7 +73,6 @@ enum chips { lm78, lm79 };#define LM78_REG_CHIPID 0x49#define LM78_REG_I2C_ADDR 0x48 -/* * Conversions. Rounding and limit checking is only done on the TO_REG * variants.
@@ -147,15 +146,13 @@ struct lm78_data {u16 alarms;/* Register encoding, combined */ }; -static int lm78_read_value (struct lm78_data *data,u8 reg);static int lm78_write_value (struct lm78_data *data,u8 reg,u8 value);static struct lm78_data *lm78_update_device (struct device *dev);static void lm78_init_device (struct lm78_data *data); -/* 7 Voltages */ -static ssize_t show_in (struct device *dev,struct device_attribute *da, +static ssize_t in_show (struct device *dev,struct device_attribute *da,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (da);
@@ -163,7 +160,7 @@ static ssize_t show_in(struct device *dev, struct device_attribute *da,return sprintf (buf,"%d\n" ,IN_FROM_REG (data->in[attr->index])); } -static ssize_t show_in_min (struct device *dev,struct device_attribute *da, +static ssize_t in_min_show (struct device *dev,struct device_attribute *da,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (da);
@@ -171,7 +168,7 @@ static ssize_t show_in_min(struct device *dev, struct device_attribute *da,return sprintf (buf,"%d\n" ,IN_FROM_REG (data->in_min[attr->index])); } -static ssize_t show_in_max (struct device *dev,struct device_attribute *da, +static ssize_t in_max_show (struct device *dev,struct device_attribute *da,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (da);
@@ -179,8 +176,8 @@ static ssize_t show_in_max(struct device *dev, struct device_attribute *da,return sprintf (buf,"%d\n" ,IN_FROM_REG (data->in_max[attr->index])); } -static ssize_t set_in_min (struct device *dev,struct device_attribute *da, -const char *buf,size_t count) +static ssize_t in_min_store (struct device *dev,struct device_attribute *da, +const char *buf,size_t count) {struct sensor_device_attribute *attr =to_sensor_dev_attr (da);struct lm78_data *data =dev_get_drvdata (dev);
@@ -199,8 +196,8 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *da,return count; } -static ssize_t set_in_max (struct device *dev,struct device_attribute *da, -const char *buf,size_t count) +static ssize_t in_max_store (struct device *dev,struct device_attribute *da, +const char *buf,size_t count) {struct sensor_device_attribute *attr =to_sensor_dev_attr (da);struct lm78_data *data =dev_get_drvdata (dev);
@@ -219,21 +216,27 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *da,return count; } -#define show_in_offset (offset) \ -static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ - show_in, NULL, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ - show_in_min, set_in_min, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ - show_in_max, set_in_max, offset); - -show_in_offset (0 ); -show_in_offset (1 ); -show_in_offset (2 ); -show_in_offset (3 ); -show_in_offset (4 ); -show_in_offset (5 ); -show_in_offset (6 ); +static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0); +static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0); +static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0); +static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1); +static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1); +static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1); +static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2); +static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2); +static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2); +static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3); +static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3); +static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3); +static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4); +static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4); +static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4); +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 SENSOR_DEVICE_ATTR_RO(in6_input, in, 6); +static SENSOR_DEVICE_ATTR_RW(in6_min, in_min, 6); +static SENSOR_DEVICE_ATTR_RW(in6_max, in_max, 6);/* Temperature */ static ssize_t temp1_input_show(struct device *dev,
@@ -300,7 +303,7 @@ static DEVICE_ATTR_RW(temp1_max);static DEVICE_ATTR_RW (temp1_max_hyst);/* 3 Fans */ -static ssize_t show_fan (struct device *dev,struct device_attribute *da, +static ssize_t fan_show (struct device *dev,struct device_attribute *da,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (da);
@@ -310,7 +313,7 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *da, DIV_FROM_REG(data->fan_div[nr]))); } -static ssize_t show_fan_min (struct device *dev,struct device_attribute *da, +static ssize_t fan_min_show (struct device *dev,struct device_attribute *da,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (da);
@@ -320,8 +323,8 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute *da, DIV_FROM_REG(data->fan_div[nr]))); } -static ssize_t set_fan_min (struct device *dev,struct device_attribute *da, -const char *buf,size_t count) +static ssize_t fan_min_store (struct device *dev,struct device_attribute *da, +const char *buf,size_t count) {struct sensor_device_attribute *attr =to_sensor_dev_attr (da);struct lm78_data *data =dev_get_drvdata (dev);
@@ -340,7 +343,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *da,return count; } -static ssize_t show_fan_div (struct device *dev,struct device_attribute *da, +static ssize_t fan_div_show (struct device *dev,struct device_attribute *da,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (da);
@@ -354,8 +357,8 @@ static ssize_t show_fan_div(struct device *dev, struct device_attribute *da,* least surprise; the user doesn't expect the fan minimum to change just * because the divisor changed. */ -static ssize_t set_fan_div (struct device *dev,struct device_attribute *da, -const char *buf,size_t count) +static ssize_t fan_div_store (struct device *dev,struct device_attribute *da, +const char *buf,size_t count) {struct sensor_device_attribute *attr =to_sensor_dev_attr (da);struct lm78_data *data =dev_get_drvdata (dev);
@@ -413,22 +416,17 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *da,return count; } -#define show_fan_offset (offset) \ -static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ - show_fan, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ - show_fan_min, set_fan_min, offset - 1); - -show_fan_offset (1 ); -show_fan_offset (2 ); -show_fan_offset (3 ); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); +static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 2); +static SENSOR_DEVICE_ATTR_RW(fan3_min, fan_min, 2);/* Fan 3 divisor is locked in H/W */ -static SENSOR_DEVICE_ATTR(fan1_div, S_IRUGO | S_IWUSR, - show_fan_div, set_fan_div, 0); -static SENSOR_DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR, - show_fan_div, set_fan_div, 1); -static SENSOR_DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2); +static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0); +static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1); +static SENSOR_DEVICE_ATTR_RO(fan3_div, fan_div, 2);/* VID */ static ssize_t cpu0_vid_show(struct device *dev, struct device_attribute *da,
@@ -448,24 +446,24 @@ static ssize_t alarms_show(struct device *dev, struct device_attribute *da, }static DEVICE_ATTR_RO (alarms); -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) {struct lm78_data *data =lm78_update_device (dev);int nr =to_sensor_dev_attr (da)->index;return sprintf (buf,"%u\n" , (data->alarms >> nr) &1 ); } -static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); -static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); -static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 9); -static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 10); -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7); -static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 11); -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4); +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0); +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2); +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 8); +static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 9); +static SENSOR_DEVICE_ATTR_RO(in6_alarm, alarm, 10); +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 6); +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 7); +static SENSOR_DEVICE_ATTR_RO(fan3_alarm, alarm, 11); +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 4);static struct attribute *lm78_attrs[] = { &sensor_dev_attr_in0_input.dev_attr.attr,
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 8/16 hwmon: (lm85) Use permission specific SENSOR[_DEVICE]_ATTR variants
In reply to Guenter RoeckUse 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.
--- drivers/hwmon/lm85.c | 340 ++++++++++++++++++++++++++------------------------- 1 file changed, 174 insertions(+), 166 deletions(-)
drivers/hwmon/lm85.c +174 -166
@@ -165,7 +165,6 @@ static inline u16 FAN_TO_REG(unsigned long val)#define PWM_TO_REG (val) clamp_val(val, 0, 255)#define PWM_FROM_REG (val) (val) -/* * ZONEs have the following parameters: * Limit (low) temp, 1. degC
@@ -563,24 +562,25 @@ static struct lm85_data *lm85_update_device(struct device *dev) }/* 4 Fans */ -static ssize_t show_fan (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t fan_show (struct device *dev,struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);return sprintf (buf,"%d\n" ,FAN_FROM_REG (data->fan[nr])); } -static ssize_t show_fan_min (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t fan_min_show (struct device *dev,struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);return sprintf (buf,"%d\n" ,FAN_FROM_REG (data->fan_min[nr])); } -static ssize_t set_fan_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t fan_min_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -599,16 +599,14 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,return count; } -#define show_fan_offset (offset) \ -static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ - show_fan, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ - show_fan_min, set_fan_min, offset - 1) - -show_fan_offset (1 ); -show_fan_offset (2 ); -show_fan_offset (3 ); -show_fan_offset (4 ); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); +static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 2); +static SENSOR_DEVICE_ATTR_RW(fan3_min, fan_min, 2); +static SENSOR_DEVICE_ATTR_RO(fan4_input, fan, 3); +static SENSOR_DEVICE_ATTR_RW(fan4_min, fan_min, 3);/* vid, vrm, alarms */
@@ -667,44 +665,44 @@ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,static DEVICE_ATTR_RO (alarms); -static ssize_t show_alarm (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t alarm_show (struct device *dev,struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);return sprintf (buf,"%u\n" , (data->alarms >> nr) &1 ); } -static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); -static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); -static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 18); -static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 16); -static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 17); -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4); -static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_alarm, NULL, 14); -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5); -static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 15); -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 10); -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 11); -static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 12); -static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, 13); +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0); +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2); +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 8); +static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 18); +static SENSOR_DEVICE_ATTR_RO(in6_alarm, alarm, 16); +static SENSOR_DEVICE_ATTR_RO(in7_alarm, alarm, 17); +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 4); +static SENSOR_DEVICE_ATTR_RO(temp1_fault, alarm, 14); +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 5); +static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, 6); +static SENSOR_DEVICE_ATTR_RO(temp3_fault, alarm, 15); +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 10); +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 11); +static SENSOR_DEVICE_ATTR_RO(fan3_alarm, alarm, 12); +static SENSOR_DEVICE_ATTR_RO(fan4_alarm, alarm, 13);/* pwm */ -static ssize_t show_pwm (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t pwm_show (struct device *dev,struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);return sprintf (buf,"%d\n" ,PWM_FROM_REG (data->pwm[nr])); } -static ssize_t set_pwm (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t pwm_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -723,8 +721,8 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,return count; } -static ssize_t show_pwm_enable (struct device *dev,struct device_attribute - *attr,char *buf) +static ssize_t pwm_enable_show (struct device *dev, +struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);
@@ -745,8 +743,9 @@ static ssize_t show_pwm_enable(struct device *dev, struct device_attributereturn sprintf (buf,"%d\n" , enable); } -static ssize_t set_pwm_enable (struct device *dev,struct device_attribute - *attr,const char *buf,size_t count) +static ssize_t pwm_enable_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -788,8 +787,8 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attributereturn count; } -static ssize_t show_pwm_freq (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t pwm_freq_show (struct device *dev, +struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);
@@ -804,8 +803,9 @@ static ssize_t show_pwm_freq(struct device *dev,return sprintf (buf,"%d\n" , freq); } -static ssize_t set_pwm_freq (struct device *dev, -struct device_attribute *attr,const char *buf,size_t count) +static ssize_t pwm_freq_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -841,22 +841,20 @@ static ssize_t set_pwm_freq(struct device *dev,return count; } -#define show_pwm_reg (offset) \ -static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ - show_pwm, set_pwm, offset - 1); \ -static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ - show_pwm_enable, set_pwm_enable, offset - 1); \ -static SENSOR_DEVICE_ATTR(pwm##offset##_freq, S_IRUGO | S_IWUSR, \ - show_pwm_freq, set_pwm_freq, offset - 1) - -show_pwm_reg (1 ); -show_pwm_reg (2 ); -show_pwm_reg (3 ); +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); +static SENSOR_DEVICE_ATTR_RW(pwm1_enable, pwm_enable, 0); +static SENSOR_DEVICE_ATTR_RW(pwm1_freq, pwm_freq, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1); +static SENSOR_DEVICE_ATTR_RW(pwm2_enable, pwm_enable, 1); +static SENSOR_DEVICE_ATTR_RW(pwm2_freq, pwm_freq, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, 2); +static SENSOR_DEVICE_ATTR_RW(pwm3_enable, pwm_enable, 2); +static SENSOR_DEVICE_ATTR_RW(pwm3_freq, pwm_freq, 2);/* Voltages */ -static ssize_t show_in (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in_show (struct device *dev,struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);
@@ -864,16 +862,16 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr, data->in_ext[nr])); } -static ssize_t show_in_min (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in_min_show (struct device *dev,struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);return sprintf (buf,"%d\n" ,INS_FROM_REG (nr, data->in_min[nr])); } -static ssize_t set_in_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t in_min_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -892,16 +890,16 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,return count; } -static ssize_t show_in_max (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in_max_show (struct device *dev,struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);return sprintf (buf,"%d\n" ,INS_FROM_REG (nr, data->in_max[nr])); } -static ssize_t set_in_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t in_max_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -920,27 +918,35 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,return count; } -#define show_in_reg (offset) \ -static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ - show_in, NULL, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ - show_in_min, set_in_min, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ - show_in_max, set_in_max, offset) - -show_in_reg (0 ); -show_in_reg (1 ); -show_in_reg (2 ); -show_in_reg (3 ); -show_in_reg (4 ); -show_in_reg (5 ); -show_in_reg (6 ); -show_in_reg (7 ); +static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0); +static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0); +static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0); +static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1); +static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1); +static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1); +static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2); +static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2); +static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2); +static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3); +static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3); +static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3); +static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4); +static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4); +static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4); +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 SENSOR_DEVICE_ATTR_RO(in6_input, in, 6); +static SENSOR_DEVICE_ATTR_RW(in6_min, in_min, 6); +static SENSOR_DEVICE_ATTR_RW(in6_max, in_max, 6); +static SENSOR_DEVICE_ATTR_RO(in7_input, in, 7); +static SENSOR_DEVICE_ATTR_RW(in7_min, in_min, 7); +static SENSOR_DEVICE_ATTR_RW(in7_max, in_max, 7);/* Temps */ -static ssize_t show_temp (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t temp_show (struct device *dev,struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);
@@ -948,16 +954,17 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr, data->temp_ext[nr])); } -static ssize_t show_temp_min (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t temp_min_show (struct device *dev, +struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp_min[nr])); } -static ssize_t set_temp_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_min_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -979,16 +986,17 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,return count; } -static ssize_t show_temp_max (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t temp_max_show (struct device *dev, +struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp_max[nr])); } -static ssize_t set_temp_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_max_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -1010,31 +1018,30 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,return count; } -#define show_temp_reg (offset) \ -static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ - show_temp, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ - show_temp_min, set_temp_min, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ - show_temp_max, set_temp_max, offset - 1); - -show_temp_reg (1 ); -show_temp_reg (2 ); -show_temp_reg (3 ); - +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2);/* Automatic PWM control */ -static ssize_t show_pwm_auto_channels (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t pwm_auto_channels_show (struct device *dev, +struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);return sprintf (buf,"%d\n" ,ZONE_FROM_REG (data->autofan[nr].config)); } -static ssize_t set_pwm_auto_channels (struct device *dev, -struct device_attribute *attr,const char *buf,size_t count) +static ssize_t pwm_auto_channels_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -1055,16 +1062,17 @@ static ssize_t set_pwm_auto_channels(struct device *dev,return count; } -static ssize_t show_pwm_auto_pwm_min (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t pwm_auto_pwm_min_show (struct device *dev, +struct device_attribute *attr,char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);return sprintf (buf,"%d\n" ,PWM_FROM_REG (data->autofan[nr].min_pwm)); } -static ssize_t set_pwm_auto_pwm_min (struct device *dev, -struct device_attribute *attr,const char *buf,size_t count) +static ssize_t pwm_auto_pwm_min_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -1084,16 +1092,18 @@ static ssize_t set_pwm_auto_pwm_min(struct device *dev,return count; } -static ssize_t show_pwm_auto_pwm_minctl (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t pwm_auto_pwm_minctl_show (struct device *dev, +struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);return sprintf (buf,"%d\n" , data->autofan[nr].min_off); } -static ssize_t set_pwm_auto_pwm_minctl (struct device *dev, -struct device_attribute *attr,const char *buf,size_t count) +static ssize_t pwm_auto_pwm_minctl_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -1117,25 +1127,21 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev,return count; } -#define pwm_auto (offset) \ -static SENSOR_DEVICE_ATTR(pwm##offset##_auto_channels, \ - S_IRUGO | S_IWUSR, show_pwm_auto_channels, \ - set_pwm_auto_channels, offset - 1); \ -static SENSOR_DEVICE_ATTR(pwm##offset##_auto_pwm_min, \ - S_IRUGO | S_IWUSR, show_pwm_auto_pwm_min, \ - set_pwm_auto_pwm_min, offset - 1); \ -static SENSOR_DEVICE_ATTR(pwm##offset##_auto_pwm_minctl, \ - S_IRUGO | S_IWUSR, show_pwm_auto_pwm_minctl, \ - set_pwm_auto_pwm_minctl, offset - 1) - -pwm_auto (1 ); -pwm_auto (2 ); -pwm_auto (3 ); +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_channels, pwm_auto_channels, 0); +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_pwm_min, pwm_auto_pwm_min, 0); +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_pwm_minctl, pwm_auto_pwm_minctl, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_channels, pwm_auto_channels, 1); +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_pwm_min, pwm_auto_pwm_min, 1); +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_pwm_minctl, pwm_auto_pwm_minctl, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_channels, pwm_auto_channels, 2); +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_pwm_min, pwm_auto_pwm_min, 2); +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_pwm_minctl, pwm_auto_pwm_minctl, 2);/* Temperature settings for automatic PWM control */ -static ssize_t show_temp_auto_temp_off (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t temp_auto_temp_off_show (struct device *dev, +struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);
@@ -1143,8 +1149,9 @@ static ssize_t show_temp_auto_temp_off(struct device *dev, HYST_FROM_REG(data->zone[nr].hyst)); } -static ssize_t set_temp_auto_temp_off (struct device *dev, -struct device_attribute *attr,const char *buf,size_t count) +static ssize_t temp_auto_temp_off_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -1172,16 +1179,18 @@ static ssize_t set_temp_auto_temp_off(struct device *dev,return count; } -static ssize_t show_temp_auto_temp_min (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t temp_auto_temp_min_show (struct device *dev, +struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->zone[nr].limit)); } -static ssize_t set_temp_auto_temp_min (struct device *dev, -struct device_attribute *attr,const char *buf,size_t count) +static ssize_t temp_auto_temp_min_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -1210,8 +1219,9 @@ static ssize_t set_temp_auto_temp_min(struct device *dev,return count; } -static ssize_t show_temp_auto_temp_max (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t temp_auto_temp_max_show (struct device *dev, +struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);
@@ -1219,8 +1229,9 @@ static ssize_t show_temp_auto_temp_max(struct device *dev, RANGE_FROM_REG(data->zone[nr].range)); } -static ssize_t set_temp_auto_temp_max (struct device *dev, -struct device_attribute *attr,const char *buf,size_t count) +static ssize_t temp_auto_temp_max_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -1245,16 +1256,18 @@ static ssize_t set_temp_auto_temp_max(struct device *dev,return count; } -static ssize_t show_temp_auto_temp_crit (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t temp_auto_temp_crit_show (struct device *dev, +struct device_attribute *attr, +char *buf) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =lm85_update_device (dev);return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->zone[nr].critical)); } -static ssize_t set_temp_auto_temp_crit (struct device *dev, -struct device_attribute *attr,const char *buf,size_t count) +static ssize_t temp_auto_temp_crit_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {int nr =to_sensor_dev_attr (attr)->index;struct lm85_data *data =dev_get_drvdata (dev);
@@ -1274,23 +1287,18 @@ static ssize_t set_temp_auto_temp_crit(struct device *dev,return count; } -#define temp_auto (offset) \ -static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_off, \ - S_IRUGO | S_IWUSR, show_temp_auto_temp_off, \ - set_temp_auto_temp_off, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_min, \ - S_IRUGO | S_IWUSR, show_temp_auto_temp_min, \ - set_temp_auto_temp_min, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_max, \ - S_IRUGO | S_IWUSR, show_temp_auto_temp_max, \ - set_temp_auto_temp_max, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_crit, \ - S_IRUGO | S_IWUSR, show_temp_auto_temp_crit, \ - set_temp_auto_temp_crit, offset - 1); - -temp_auto (1 ); -temp_auto (2 ); -temp_auto (3 ); +static SENSOR_DEVICE_ATTR_RW(temp1_auto_temp_off, temp_auto_temp_off, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_auto_temp_min, temp_auto_temp_min, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_auto_temp_max, temp_auto_temp_max, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_auto_temp_crit, temp_auto_temp_crit, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_auto_temp_off, temp_auto_temp_off, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_auto_temp_min, temp_auto_temp_min, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_auto_temp_max, temp_auto_temp_max, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_auto_temp_crit, temp_auto_temp_crit, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_auto_temp_off, temp_auto_temp_off, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_auto_temp_min, temp_auto_temp_min, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_auto_temp_max, temp_auto_temp_max, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_auto_temp_crit, temp_auto_temp_crit, 2);static struct attribute *lm85_attributes[] = { &sensor_dev_attr_fan1_input.dev_attr.attr,
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 9/16 hwmon: (via686a) Use permission specific SENSOR[_DEVICE]_ATTR variants
In reply to Guenter RoeckUse 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.
--- drivers/hwmon/via686a.c | 148 ++++++++++++++++++++++++------------------------ 1 file changed, 73 insertions(+), 75 deletions(-)
drivers/hwmon/via686a.c +73 -75
@@ -47,7 +47,6 @@#include <linux/acpi.h> #include <linux/io.h> -/* * If force_addr is set to anything different from 0, we forcibly enable * the device at the given address.
@@ -355,32 +354,32 @@ static void via686a_init_device(struct via686a_data *data);/* following are the sysfs callback functions */ /* 7 voltage sensors */ -static ssize_t show_in (struct device *dev,struct device_attribute *da, -char *buf) { +static ssize_t in_show (struct device *dev,struct device_attribute *da, +char *buf) {struct via686a_data *data =via686a_update_device (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;return sprintf (buf,"%ld\n" ,IN_FROM_REG (data->in[nr], nr)); } -static ssize_t show_in_min (struct device *dev,struct device_attribute *da, -char *buf) { +static ssize_t in_min_show (struct device *dev,struct device_attribute *da, +char *buf) {struct via686a_data *data =via686a_update_device (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;return sprintf (buf,"%ld\n" ,IN_FROM_REG (data->in_min[nr], nr)); } -static ssize_t show_in_max (struct device *dev,struct device_attribute *da, -char *buf) { +static ssize_t in_max_show (struct device *dev,struct device_attribute *da, +char *buf) {struct via686a_data *data =via686a_update_device (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;return sprintf (buf,"%ld\n" ,IN_FROM_REG (data->in_max[nr], nr)); } -static ssize_t set_in_min (struct device *dev,struct device_attribute *da, -const char *buf,size_t count) { +static ssize_t in_min_store (struct device *dev,struct device_attribute *da, +const char *buf,size_t count) {struct via686a_data *data =dev_get_drvdata (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;
@@ -398,8 +397,8 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *da,mutex_unlock (&data->update_lock);return count; } -static ssize_t set_in_max (struct device *dev,struct device_attribute *da, -const char *buf,size_t count) { +static ssize_t in_max_store (struct device *dev,struct device_attribute *da, +const char *buf,size_t count) {struct via686a_data *data =dev_get_drvdata (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;
@@ -417,44 +416,48 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *da,mutex_unlock (&data->update_lock);return count; } -#define show_in_offset (offset) \ -static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ - show_in, NULL, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ - show_in_min, set_in_min, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ - show_in_max, set_in_max, offset); -show_in_offset (0 ); -show_in_offset (1 ); -show_in_offset (2 ); -show_in_offset (3 ); -show_in_offset (4 ); +static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0); +static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0); +static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0); +static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1); +static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1); +static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1); +static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2); +static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2); +static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2); +static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3); +static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3); +static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3); +static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4); +static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4); +static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4);/* 3 temperatures */ -static ssize_t show_temp (struct device *dev,struct device_attribute *da, -char *buf) { +static ssize_t temp_show (struct device *dev,struct device_attribute *da, +char *buf) {struct via686a_data *data =via686a_update_device (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;return sprintf (buf,"%ld\n" ,TEMP_FROM_REG10 (data->temp[nr])); } -static ssize_t show_temp_over (struct device *dev,struct device_attribute *da, -char *buf) { +static ssize_t temp_over_show (struct device *dev,struct device_attribute *da, +char *buf) {struct via686a_data *data =via686a_update_device (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;return sprintf (buf,"%ld\n" ,TEMP_FROM_REG (data->temp_over[nr])); } -static ssize_t show_temp_hyst (struct device *dev,struct device_attribute *da, -char *buf) { +static ssize_t temp_hyst_show (struct device *dev,struct device_attribute *da, +char *buf) {struct via686a_data *data =via686a_update_device (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;return sprintf (buf,"%ld\n" ,TEMP_FROM_REG (data->temp_hyst[nr])); } -static ssize_t set_temp_over (struct device *dev,struct device_attribute *da, -const char *buf,size_t count) { +static ssize_t temp_over_store (struct device *dev, +struct device_attribute *da,const char *buf, +size_t count) {struct via686a_data *data =dev_get_drvdata (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;
@@ -472,8 +475,9 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *da,mutex_unlock (&data->update_lock);return count; } -static ssize_t set_temp_hyst (struct device *dev,struct device_attribute *da, -const char *buf,size_t count) { +static ssize_t temp_hyst_store (struct device *dev, +struct device_attribute *da,const char *buf, +size_t count) {struct via686a_data *data =dev_get_drvdata (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;
@@ -491,29 +495,28 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *da,mutex_unlock (&data->update_lock);return count; } -#define show_temp_offset (offset) \ -static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ - show_temp, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ - show_temp_over, set_temp_over, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ - show_temp_hyst, set_temp_hyst, offset - 1); -show_temp_offset (1 ); -show_temp_offset (2 ); -show_temp_offset (3 ); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_over, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, temp_hyst, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_over, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max_hyst, temp_hyst, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_over, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max_hyst, temp_hyst, 2);/* 2 Fans */ -static ssize_t show_fan (struct device *dev,struct device_attribute *da, -char *buf) { +static ssize_t fan_show (struct device *dev,struct device_attribute *da, +char *buf) {struct via686a_data *data =via686a_update_device (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;return sprintf (buf,"%d\n" ,FAN_FROM_REG (data->fan[nr],DIV_FROM_REG (data->fan_div[nr]))); } -static ssize_t show_fan_min (struct device *dev,struct device_attribute *da, -char *buf) { +static ssize_t fan_min_show (struct device *dev,struct device_attribute *da, +char *buf) {struct via686a_data *data =via686a_update_device (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;
@@ -521,15 +524,15 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute *da,FAN_FROM_REG (data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr]))); } -static ssize_t show_fan_div (struct device *dev,struct device_attribute *da, -char *buf) { +static ssize_t fan_div_show (struct device *dev,struct device_attribute *da, +char *buf) {struct via686a_data *data =via686a_update_device (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;return sprintf (buf,"%d\n" ,DIV_FROM_REG (data->fan_div[nr])); } -static ssize_t set_fan_min (struct device *dev,struct device_attribute *da, -const char *buf,size_t count) { +static ssize_t fan_min_store (struct device *dev,struct device_attribute *da, +const char *buf,size_t count) {struct via686a_data *data =dev_get_drvdata (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;
@@ -546,8 +549,8 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *da,mutex_unlock (&data->update_lock);return count; } -static ssize_t set_fan_div (struct device *dev,struct device_attribute *da, -const char *buf,size_t count) { +static ssize_t fan_div_store (struct device *dev,struct device_attribute *da, +const char *buf,size_t count) {struct via686a_data *data =dev_get_drvdata (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);int nr = attr->index;
@@ -568,16 +571,12 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *da,return count; } -#define show_fan_offset (offset) \ -static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ - show_fan, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ - show_fan_min, set_fan_min, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ - show_fan_div, set_fan_div, offset - 1); - -show_fan_offset (1 ); -show_fan_offset (2 ); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1);/* Alarms */ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,
@@ -589,23 +588,23 @@ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,static DEVICE_ATTR_RO (alarms); -static ssize_t show_alarm (struct device *dev,struct device_attribute *attr, +static ssize_t alarm_show (struct device *dev,struct device_attribute *attr,char *buf) {int bitnr =to_sensor_dev_attr (attr)->index;struct via686a_data *data =via686a_update_device (dev);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(in1_alarm, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4); -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 11); -static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 15); -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7); +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0); +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2); +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 8); +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 4); +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 11); +static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, 15); +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 6); +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 7);static ssize_t name_show (struct device *dev,struct device_attribute *devattr,char *buf)
@@ -676,7 +675,6 @@ static struct platform_driver via686a_driver = { .remove = via686a_remove, }; -/* This is called when the module is loaded */ static int via686a_probe (struct platform_device *pdev) {
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 10/16 hwmon: (menf21bmc_hwmon) Use permission specific SENSOR[_DEVICE]_ATTR variants
In reply to Guenter RoeckUse 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.
--- drivers/hwmon/menf21bmc_hwmon.c | 43 +++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 19 deletions(-)
drivers/hwmon/menf21bmc_hwmon.c +24 -19
@@ -101,7 +101,7 @@ static int menf21bmc_hwmon_get_volt_limits(struct menf21bmc_hwmon *drv_data) }static ssize_t -show_label (struct device *dev,struct device_attribute *devattr,char *buf) +label_show (struct device *dev,struct device_attribute *devattr,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);
@@ -109,7 +109,7 @@ show_label(struct device *dev, struct device_attribute *devattr, char *buf) }static ssize_t -show_in (struct device *dev,struct device_attribute *devattr,char *buf) +in_show (struct device *dev,struct device_attribute *devattr,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct menf21bmc_hwmon *drv_data =menf21bmc_hwmon_update (dev);
@@ -121,7 +121,7 @@ show_in(struct device *dev, struct device_attribute *devattr, char *buf) }static ssize_t -show_min (struct device *dev,struct device_attribute *devattr,char *buf) +min_show (struct device *dev,struct device_attribute *devattr,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct menf21bmc_hwmon *drv_data =dev_get_drvdata (dev);
@@ -130,7 +130,7 @@ show_min(struct device *dev, struct device_attribute *devattr, char *buf) }static ssize_t -show_max (struct device *dev,struct device_attribute *devattr,char *buf) +max_show (struct device *dev,struct device_attribute *devattr,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct menf21bmc_hwmon *drv_data =dev_get_drvdata (dev);
@@ -138,21 +138,26 @@ show_max(struct device *dev, struct device_attribute *devattr, char *buf)return sprintf (buf,"%d\n" , drv_data->in_max[attr->index]); } -#define create_voltage_sysfs (idx) \ -static SENSOR_DEVICE_ATTR(in##idx##_input, S_IRUGO, \ - show_in, NULL, idx); \ -static SENSOR_DEVICE_ATTR(in##idx##_min, S_IRUGO, \ - show_min, NULL, idx); \ -static SENSOR_DEVICE_ATTR(in##idx##_max, S_IRUGO, \ - show_max, NULL, idx); \ -static SENSOR_DEVICE_ATTR(in##idx##_label, S_IRUGO, \ - show_label, NULL, idx); - -create_voltage_sysfs (0 ); -create_voltage_sysfs (1 ); -create_voltage_sysfs (2 ); -create_voltage_sysfs (3 ); -create_voltage_sysfs (4 ); +static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0); +static SENSOR_DEVICE_ATTR_RO(in0_min, min, 0); +static SENSOR_DEVICE_ATTR_RO(in0_max, max, 0); +static SENSOR_DEVICE_ATTR_RO(in0_label, label, 0); +static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1); +static SENSOR_DEVICE_ATTR_RO(in1_min, min, 1); +static SENSOR_DEVICE_ATTR_RO(in1_max, max, 1); +static SENSOR_DEVICE_ATTR_RO(in1_label, label, 1); +static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2); +static SENSOR_DEVICE_ATTR_RO(in2_min, min, 2); +static SENSOR_DEVICE_ATTR_RO(in2_max, max, 2); +static SENSOR_DEVICE_ATTR_RO(in2_label, label, 2); +static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3); +static SENSOR_DEVICE_ATTR_RO(in3_min, min, 3); +static SENSOR_DEVICE_ATTR_RO(in3_max, max, 3); +static SENSOR_DEVICE_ATTR_RO(in3_label, label, 3); +static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4); +static SENSOR_DEVICE_ATTR_RO(in4_min, min, 4); +static SENSOR_DEVICE_ATTR_RO(in4_max, max, 4); +static SENSOR_DEVICE_ATTR_RO(in4_label, label, 4);static struct attribute *menf21bmc_hwmon_attrs[] = { &sensor_dev_attr_in0_input.dev_attr.attr,
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 11/16 hwmon: (sis5595) Use permission specific SENSOR[_DEVICE]_ATTR variants
In reply to Guenter RoeckUse 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.
--- drivers/hwmon/sis5595.c | 92 +++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 48 deletions(-)
drivers/hwmon/sis5595.c +44 -48
@@ -67,7 +67,6 @@#include <linux/acpi.h> #include <linux/io.h> -/* * If force_addr is set to anything different from 0, we forcibly enable * the device at the given address.
@@ -222,7 +221,7 @@ static struct platform_driver sis5595_driver = { };/* 4 Voltages */ -static ssize_t show_in (struct device *dev,struct device_attribute *da, +static ssize_t in_show (struct device *dev,struct device_attribute *da,char *buf) {struct sis5595_data *data =sis5595_update_device (dev);
@@ -231,7 +230,7 @@ static ssize_t show_in(struct device *dev, struct device_attribute *da,return sprintf (buf,"%d\n" ,IN_FROM_REG (data->in[nr])); } -static ssize_t show_in_min (struct device *dev,struct device_attribute *da, +static ssize_t in_min_show (struct device *dev,struct device_attribute *da,char *buf) {struct sis5595_data *data =sis5595_update_device (dev);
@@ -240,7 +239,7 @@ static ssize_t show_in_min(struct device *dev, struct device_attribute *da,return sprintf (buf,"%d\n" ,IN_FROM_REG (data->in_min[nr])); } -static ssize_t show_in_max (struct device *dev,struct device_attribute *da, +static ssize_t in_max_show (struct device *dev,struct device_attribute *da,char *buf) {struct sis5595_data *data =sis5595_update_device (dev);
@@ -249,8 +248,8 @@ static ssize_t show_in_max(struct device *dev, struct device_attribute *da,return sprintf (buf,"%d\n" ,IN_FROM_REG (data->in_max[nr])); } -static ssize_t set_in_min (struct device *dev,struct device_attribute *da, -const char *buf,size_t count) +static ssize_t in_min_store (struct device *dev,struct device_attribute *da, +const char *buf,size_t count) {struct sis5595_data *data =dev_get_drvdata (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);
@@ -269,8 +268,8 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *da,return count; } -static ssize_t set_in_max (struct device *dev,struct device_attribute *da, -const char *buf,size_t count) +static ssize_t in_max_store (struct device *dev,struct device_attribute *da, +const char *buf,size_t count) {struct sis5595_data *data =dev_get_drvdata (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);
@@ -289,19 +288,21 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *da,return count; } -#define show_in_offset (offset) \ -static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ - show_in, NULL, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ - show_in_min, set_in_min, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ - show_in_max, set_in_max, offset); - -show_in_offset (0 ); -show_in_offset (1 ); -show_in_offset (2 ); -show_in_offset (3 ); -show_in_offset (4 ); +static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0); +static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0); +static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0); +static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1); +static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1); +static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1); +static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2); +static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2); +static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2); +static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3); +static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3); +static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3); +static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4); +static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4); +static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4);/* Temperature */ static ssize_t temp1_input_show(struct device *dev,
@@ -368,7 +369,7 @@ static DEVICE_ATTR_RW(temp1_max);static DEVICE_ATTR_RW (temp1_max_hyst);/* 2 Fans */ -static ssize_t show_fan (struct device *dev,struct device_attribute *da, +static ssize_t fan_show (struct device *dev,struct device_attribute *da,char *buf) {struct sis5595_data *data =sis5595_update_device (dev);
@@ -378,7 +379,7 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *da, DIV_FROM_REG(data->fan_div[nr]))); } -static ssize_t show_fan_min (struct device *dev,struct device_attribute *da, +static ssize_t fan_min_show (struct device *dev,struct device_attribute *da,char *buf) {struct sis5595_data *data =sis5595_update_device (dev);
@@ -388,8 +389,8 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute *da, DIV_FROM_REG(data->fan_div[nr]))); } -static ssize_t set_fan_min (struct device *dev,struct device_attribute *da, -const char *buf,size_t count) +static ssize_t fan_min_store (struct device *dev,struct device_attribute *da, +const char *buf,size_t count) {struct sis5595_data *data =dev_get_drvdata (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);
@@ -408,7 +409,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *da,return count; } -static ssize_t show_fan_div (struct device *dev,struct device_attribute *da, +static ssize_t fan_div_show (struct device *dev,struct device_attribute *da,char *buf) {struct sis5595_data *data =sis5595_update_device (dev);
@@ -423,8 +424,8 @@ static ssize_t show_fan_div(struct device *dev, struct device_attribute *da,* least surprise; the user doesn't expect the fan minimum to change just * because the divisor changed. */ -static ssize_t set_fan_div (struct device *dev,struct device_attribute *da, -const char *buf,size_t count) +static ssize_t fan_div_store (struct device *dev,struct device_attribute *da, +const char *buf,size_t count) {struct sis5595_data *data =dev_get_drvdata (dev);struct sensor_device_attribute *attr =to_sensor_dev_attr (da);
@@ -480,16 +481,12 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *da,return count; } -#define show_fan_offset (offset) \ -static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ - show_fan, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ - show_fan_min, set_fan_min, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ - show_fan_div, set_fan_div, offset - 1); - -show_fan_offset (1 ); -show_fan_offset (2 ); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1);/* Alarms */ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,
@@ -500,21 +497,21 @@ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr, }static DEVICE_ATTR_RO (alarms); -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) {struct sis5595_data *data =sis5595_update_device (dev);int nr =to_sensor_dev_attr (da)->index;return sprintf (buf,"%u\n" , (data->alarms >> nr) &1 ); } -static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); -static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 15); -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7); -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 15); +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0); +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2); +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 15); +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 6); +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 7); +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 15);static ssize_t name_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -673,7 +670,6 @@ static int sis5595_remove(struct platform_device *pdev)return 0 ; } -/* ISA access must be locked explicitly. */ static int sis5595_read_value (struct sis5595_data *data,u8 reg) {
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 12/16 hwmon: (vt8231) Use permission specific SENSOR[_DEVICE]_ATTR variants
In reply to Guenter RoeckUse 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.
--- drivers/hwmon/vt8231.c | 166 +++++++++++++++++++++++++------------------------ 1 file changed, 85 insertions(+), 81 deletions(-)
drivers/hwmon/vt8231.c +85 -81
@@ -192,8 +192,8 @@ static inline void vt8231_write_value(struct vt8231_data *data, u8 reg, }/* following are the sysfs callback functions */ -static ssize_t show_in (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -202,8 +202,8 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" , ((data->in[nr] -3 ) *10000 ) /958 ); } -static ssize_t show_in_min (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in_min_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -212,8 +212,8 @@ static ssize_t show_in_min(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" , ((data->in_min[nr] -3 ) *10000 ) /958 ); } -static ssize_t show_in_max (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in_max_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -222,8 +222,8 @@ static ssize_t show_in_max(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" , (((data->in_max[nr] -3 ) *10000 ) /958 )); } -static ssize_t set_in_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t in_min_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -242,8 +242,8 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,return count; } -static ssize_t set_in_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t in_max_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -330,19 +330,21 @@ static ssize_t in5_max_store(struct device *dev,return count; } -#define define_voltage_sysfs (offset) \ -static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ - show_in, NULL, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ - show_in_min, set_in_min, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ - show_in_max, set_in_max, offset) - -define_voltage_sysfs (0 ); -define_voltage_sysfs (1 ); -define_voltage_sysfs (2 ); -define_voltage_sysfs (3 ); -define_voltage_sysfs (4 ); +static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0); +static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0); +static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0); +static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1); +static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1); +static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1); +static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2); +static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2); +static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2); +static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3); +static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3); +static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3); +static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4); +static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4); +static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4);static DEVICE_ATTR_RO (in5_input);static DEVICE_ATTR_RW (in5_min);
@@ -407,8 +409,8 @@ static ssize_t temp1_max_hyst_store(struct device *dev,return count; } -static ssize_t show_temp (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t temp_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -416,8 +418,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp[nr])); } -static ssize_t show_temp_max (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t temp_max_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -425,8 +427,8 @@ static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" ,TEMP_MAXMIN_FROM_REG (data->temp_max[nr])); } -static ssize_t show_temp_min (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t temp_min_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -434,8 +436,9 @@ static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" ,TEMP_MAXMIN_FROM_REG (data->temp_min[nr])); } -static ssize_t set_temp_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_max_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -453,8 +456,9 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,mutex_unlock (&data->update_lock);return count; } -static ssize_t set_temp_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_min_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -477,27 +481,30 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,* Note that these map the Linux temperature sensor numbering (1-6) to the VIA * temperature sensor numbering (0-5) */ -#define define_temperature_sysfs (offset) \ -static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ - show_temp, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ - show_temp_max, set_temp_max, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ - show_temp_min, set_temp_min, offset - 1)static DEVICE_ATTR_RO (temp1_input);static DEVICE_ATTR_RW (temp1_max);static DEVICE_ATTR_RW (temp1_max_hyst); -define_temperature_sysfs (2 ); -define_temperature_sysfs (3 ); -define_temperature_sysfs (4 ); -define_temperature_sysfs (5 ); -define_temperature_sysfs (6 ); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max_hyst, temp_min, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max_hyst, temp_min, 2); +static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 3); +static SENSOR_DEVICE_ATTR_RW(temp4_max, temp_max, 3); +static SENSOR_DEVICE_ATTR_RW(temp4_max_hyst, temp_min, 3); +static SENSOR_DEVICE_ATTR_RO(temp5_input, temp, 4); +static SENSOR_DEVICE_ATTR_RW(temp5_max, temp_max, 4); +static SENSOR_DEVICE_ATTR_RW(temp5_max_hyst, temp_min, 4); +static SENSOR_DEVICE_ATTR_RO(temp6_input, temp, 5); +static SENSOR_DEVICE_ATTR_RW(temp6_max, temp_max, 5); +static SENSOR_DEVICE_ATTR_RW(temp6_max_hyst, temp_min, 5);/* Fans */ -static ssize_t show_fan (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t fan_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -506,8 +513,8 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *attr, DIV_FROM_REG(data->fan_div[nr]))); } -static ssize_t show_fan_min (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t fan_min_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -516,8 +523,8 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, DIV_FROM_REG(data->fan_div[nr]))); } -static ssize_t show_fan_div (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t fan_div_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -525,8 +532,9 @@ static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" ,DIV_FROM_REG (data->fan_div[nr])); } -static ssize_t set_fan_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t fan_min_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -545,8 +553,9 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,return count; } -static ssize_t set_fan_div (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t fan_div_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct vt8231_data *data =dev_get_drvdata (dev);struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);
@@ -593,17 +602,12 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,return count; } - -#define define_fan_sysfs (offset) \ -static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ - show_fan, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ - show_fan_div, set_fan_div, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ - show_fan_min, set_fan_min, offset - 1) - -define_fan_sysfs (1 ); -define_fan_sysfs (2 ); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1);/* Alarms */ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,
@@ -614,27 +618,27 @@ static ssize_t alarms_show(struct device *dev, struct device_attribute *attr, }static DEVICE_ATTR_RO (alarms); -static ssize_t show_alarm (struct device *dev,struct device_attribute *attr, +static ssize_t alarm_show (struct device *dev,struct device_attribute *attr,char *buf) {int bitnr =to_sensor_dev_attr (attr)->index;struct vt8231_data *data =vt8231_update_device (dev);return sprintf (buf,"%u\n" , (data->alarms >> bitnr) &1 ); } -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4); -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 11); -static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 0); -static SENSOR_DEVICE_ATTR(temp4_alarm, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(temp5_alarm, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(temp6_alarm, S_IRUGO, show_alarm, NULL, 8); -static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 11); -static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 0); -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); -static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7); +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 4); +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 11); +static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, 0); +static SENSOR_DEVICE_ATTR_RO(temp4_alarm, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(temp5_alarm, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(temp6_alarm, alarm, 8); +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 11); +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 0); +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 8); +static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 2); +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 6); +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 7);static ssize_t name_show (struct device *dev,struct device_attribute *devattr,char *buf)
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 13/16 hwmon: (smsc47m192) Use permission specific SENSOR[_DEVICE]_ATTR variants
In reply to Guenter RoeckUse 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.
--- drivers/hwmon/smsc47m192.c | 146 ++++++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 68 deletions(-)
drivers/hwmon/smsc47m192.c +78 -68
@@ -179,8 +179,8 @@ static struct smsc47m192_data *smsc47m192_update_device(struct device *dev) }/* Voltages */ -static ssize_t show_in (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -188,8 +188,8 @@ static ssize_t show_in(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" ,IN_FROM_REG (data->in[nr], nr)); } -static ssize_t show_in_min (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in_min_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -197,8 +197,8 @@ static ssize_t show_in_min(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" ,IN_FROM_REG (data->in_min[nr], nr)); } -static ssize_t show_in_max (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t in_max_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -206,8 +206,8 @@ static ssize_t show_in_max(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" ,IN_FROM_REG (data->in_max[nr], nr)); } -static ssize_t set_in_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t in_min_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -228,8 +228,8 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,return count; } -static ssize_t set_in_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t in_max_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -250,26 +250,34 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,return count; } -#define show_in_offset (offset) \ -static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ - show_in, NULL, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ - show_in_min, set_in_min, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ - show_in_max, set_in_max, offset); - -show_in_offset(0) -show_in_offset(1) -show_in_offset(2) -show_in_offset(3) -show_in_offset(4) -show_in_offset(5) -show_in_offset(6) -show_in_offset (7 ) +static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0); +static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0); +static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0); +static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1); +static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1); +static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1); +static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2); +static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2); +static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2); +static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3); +static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3); +static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3); +static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4); +static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4); +static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4); +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 SENSOR_DEVICE_ATTR_RO(in6_input, in, 6); +static SENSOR_DEVICE_ATTR_RW(in6_min, in_min, 6); +static SENSOR_DEVICE_ATTR_RW(in6_max, in_max, 6); +static SENSOR_DEVICE_ATTR_RO(in7_input, in, 7); +static SENSOR_DEVICE_ATTR_RW(in7_min, in_min, 7); +static SENSOR_DEVICE_ATTR_RW(in7_max, in_max, 7);/* Temperatures */ -static ssize_t show_temp (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t temp_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -277,8 +285,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp[nr])); } -static ssize_t show_temp_min (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t temp_min_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -286,8 +294,8 @@ static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp_min[nr])); } -static ssize_t show_temp_max (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t temp_max_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -295,8 +303,9 @@ static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp_max[nr])); } -static ssize_t set_temp_min (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_min_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -317,8 +326,9 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,return count; } -static ssize_t set_temp_max (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t temp_max_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -339,8 +349,8 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,return count; } -static ssize_t show_temp_offset (struct device *dev,struct device_attribute - *attr,char *buf) +static ssize_t temp_offset_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -348,8 +358,9 @@ static ssize_t show_temp_offset(struct device *dev, struct device_attributereturn sprintf (buf,"%d\n" ,TEMP_FROM_REG (data->temp_offset[nr])); } -static ssize_t set_temp_offset (struct device *dev,struct device_attribute - *attr,const char *buf,size_t count) +static ssize_t temp_offset_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -385,19 +396,18 @@ static ssize_t set_temp_offset(struct device *dev, struct device_attributereturn count; } -#define show_temp_index (index) \ -static SENSOR_DEVICE_ATTR(temp##index##_input, S_IRUGO, \ - show_temp, NULL, index-1); \ -static SENSOR_DEVICE_ATTR(temp##index##_min, S_IRUGO | S_IWUSR, \ - show_temp_min, set_temp_min, index-1); \ -static SENSOR_DEVICE_ATTR(temp##index##_max, S_IRUGO | S_IWUSR, \ - show_temp_max, set_temp_max, index-1); \ -static SENSOR_DEVICE_ATTR(temp##index##_offset, S_IRUGO | S_IWUSR, \ - show_temp_offset, set_temp_offset, index-1); - -show_temp_index(1) -show_temp_index(2) -show_temp_index (3 ) +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_offset, temp_offset, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_offset, temp_offset, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_offset, temp_offset, 2);/* VID */ static ssize_t cpu0_vid_show(struct device *dev,
@@ -434,8 +444,8 @@ static ssize_t vrm_store(struct device *dev, struct device_attribute *attr,static DEVICE_ATTR_RW (vrm);/* Alarms */ -static ssize_t show_alarm (struct device *dev,struct device_attribute *attr, -char *buf) +static ssize_t alarm_show (struct device *dev,struct device_attribute *attr, +char *buf) {struct sensor_device_attribute *sensor_attr =to_sensor_dev_attr (attr);int nr = sensor_attr->index;
@@ -443,19 +453,19 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,return sprintf (buf,"%u\n" , (data->alarms & nr) ?1 :0 ); } -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 0x0010); -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 0x0020); -static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 0x0040); -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 0x4000); -static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 0x8000); -static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0x0001); -static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 0x0002); -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 0x0004); -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 0x0008); -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 0x0100); -static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 0x0200); -static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 0x0400); -static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 0x0800); +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 0x0010); +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 0x0020); +static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, 0x0040); +static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 0x4000); +static SENSOR_DEVICE_ATTR_RO(temp3_fault, alarm, 0x8000); +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0x0001); +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 0x0002); +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 0x0004); +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 0x0008); +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 0x0100); +static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 0x0200); +static SENSOR_DEVICE_ATTR_RO(in6_alarm, alarm, 0x0400); +static SENSOR_DEVICE_ATTR_RO(in7_alarm, alarm, 0x0800);static struct attribute *smsc47m192_attributes[] = { &sensor_dev_attr_in0_input.dev_attr.attr,
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 14/16 hwmon: (smsc47m1) Use permission specific SENSOR[_DEVICE]_ATTR variants
In reply to Guenter RoeckUse 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.
--- drivers/hwmon/smsc47m1.c | 78 +++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 37 deletions(-)
drivers/hwmon/smsc47m1.c +41 -37
@@ -207,8 +207,8 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,return data; } -static ssize_t get_fan (struct device *dev,struct device_attribute - *devattr,char *buf) +static ssize_t fan_show (struct device *dev,struct device_attribute *devattr, +char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct smsc47m1_data *data =smsc47m1_update_device (dev,0 );
@@ -226,8 +226,8 @@ static ssize_t get_fan(struct device *dev, struct device_attributereturn sprintf (buf,"%d\n" , rpm); } -static ssize_t get_fan_min (struct device *dev,struct device_attribute - *devattr,char *buf) +static ssize_t fan_min_show (struct device *dev, +struct device_attribute *devattr,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct smsc47m1_data *data =smsc47m1_update_device (dev,0 );
@@ -237,32 +237,32 @@ static ssize_t get_fan_min(struct device *dev, struct device_attributereturn sprintf (buf,"%d\n" , rpm); } -static ssize_t get_fan_div (struct device *dev,struct device_attribute - *devattr,char *buf) +static ssize_t fan_div_show (struct device *dev, +struct device_attribute *devattr,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct smsc47m1_data *data =smsc47m1_update_device (dev,0 );return sprintf (buf,"%d\n" ,DIV_FROM_REG (data->fan_div[attr->index])); } -static ssize_t get_fan_alarm (struct device *dev,struct device_attribute - *devattr,char *buf) +static ssize_t fan_alarm_show (struct device *dev, +struct device_attribute *devattr,char *buf) {int bitnr =to_sensor_dev_attr (devattr)->index;struct smsc47m1_data *data =smsc47m1_update_device (dev,0 );return sprintf (buf,"%u\n" , (data->alarms >> bitnr) &1 ); } -static ssize_t get_pwm (struct device *dev,struct device_attribute - *devattr,char *buf) +static ssize_t pwm_show (struct device *dev,struct device_attribute *devattr, +char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct smsc47m1_data *data =smsc47m1_update_device (dev,0 );return sprintf (buf,"%d\n" ,PWM_FROM_REG (data->pwm[attr->index])); } -static ssize_t get_pwm_en (struct device *dev,struct device_attribute - *devattr,char *buf) +static ssize_t pwm_en_show (struct device *dev, +struct device_attribute *devattr,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct smsc47m1_data *data =smsc47m1_update_device (dev,0 );
@@ -276,8 +276,9 @@ static ssize_t alarms_show(struct device *dev,return sprintf (buf,"%d\n" , data->alarms); } -static ssize_t set_fan_min (struct device *dev,struct device_attribute - *devattr,const char *buf,size_t count) +static ssize_t fan_min_store (struct device *dev, +struct device_attribute *devattr, +const char *buf,size_t count) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct smsc47m1_data *data =dev_get_drvdata (dev);
@@ -312,8 +313,9 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute* of least surprise; the user doesn't expect the fan minimum to change just * because the divider changed. */ -static ssize_t set_fan_div (struct device *dev,struct device_attribute - *devattr,const char *buf,size_t count) +static ssize_t fan_div_store (struct device *dev, +struct device_attribute *devattr, +const char *buf,size_t count) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct smsc47m1_data *data =dev_get_drvdata (dev);
@@ -375,8 +377,8 @@ static ssize_t set_fan_div(struct device *dev, struct device_attributereturn count; } -static ssize_t set_pwm (struct device *dev,struct device_attribute - *devattr,const char *buf,size_t count) +static ssize_t pwm_store (struct device *dev,struct device_attribute *devattr, +const char *buf,size_t count) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct smsc47m1_data *data =dev_get_drvdata (dev);
@@ -401,8 +403,9 @@ static ssize_t set_pwm(struct device *dev, struct device_attributereturn count; } -static ssize_t set_pwm_en (struct device *dev,struct device_attribute - *devattr,const char *buf,size_t count) +static ssize_t pwm_en_store (struct device *dev, +struct device_attribute *devattr,const char *buf, +size_t count) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct smsc47m1_data *data =dev_get_drvdata (dev);
@@ -427,23 +430,24 @@ static ssize_t set_pwm_en(struct device *dev, struct device_attributereturn count; } -#define fan_present (offset) \ -static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, get_fan, \ - NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ - get_fan_min, set_fan_min, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ - get_fan_div, set_fan_div, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_alarm, S_IRUGO, get_fan_alarm, \ - NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ - get_pwm, set_pwm, offset - 1); \ -static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ - get_pwm_en, set_pwm_en, offset - 1) - -fan_present (1 ); -fan_present (2 ); -fan_present (3 ); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0); +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, fan_alarm, 0); +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); +static SENSOR_DEVICE_ATTR_RW(pwm1_enable, pwm_en, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1); +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, fan_alarm, 1); +static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1); +static SENSOR_DEVICE_ATTR_RW(pwm2_enable, pwm_en, 1); +static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 2); +static SENSOR_DEVICE_ATTR_RW(fan3_min, fan_min, 2); +static SENSOR_DEVICE_ATTR_RW(fan3_div, fan_div, 2); +static SENSOR_DEVICE_ATTR_RO(fan3_alarm, fan_alarm, 2); +static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, 2); +static SENSOR_DEVICE_ATTR_RW(pwm3_enable, pwm_en, 2);static DEVICE_ATTR_RO (alarms);
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 15/16 hwmon: (w83627hf) Use permission specific SENSOR[_DEVICE]_ATTR variants
In reply to Guenter RoeckUse 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.
--- drivers/hwmon/w83627hf.c | 257 +++++++++++++++++++++-------------------------- 1 file changed, 116 insertions(+), 141 deletions(-)
drivers/hwmon/w83627hf.c +116 -141
@@ -396,7 +396,6 @@ struct w83627hf_data {#endif }; -static int w83627hf_probe (struct platform_device *pdev);static int w83627hf_remove (struct platform_device *pdev);
@@ -482,28 +481,28 @@ static struct platform_driver w83627hf_driver = { };static ssize_t -show_in_input (struct device *dev,struct device_attribute *devattr,char *buf) +in_input_show (struct device *dev,struct device_attribute *devattr,char *buf) {int nr =to_sensor_dev_attr (devattr)->index;struct w83627hf_data *data =w83627hf_update_device (dev);return sprintf (buf,"%ld\n" , (long )IN_FROM_REG (data->in[nr])); }static ssize_t -show_in_min (struct device *dev,struct device_attribute *devattr,char *buf) +in_min_show (struct device *dev,struct device_attribute *devattr,char *buf) {int nr =to_sensor_dev_attr (devattr)->index;struct w83627hf_data *data =w83627hf_update_device (dev);return sprintf (buf,"%ld\n" , (long )IN_FROM_REG (data->in_min[nr])); }static ssize_t -show_in_max (struct device *dev,struct device_attribute *devattr,char *buf) +in_max_show (struct device *dev,struct device_attribute *devattr,char *buf) {int nr =to_sensor_dev_attr (devattr)->index;struct w83627hf_data *data =w83627hf_update_device (dev);return sprintf (buf,"%ld\n" , (long )IN_FROM_REG (data->in_max[nr])); }static ssize_t -store_in_min (struct device *dev,struct device_attribute *devattr, +in_min_store (struct device *dev,struct device_attribute *devattr,const char *buf,size_t count) {int nr =to_sensor_dev_attr (devattr)->index;
@@ -522,7 +521,7 @@ store_in_min(struct device *dev, struct device_attribute *devattr,return count; }static ssize_t -store_in_max (struct device *dev,struct device_attribute *devattr, +in_max_store (struct device *dev,struct device_attribute *devattr,const char *buf,size_t count) {int nr =to_sensor_dev_attr (devattr)->index;
@@ -540,22 +539,31 @@ store_in_max(struct device *dev, struct device_attribute *devattr,mutex_unlock (&data->update_lock);return count; } -#define sysfs_vin_decl (offset) \ -static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ - show_in_input, NULL, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO|S_IWUSR, \ - show_in_min, store_in_min, offset); \ -static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO|S_IWUSR, \ - show_in_max, store_in_max, offset); - -sysfs_vin_decl (1 ); -sysfs_vin_decl (2 ); -sysfs_vin_decl (3 ); -sysfs_vin_decl (4 ); -sysfs_vin_decl (5 ); -sysfs_vin_decl (6 ); -sysfs_vin_decl (7 ); -sysfs_vin_decl (8 ); + +static SENSOR_DEVICE_ATTR_RO(in1_input, in_input, 1); +static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1); +static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1); +static SENSOR_DEVICE_ATTR_RO(in2_input, in_input, 2); +static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2); +static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2); +static SENSOR_DEVICE_ATTR_RO(in3_input, in_input, 3); +static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3); +static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3); +static SENSOR_DEVICE_ATTR_RO(in4_input, in_input, 4); +static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4); +static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4); +static SENSOR_DEVICE_ATTR_RO(in5_input, in_input, 5); +static SENSOR_DEVICE_ATTR_RW(in5_min, in_min, 5); +static SENSOR_DEVICE_ATTR_RW(in5_max, in_max, 5); +static SENSOR_DEVICE_ATTR_RO(in6_input, in_input, 6); +static SENSOR_DEVICE_ATTR_RW(in6_min, in_min, 6); +static SENSOR_DEVICE_ATTR_RW(in6_max, in_max, 6); +static SENSOR_DEVICE_ATTR_RO(in7_input, in_input, 7); +static SENSOR_DEVICE_ATTR_RW(in7_min, in_min, 7); +static SENSOR_DEVICE_ATTR_RW(in7_max, in_max, 7); +static SENSOR_DEVICE_ATTR_RO(in8_input, in_input, 8); +static SENSOR_DEVICE_ATTR_RW(in8_min, in_min, 8); +static SENSOR_DEVICE_ATTR_RW(in8_max, in_max, 8);/* use a different set of functions for in0 */ static ssize_t show_in_0 (struct w83627hf_data *data,char *buf,u8 reg)
@@ -661,7 +669,8 @@ static DEVICE_ATTR_RW(in0_min);static DEVICE_ATTR_RW (in0_max);static ssize_t -show_fan_input (struct device *dev,struct device_attribute *devattr,char *buf) +fan_input_show (struct device *dev,struct device_attribute *devattr, +char *buf) {int nr =to_sensor_dev_attr (devattr)->index;struct w83627hf_data *data =w83627hf_update_device (dev);
@@ -669,7 +678,7 @@ show_fan_input(struct device *dev, struct device_attribute *devattr, char *buf) (long)DIV_FROM_REG(data->fan_div[nr]))); }static ssize_t -show_fan_min (struct device *dev,struct device_attribute *devattr,char *buf) +fan_min_show (struct device *dev,struct device_attribute *devattr,char *buf) {int nr =to_sensor_dev_attr (devattr)->index;struct w83627hf_data *data =w83627hf_update_device (dev);
@@ -677,7 +686,7 @@ show_fan_min(struct device *dev, struct device_attribute *devattr, char *buf) (long)DIV_FROM_REG(data->fan_div[nr]))); }static ssize_t -store_fan_min (struct device *dev,struct device_attribute *devattr, +fan_min_store (struct device *dev,struct device_attribute *devattr,const char *buf,size_t count) {int nr =to_sensor_dev_attr (devattr)->index;
@@ -697,18 +706,16 @@ store_fan_min(struct device *dev, struct device_attribute *devattr,mutex_unlock (&data->update_lock);return count; } -#define sysfs_fan_decl (offset) \ -static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ - show_fan_input, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ - show_fan_min, store_fan_min, offset - 1); -sysfs_fan_decl (1 ); -sysfs_fan_decl (2 ); -sysfs_fan_decl (3 ); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan_input, 0); +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan_input, 1); +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); +static SENSOR_DEVICE_ATTR_RO(fan3_input, fan_input, 2); +static SENSOR_DEVICE_ATTR_RW(fan3_min, fan_min, 2);static ssize_t -show_temp (struct device *dev,struct device_attribute *devattr,char *buf) +temp_show (struct device *dev,struct device_attribute *devattr,char *buf) {int nr =to_sensor_dev_attr (devattr)->index;struct w83627hf_data *data =w83627hf_update_device (dev);
@@ -719,8 +726,7 @@ show_temp(struct device *dev, struct device_attribute *devattr, char *buf) }static ssize_t -show_temp_max (struct device *dev,struct device_attribute *devattr, -char *buf) +temp_max_show (struct device *dev,struct device_attribute *devattr,char *buf) {int nr =to_sensor_dev_attr (devattr)->index;struct w83627hf_data *data =w83627hf_update_device (dev);
@@ -731,7 +737,7 @@ show_temp_max(struct device *dev, struct device_attribute *devattr, }static ssize_t -show_temp_max_hyst (struct device *dev,struct device_attribute *devattr, +temp_max_hyst_show (struct device *dev,struct device_attribute *devattr,char *buf) {int nr =to_sensor_dev_attr (devattr)->index;
@@ -743,7 +749,7 @@ show_temp_max_hyst(struct device *dev, struct device_attribute *devattr, }static ssize_t -store_temp_max (struct device *dev,struct device_attribute *devattr, +temp_max_store (struct device *dev,struct device_attribute *devattr,const char *buf,size_t count) {int nr =to_sensor_dev_attr (devattr)->index;
@@ -765,7 +771,7 @@ store_temp_max(struct device *dev, struct device_attribute *devattr, }static ssize_t -store_temp_max_hyst (struct device *dev,struct device_attribute *devattr, +temp_max_hyst_store (struct device *dev,struct device_attribute *devattr,const char *buf,size_t count) {int nr =to_sensor_dev_attr (devattr)->index;
@@ -786,17 +792,15 @@ store_temp_max_hyst(struct device *dev, struct device_attribute *devattr,return count; } -#define sysfs_temp_decl (offset) \ -static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ - show_temp, NULL, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO|S_IWUSR, \ - show_temp_max, store_temp_max, offset - 1); \ -static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO|S_IWUSR, \ - show_temp_max_hyst, store_temp_max_hyst, offset - 1); - -sysfs_temp_decl (1 ); -sysfs_temp_decl (2 ); -sysfs_temp_decl (3 ); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); +static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, temp_max_hyst, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); +static SENSOR_DEVICE_ATTR_RW(temp2_max_hyst, temp_max_hyst, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2); +static SENSOR_DEVICE_ATTR_RW(temp3_max_hyst, temp_max_hyst, 2);static ssize_t cpu0_vid_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -841,27 +845,27 @@ alarms_show(struct device *dev, struct device_attribute *attr, char *buf)static DEVICE_ATTR_RO (alarms);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) {struct w83627hf_data *data =w83627hf_update_device (dev);int bitnr =to_sensor_dev_attr (attr)->index;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(in1_alarm, S_IRUGO, show_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); -static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 9); -static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 10); -static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 16); -static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 17); -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6); -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7); -static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 11); -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4); -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5); -static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13); +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0); +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1); +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2); +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3); +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 8); +static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 9); +static SENSOR_DEVICE_ATTR_RO(in6_alarm, alarm, 10); +static SENSOR_DEVICE_ATTR_RO(in7_alarm, alarm, 16); +static SENSOR_DEVICE_ATTR_RO(in8_alarm, alarm, 17); +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 6); +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 7); +static SENSOR_DEVICE_ATTR_RO(fan3_alarm, alarm, 11); +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 4); +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 5); +static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, 13);static ssize_t beep_mask_show (struct device *dev,struct device_attribute *attr,char *buf)
@@ -902,7 +906,7 @@ beep_mask_store(struct device *dev, struct device_attribute *attr,static DEVICE_ATTR_RW (beep_mask);static ssize_t -show_beep (struct device *dev,struct device_attribute *attr,char *buf) +beep_show (struct device *dev,struct device_attribute *attr,char *buf) {struct w83627hf_data *data =w83627hf_update_device (dev);int bitnr =to_sensor_dev_attr (attr)->index;
@@ -910,8 +914,8 @@ show_beep(struct device *dev, struct device_attribute *attr, char *buf) }static ssize_t -store_beep (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +beep_store (struct device *dev,struct device_attribute *attr,const char *buf, +size_t count) {struct w83627hf_data *data =dev_get_drvdata (dev);int bitnr =to_sensor_dev_attr (attr)->index;
@@ -959,41 +963,25 @@ store_beep(struct device *dev, struct device_attribute *attr,return count; } -static SENSOR_DEVICE_ATTR(in0_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 0); -static SENSOR_DEVICE_ATTR(in1_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 1); -static SENSOR_DEVICE_ATTR(in2_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 2); -static SENSOR_DEVICE_ATTR(in3_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 3); -static SENSOR_DEVICE_ATTR(in4_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 8); -static SENSOR_DEVICE_ATTR(in5_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 9); -static SENSOR_DEVICE_ATTR(in6_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 10); -static SENSOR_DEVICE_ATTR(in7_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 16); -static SENSOR_DEVICE_ATTR(in8_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 17); -static SENSOR_DEVICE_ATTR(fan1_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 6); -static SENSOR_DEVICE_ATTR(fan2_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 7); -static SENSOR_DEVICE_ATTR(fan3_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 11); -static SENSOR_DEVICE_ATTR(temp1_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 4); -static SENSOR_DEVICE_ATTR(temp2_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 5); -static SENSOR_DEVICE_ATTR(temp3_beep, S_IRUGO | S_IWUSR, - show_beep, store_beep, 13); -static SENSOR_DEVICE_ATTR(beep_enable, S_IRUGO | S_IWUSR, - show_beep, store_beep, 15); +static SENSOR_DEVICE_ATTR_RW(in0_beep, beep, 0); +static SENSOR_DEVICE_ATTR_RW(in1_beep, beep, 1); +static SENSOR_DEVICE_ATTR_RW(in2_beep, beep, 2); +static SENSOR_DEVICE_ATTR_RW(in3_beep, beep, 3); +static SENSOR_DEVICE_ATTR_RW(in4_beep, beep, 8); +static SENSOR_DEVICE_ATTR_RW(in5_beep, beep, 9); +static SENSOR_DEVICE_ATTR_RW(in6_beep, beep, 10); +static SENSOR_DEVICE_ATTR_RW(in7_beep, beep, 16); +static SENSOR_DEVICE_ATTR_RW(in8_beep, beep, 17); +static SENSOR_DEVICE_ATTR_RW(fan1_beep, beep, 6); +static SENSOR_DEVICE_ATTR_RW(fan2_beep, beep, 7); +static SENSOR_DEVICE_ATTR_RW(fan3_beep, beep, 11); +static SENSOR_DEVICE_ATTR_RW(temp1_beep, beep, 4); +static SENSOR_DEVICE_ATTR_RW(temp2_beep, beep, 5); +static SENSOR_DEVICE_ATTR_RW(temp3_beep, beep, 13); +static SENSOR_DEVICE_ATTR_RW(beep_enable, beep, 15);static ssize_t -show_fan_div (struct device *dev,struct device_attribute *devattr,char *buf) +fan_div_show (struct device *dev,struct device_attribute *devattr,char *buf) {int nr =to_sensor_dev_attr (devattr)->index;struct w83627hf_data *data =w83627hf_update_device (dev);
@@ -1007,7 +995,7 @@ show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf)* because the divisor changed. */ static ssize_t -store_fan_div (struct device *dev,struct device_attribute *devattr, +fan_div_store (struct device *dev,struct device_attribute *devattr,const char *buf,size_t count) {int nr =to_sensor_dev_attr (devattr)->index;
@@ -1047,15 +1035,12 @@ store_fan_div(struct device *dev, struct device_attribute *devattr,return count; } -static SENSOR_DEVICE_ATTR(fan1_div, S_IRUGO|S_IWUSR, - show_fan_div, store_fan_div, 0); -static SENSOR_DEVICE_ATTR(fan2_div, S_IRUGO|S_IWUSR, - show_fan_div, store_fan_div, 1); -static SENSOR_DEVICE_ATTR(fan3_div, S_IRUGO|S_IWUSR, - show_fan_div, store_fan_div, 2); +static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0); +static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1); +static SENSOR_DEVICE_ATTR_RW(fan3_div, fan_div, 2);static ssize_t -show_pwm (struct device *dev,struct device_attribute *devattr,char *buf) +pwm_show (struct device *dev,struct device_attribute *devattr,char *buf) {int nr =to_sensor_dev_attr (devattr)->index;struct w83627hf_data *data =w83627hf_update_device (dev);
@@ -1063,7 +1048,7 @@ show_pwm(struct device *dev, struct device_attribute *devattr, char *buf) }static ssize_t -store_pwm (struct device *dev,struct device_attribute *devattr, +pwm_store (struct device *dev,struct device_attribute *devattr,const char *buf,size_t count) {int nr =to_sensor_dev_attr (devattr)->index;
@@ -1096,12 +1081,13 @@ store_pwm(struct device *dev, struct device_attribute *devattr,return count; } -static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0); -static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 1); -static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 2); +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, 2);static ssize_t -show_pwm_enable (struct device *dev,struct device_attribute *devattr,char *buf) +pwm_enable_show (struct device *dev,struct device_attribute *devattr, +char *buf) {int nr =to_sensor_dev_attr (devattr)->index;struct w83627hf_data *data =w83627hf_update_device (dev);
@@ -1109,8 +1095,8 @@ show_pwm_enable(struct device *dev, struct device_attribute *devattr, char *buf) }static ssize_t -store_pwm_enable (struct device *dev,struct device_attribute *devattr, -const char *buf,size_t count) +pwm_enable_store (struct device *dev,struct device_attribute *devattr, +const char *buf,size_t count) {int nr =to_sensor_dev_attr (devattr)->index;struct w83627hf_data *data =dev_get_drvdata (dev);
@@ -1134,15 +1120,12 @@ store_pwm_enable(struct device *dev, struct device_attribute *devattr,return count; } -static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO|S_IWUSR, show_pwm_enable, - store_pwm_enable, 0); -static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO|S_IWUSR, show_pwm_enable, - store_pwm_enable, 1); -static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable, - store_pwm_enable, 2); +static SENSOR_DEVICE_ATTR_RW(pwm1_enable, pwm_enable, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2_enable, pwm_enable, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3_enable, pwm_enable, 2);static ssize_t -show_pwm_freq (struct device *dev,struct device_attribute *devattr,char *buf) +pwm_freq_show (struct device *dev,struct device_attribute *devattr,char *buf) {int nr =to_sensor_dev_attr (devattr)->index;struct w83627hf_data *data =w83627hf_update_device (dev);
@@ -1155,7 +1138,7 @@ show_pwm_freq(struct device *dev, struct device_attribute *devattr, char *buf) }static ssize_t -store_pwm_freq (struct device *dev,struct device_attribute *devattr, +pwm_freq_store (struct device *dev,struct device_attribute *devattr,const char *buf,size_t count) {int nr =to_sensor_dev_attr (devattr)->index;
@@ -1186,15 +1169,12 @@ store_pwm_freq(struct device *dev, struct device_attribute *devattr,return count; } -static SENSOR_DEVICE_ATTR(pwm1_freq, S_IRUGO|S_IWUSR, - show_pwm_freq, store_pwm_freq, 0); -static SENSOR_DEVICE_ATTR(pwm2_freq, S_IRUGO|S_IWUSR, - show_pwm_freq, store_pwm_freq, 1); -static SENSOR_DEVICE_ATTR(pwm3_freq, S_IRUGO|S_IWUSR, - show_pwm_freq, store_pwm_freq, 2); +static SENSOR_DEVICE_ATTR_RW(pwm1_freq, pwm_freq, 0); +static SENSOR_DEVICE_ATTR_RW(pwm2_freq, pwm_freq, 1); +static SENSOR_DEVICE_ATTR_RW(pwm3_freq, pwm_freq, 2);static ssize_t -show_temp_type (struct device *dev,struct device_attribute *devattr, +temp_type_show (struct device *dev,struct device_attribute *devattr,char *buf) {int nr =to_sensor_dev_attr (devattr)->index;
@@ -1203,7 +1183,7 @@ show_temp_type(struct device *dev, struct device_attribute *devattr, }static ssize_t -store_temp_type (struct device *dev,struct device_attribute *devattr, +temp_type_store (struct device *dev,struct device_attribute *devattr,const char *buf,size_t count) {int nr =to_sensor_dev_attr (devattr)->index;
@@ -1258,13 +1238,9 @@ store_temp_type(struct device *dev, struct device_attribute *devattr,return count; } -#define sysfs_temp_type (offset) \ -static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \ - show_temp_type, store_temp_type, offset - 1); - -sysfs_temp_type (1 ); -sysfs_temp_type (2 ); -sysfs_temp_type (3 ); +static SENSOR_DEVICE_ATTR_RW(temp1_type, temp_type, 0); +static SENSOR_DEVICE_ATTR_RW(temp2_type, temp_type, 1); +static SENSOR_DEVICE_ATTR_RW(temp3_type, temp_type, 2);static ssize_t name_show (struct device *dev,struct device_attribute *devattr,char *buf)
@@ -1595,7 +1571,6 @@ static int w83627hf_remove(struct platform_device *pdev)return 0 ; } -/* Registers 0x50-0x5f are banked */ static inline void w83627hf_set_bank (struct w83627hf_data *data,u16 reg) {
Signature · 1 line
2.7.4
Guenter Roeck
maintainerPATCH 16/16 hwmon: (adm1029) Use permission specific [SENSOR_][DEVICE_]ATTR variants
In reply to Guenter RoeckUse [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.
--- drivers/hwmon/adm1029.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-)
drivers/hwmon/adm1029.c +21 -20
@@ -166,7 +166,7 @@ static struct adm1029_data *adm1029_update_device(struct device *dev)*/ static ssize_t -show_temp (struct device *dev,struct device_attribute *devattr,char *buf) +temp_show (struct device *dev,struct device_attribute *devattr,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct adm1029_data *data =adm1029_update_device (dev);
@@ -175,7 +175,7 @@ show_temp(struct device *dev, struct device_attribute *devattr, char *buf) }static ssize_t -show_fan (struct device *dev,struct device_attribute *devattr,char *buf) +fan_show (struct device *dev,struct device_attribute *devattr,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct adm1029_data *data =adm1029_update_device (dev);
@@ -193,7 +193,7 @@ show_fan(struct device *dev, struct device_attribute *devattr, char *buf) }static ssize_t -show_fan_div (struct device *dev,struct device_attribute *devattr,char *buf) +fan_div_show (struct device *dev,struct device_attribute *devattr,char *buf) {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr);struct adm1029_data *data =adm1029_update_device (dev);
@@ -203,8 +203,9 @@ show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf)return sprintf (buf,"%d\n" ,DIV_FROM_REG (data->fan_div[attr->index])); } -static ssize_t set_fan_div (struct device *dev,struct device_attribute *devattr, -const char *buf,size_t count) +static ssize_t fan_div_store (struct device *dev, +struct device_attribute *devattr, +const char *buf,size_t count) {struct adm1029_data *data =dev_get_drvdata (dev);struct i2c_client *client = data->client;
@@ -254,26 +255,26 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *devattr, }/* Access rights on sysfs. */ -static SENSOR_DEVICE_ATTR(temp1_input, 0444, show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_input, 0444, show_temp, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_input, 0444, show_temp, NULL, 2); +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); -static SENSOR_DEVICE_ATTR(temp1_max, 0444, show_temp, NULL, 3); -static SENSOR_DEVICE_ATTR(temp2_max, 0444, show_temp, NULL, 4); -static SENSOR_DEVICE_ATTR(temp3_max, 0444, show_temp, NULL, 5); +static SENSOR_DEVICE_ATTR_RO(temp1_max, temp, 3); +static SENSOR_DEVICE_ATTR_RO(temp2_max, temp, 4); +static SENSOR_DEVICE_ATTR_RO(temp3_max, temp, 5); -static SENSOR_DEVICE_ATTR(temp1_min, 0444, show_temp, NULL, 6); -static SENSOR_DEVICE_ATTR(temp2_min, 0444, show_temp, NULL, 7); -static SENSOR_DEVICE_ATTR(temp3_min, 0444, show_temp, NULL, 8); +static SENSOR_DEVICE_ATTR_RO(temp1_min, temp, 6); +static SENSOR_DEVICE_ATTR_RO(temp2_min, temp, 7); +static SENSOR_DEVICE_ATTR_RO(temp3_min, temp, 8); -static SENSOR_DEVICE_ATTR(fan1_input, 0444, show_fan, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_input, 0444, show_fan, NULL, 1); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); -static SENSOR_DEVICE_ATTR(fan1_min, 0444, show_fan, NULL, 2); -static SENSOR_DEVICE_ATTR(fan2_min, 0444, show_fan, NULL, 3); +static SENSOR_DEVICE_ATTR_RO(fan1_min, fan, 2); +static SENSOR_DEVICE_ATTR_RO(fan2_min, fan, 3); -static SENSOR_DEVICE_ATTR(fan1_div, 0644, show_fan_div, set_fan_div, 0); -static SENSOR_DEVICE_ATTR(fan2_div, 0644, show_fan_div, set_fan_div, 1); +static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0); +static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1);static struct attribute *adm1029_attrs[] = { &sensor_dev_attr_temp1_input.dev_attr.attr,
Signature · 1 line
2.7.4