Commit 96c6f81a authored by Guenter Roeck's avatar Guenter Roeck

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

Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code,
to improve readbility, and to reduce the chance of inconsistencies.

Also replace any remaining S_<PERMS> in the driver with octal values.

The conversion was done automatically with coccinelle. The semantic patches
and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches/.

This patch does not introduce functional changes. It was verified by
compiling the old and new files and comparing text and data sizes.
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent f2bec7ea
...@@ -202,8 +202,8 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, ...@@ -202,8 +202,8 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
return data; return data;
} }
static ssize_t get_fan(struct device *dev, struct device_attribute static ssize_t fan_show(struct device *dev, struct device_attribute *devattr,
*devattr, char *buf) char *buf)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct smsc47m1_data *data = smsc47m1_update_device(dev, 0); struct smsc47m1_data *data = smsc47m1_update_device(dev, 0);
...@@ -221,8 +221,8 @@ static ssize_t get_fan(struct device *dev, struct device_attribute ...@@ -221,8 +221,8 @@ static ssize_t get_fan(struct device *dev, struct device_attribute
return sprintf(buf, "%d\n", rpm); return sprintf(buf, "%d\n", rpm);
} }
static ssize_t get_fan_min(struct device *dev, struct device_attribute static ssize_t fan_min_show(struct device *dev,
*devattr, char *buf) struct device_attribute *devattr, char *buf)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct smsc47m1_data *data = smsc47m1_update_device(dev, 0); struct smsc47m1_data *data = smsc47m1_update_device(dev, 0);
...@@ -232,32 +232,32 @@ static ssize_t get_fan_min(struct device *dev, struct device_attribute ...@@ -232,32 +232,32 @@ static ssize_t get_fan_min(struct device *dev, struct device_attribute
return sprintf(buf, "%d\n", rpm); return sprintf(buf, "%d\n", rpm);
} }
static ssize_t get_fan_div(struct device *dev, struct device_attribute static ssize_t fan_div_show(struct device *dev,
*devattr, char *buf) struct device_attribute *devattr, char *buf)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct smsc47m1_data *data = smsc47m1_update_device(dev, 0); struct smsc47m1_data *data = smsc47m1_update_device(dev, 0);
return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[attr->index])); 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 static ssize_t fan_alarm_show(struct device *dev,
*devattr, char *buf) struct device_attribute *devattr, char *buf)
{ {
int bitnr = to_sensor_dev_attr(devattr)->index; int bitnr = to_sensor_dev_attr(devattr)->index;
struct smsc47m1_data *data = smsc47m1_update_device(dev, 0); struct smsc47m1_data *data = smsc47m1_update_device(dev, 0);
return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1);
} }
static ssize_t get_pwm(struct device *dev, struct device_attribute static ssize_t pwm_show(struct device *dev, struct device_attribute *devattr,
*devattr, char *buf) char *buf)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct smsc47m1_data *data = smsc47m1_update_device(dev, 0); struct smsc47m1_data *data = smsc47m1_update_device(dev, 0);
return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[attr->index])); return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[attr->index]));
} }
static ssize_t get_pwm_en(struct device *dev, struct device_attribute static ssize_t pwm_en_show(struct device *dev,
*devattr, char *buf) struct device_attribute *devattr, char *buf)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct smsc47m1_data *data = smsc47m1_update_device(dev, 0); struct smsc47m1_data *data = smsc47m1_update_device(dev, 0);
...@@ -271,8 +271,9 @@ static ssize_t alarms_show(struct device *dev, ...@@ -271,8 +271,9 @@ static ssize_t alarms_show(struct device *dev,
return sprintf(buf, "%d\n", data->alarms); return sprintf(buf, "%d\n", data->alarms);
} }
static ssize_t set_fan_min(struct device *dev, struct device_attribute static ssize_t fan_min_store(struct device *dev,
*devattr, const char *buf, size_t count) struct device_attribute *devattr,
const char *buf, size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct smsc47m1_data *data = dev_get_drvdata(dev); struct smsc47m1_data *data = dev_get_drvdata(dev);
...@@ -307,8 +308,9 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute ...@@ -307,8 +308,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 * of least surprise; the user doesn't expect the fan minimum to change just
* because the divider changed. * because the divider changed.
*/ */
static ssize_t set_fan_div(struct device *dev, struct device_attribute static ssize_t fan_div_store(struct device *dev,
*devattr, const char *buf, size_t count) struct device_attribute *devattr,
const char *buf, size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct smsc47m1_data *data = dev_get_drvdata(dev); struct smsc47m1_data *data = dev_get_drvdata(dev);
...@@ -370,8 +372,8 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute ...@@ -370,8 +372,8 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute
return count; return count;
} }
static ssize_t set_pwm(struct device *dev, struct device_attribute static ssize_t pwm_store(struct device *dev, struct device_attribute *devattr,
*devattr, const char *buf, size_t count) const char *buf, size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct smsc47m1_data *data = dev_get_drvdata(dev); struct smsc47m1_data *data = dev_get_drvdata(dev);
...@@ -396,8 +398,9 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute ...@@ -396,8 +398,9 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute
return count; return count;
} }
static ssize_t set_pwm_en(struct device *dev, struct device_attribute static ssize_t pwm_en_store(struct device *dev,
*devattr, const char *buf, size_t count) struct device_attribute *devattr, const char *buf,
size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct smsc47m1_data *data = dev_get_drvdata(dev); struct smsc47m1_data *data = dev_get_drvdata(dev);
...@@ -422,23 +425,24 @@ static ssize_t set_pwm_en(struct device *dev, struct device_attribute ...@@ -422,23 +425,24 @@ static ssize_t set_pwm_en(struct device *dev, struct device_attribute
return count; return count;
} }
#define fan_present(offset) \ static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0);
static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, get_fan, \ static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0);
NULL, offset - 1); \ static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0);
static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ static SENSOR_DEVICE_ATTR_RO(fan1_alarm, fan_alarm, 0);
get_fan_min, set_fan_min, offset - 1); \ static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0);
static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ static SENSOR_DEVICE_ATTR_RW(pwm1_enable, pwm_en, 0);
get_fan_div, set_fan_div, offset - 1); \ static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1);
static SENSOR_DEVICE_ATTR(fan##offset##_alarm, S_IRUGO, get_fan_alarm, \ static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1);
NULL, offset - 1); \ static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1);
static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ static SENSOR_DEVICE_ATTR_RO(fan2_alarm, fan_alarm, 1);
get_pwm, set_pwm, offset - 1); \ static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1);
static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ static SENSOR_DEVICE_ATTR_RW(pwm2_enable, pwm_en, 1);
get_pwm_en, set_pwm_en, offset - 1) static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 2);
static SENSOR_DEVICE_ATTR_RW(fan3_min, fan_min, 2);
fan_present(1); static SENSOR_DEVICE_ATTR_RW(fan3_div, fan_div, 2);
fan_present(2); static SENSOR_DEVICE_ATTR_RO(fan3_alarm, fan_alarm, 2);
fan_present(3); static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, 2);
static SENSOR_DEVICE_ATTR_RW(pwm3_enable, pwm_en, 2);
static DEVICE_ATTR_RO(alarms); static DEVICE_ATTR_RO(alarms);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment