diff options
author | Guenter Roeck <linux@roeck-us.net> | 2018-12-10 17:02:11 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2019-02-18 17:23:29 -0500 |
commit | 0f875acc93d1b9544963b476c1d7cbb687eea7bb (patch) | |
tree | b1f2d924fc6b18f13ae6b2cc6bb44d1be8211896 | |
parent | 6ccf6a8340d7f6c6b0339bb43b8d398bd6adb636 (diff) |
hwmon: (lm73) Use permission specific SENSOR[_DEVICE]_ATTR variants
Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code,
to improve readability, 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.
Cc: Guillaume Ligneul <guillaume.ligneul@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | drivers/hwmon/lm73.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/drivers/hwmon/lm73.c b/drivers/hwmon/lm73.c index 9653bb870a47..d1d728aa31d2 100644 --- a/drivers/hwmon/lm73.c +++ b/drivers/hwmon/lm73.c | |||
@@ -62,8 +62,8 @@ struct lm73_data { | |||
62 | 62 | ||
63 | /*-----------------------------------------------------------------------*/ | 63 | /*-----------------------------------------------------------------------*/ |
64 | 64 | ||
65 | static ssize_t set_temp(struct device *dev, struct device_attribute *da, | 65 | static ssize_t temp_store(struct device *dev, struct device_attribute *da, |
66 | const char *buf, size_t count) | 66 | const char *buf, size_t count) |
67 | { | 67 | { |
68 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); | 68 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
69 | struct lm73_data *data = dev_get_drvdata(dev); | 69 | struct lm73_data *data = dev_get_drvdata(dev); |
@@ -81,7 +81,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, | |||
81 | return (err < 0) ? err : count; | 81 | return (err < 0) ? err : count; |
82 | } | 82 | } |
83 | 83 | ||
84 | static ssize_t show_temp(struct device *dev, struct device_attribute *da, | 84 | static ssize_t temp_show(struct device *dev, struct device_attribute *da, |
85 | char *buf) | 85 | char *buf) |
86 | { | 86 | { |
87 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); | 87 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
@@ -98,8 +98,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da, | |||
98 | return scnprintf(buf, PAGE_SIZE, "%d\n", temp); | 98 | return scnprintf(buf, PAGE_SIZE, "%d\n", temp); |
99 | } | 99 | } |
100 | 100 | ||
101 | static ssize_t set_convrate(struct device *dev, struct device_attribute *da, | 101 | static ssize_t convrate_store(struct device *dev, struct device_attribute *da, |
102 | const char *buf, size_t count) | 102 | const char *buf, size_t count) |
103 | { | 103 | { |
104 | struct lm73_data *data = dev_get_drvdata(dev); | 104 | struct lm73_data *data = dev_get_drvdata(dev); |
105 | unsigned long convrate; | 105 | unsigned long convrate; |
@@ -133,7 +133,7 @@ static ssize_t set_convrate(struct device *dev, struct device_attribute *da, | |||
133 | return count; | 133 | return count; |
134 | } | 134 | } |
135 | 135 | ||
136 | static ssize_t show_convrate(struct device *dev, struct device_attribute *da, | 136 | static ssize_t convrate_show(struct device *dev, struct device_attribute *da, |
137 | char *buf) | 137 | char *buf) |
138 | { | 138 | { |
139 | struct lm73_data *data = dev_get_drvdata(dev); | 139 | struct lm73_data *data = dev_get_drvdata(dev); |
@@ -143,7 +143,7 @@ static ssize_t show_convrate(struct device *dev, struct device_attribute *da, | |||
143 | return scnprintf(buf, PAGE_SIZE, "%hu\n", lm73_convrates[res]); | 143 | return scnprintf(buf, PAGE_SIZE, "%hu\n", lm73_convrates[res]); |
144 | } | 144 | } |
145 | 145 | ||
146 | static ssize_t show_maxmin_alarm(struct device *dev, | 146 | static ssize_t maxmin_alarm_show(struct device *dev, |
147 | struct device_attribute *da, char *buf) | 147 | struct device_attribute *da, char *buf) |
148 | { | 148 | { |
149 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); | 149 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
@@ -168,18 +168,14 @@ abort: | |||
168 | 168 | ||
169 | /* sysfs attributes for hwmon */ | 169 | /* sysfs attributes for hwmon */ |
170 | 170 | ||
171 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | 171 | static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, LM73_REG_MAX); |
172 | show_temp, set_temp, LM73_REG_MAX); | 172 | static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, LM73_REG_MIN); |
173 | static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, | 173 | static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, LM73_REG_INPUT); |
174 | show_temp, set_temp, LM73_REG_MIN); | 174 | static SENSOR_DEVICE_ATTR_RW(update_interval, convrate, 0); |
175 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, | 175 | static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, maxmin_alarm, |
176 | show_temp, NULL, LM73_REG_INPUT); | 176 | LM73_CTRL_HI_SHIFT); |
177 | static SENSOR_DEVICE_ATTR(update_interval, S_IWUSR | S_IRUGO, | 177 | static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, maxmin_alarm, |
178 | show_convrate, set_convrate, 0); | 178 | LM73_CTRL_LO_SHIFT); |
179 | static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, | ||
180 | show_maxmin_alarm, NULL, LM73_CTRL_HI_SHIFT); | ||
181 | static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, | ||
182 | show_maxmin_alarm, NULL, LM73_CTRL_LO_SHIFT); | ||
183 | 179 | ||
184 | static struct attribute *lm73_attrs[] = { | 180 | static struct attribute *lm73_attrs[] = { |
185 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 181 | &sensor_dev_attr_temp1_input.dev_attr.attr, |