hwmon: (lm87) Use permission specific SENSOR[_DEVICE]_ATTR variants
Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_<PERMS> in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
8e757e15a5
commit
f6c93aeb0a
|
@ -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 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 show_temp_input(struct device *dev,
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue