diff options
author | Guenter Roeck <linux@roeck-us.net> | 2018-12-10 17:02:05 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2018-12-16 18:13:44 -0500 |
commit | ae66d2d9e881148acb0092be5a3e39982603ac07 (patch) | |
tree | 6e82217253c6379fc710da4740b30a4d707d2139 | |
parent | 57549f3360eefde08b63886b1477c5751fe2e446 (diff) |
hwmon: (emc1403) 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.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | drivers/hwmon/emc1403.c | 164 |
1 files changed, 69 insertions, 95 deletions
diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c index aaebeb726d6a..bdab47ac9e9a 100644 --- a/drivers/hwmon/emc1403.c +++ b/drivers/hwmon/emc1403.c | |||
@@ -43,8 +43,8 @@ struct thermal_data { | |||
43 | const struct attribute_group *groups[4]; | 43 | const struct attribute_group *groups[4]; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | static ssize_t show_temp(struct device *dev, | 46 | static ssize_t temp_show(struct device *dev, struct device_attribute *attr, |
47 | struct device_attribute *attr, char *buf) | 47 | char *buf) |
48 | { | 48 | { |
49 | struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); | 49 | struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); |
50 | struct thermal_data *data = dev_get_drvdata(dev); | 50 | struct thermal_data *data = dev_get_drvdata(dev); |
@@ -57,8 +57,8 @@ static ssize_t show_temp(struct device *dev, | |||
57 | return sprintf(buf, "%d000\n", val); | 57 | return sprintf(buf, "%d000\n", val); |
58 | } | 58 | } |
59 | 59 | ||
60 | static ssize_t show_bit(struct device *dev, | 60 | static ssize_t bit_show(struct device *dev, struct device_attribute *attr, |
61 | struct device_attribute *attr, char *buf) | 61 | char *buf) |
62 | { | 62 | { |
63 | struct sensor_device_attribute_2 *sda = to_sensor_dev_attr_2(attr); | 63 | struct sensor_device_attribute_2 *sda = to_sensor_dev_attr_2(attr); |
64 | struct thermal_data *data = dev_get_drvdata(dev); | 64 | struct thermal_data *data = dev_get_drvdata(dev); |
@@ -71,8 +71,8 @@ static ssize_t show_bit(struct device *dev, | |||
71 | return sprintf(buf, "%d\n", !!(val & sda->index)); | 71 | return sprintf(buf, "%d\n", !!(val & sda->index)); |
72 | } | 72 | } |
73 | 73 | ||
74 | static ssize_t store_temp(struct device *dev, | 74 | static ssize_t temp_store(struct device *dev, struct device_attribute *attr, |
75 | struct device_attribute *attr, const char *buf, size_t count) | 75 | const char *buf, size_t count) |
76 | { | 76 | { |
77 | struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); | 77 | struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); |
78 | struct thermal_data *data = dev_get_drvdata(dev); | 78 | struct thermal_data *data = dev_get_drvdata(dev); |
@@ -88,8 +88,8 @@ static ssize_t store_temp(struct device *dev, | |||
88 | return count; | 88 | return count; |
89 | } | 89 | } |
90 | 90 | ||
91 | static ssize_t store_bit(struct device *dev, | 91 | static ssize_t bit_store(struct device *dev, struct device_attribute *attr, |
92 | struct device_attribute *attr, const char *buf, size_t count) | 92 | const char *buf, size_t count) |
93 | { | 93 | { |
94 | struct sensor_device_attribute_2 *sda = to_sensor_dev_attr_2(attr); | 94 | struct sensor_device_attribute_2 *sda = to_sensor_dev_attr_2(attr); |
95 | struct thermal_data *data = dev_get_drvdata(dev); | 95 | struct thermal_data *data = dev_get_drvdata(dev); |
@@ -128,20 +128,20 @@ static ssize_t show_hyst_common(struct device *dev, | |||
128 | return sprintf(buf, "%d000\n", is_min ? limit + hyst : limit - hyst); | 128 | return sprintf(buf, "%d000\n", is_min ? limit + hyst : limit - hyst); |
129 | } | 129 | } |
130 | 130 | ||
131 | static ssize_t show_hyst(struct device *dev, | 131 | static ssize_t hyst_show(struct device *dev, struct device_attribute *attr, |
132 | struct device_attribute *attr, char *buf) | 132 | char *buf) |
133 | { | 133 | { |
134 | return show_hyst_common(dev, attr, buf, false); | 134 | return show_hyst_common(dev, attr, buf, false); |
135 | } | 135 | } |
136 | 136 | ||
137 | static ssize_t show_min_hyst(struct device *dev, | 137 | static ssize_t min_hyst_show(struct device *dev, |
138 | struct device_attribute *attr, char *buf) | 138 | struct device_attribute *attr, char *buf) |
139 | { | 139 | { |
140 | return show_hyst_common(dev, attr, buf, true); | 140 | return show_hyst_common(dev, attr, buf, true); |
141 | } | 141 | } |
142 | 142 | ||
143 | static ssize_t store_hyst(struct device *dev, | 143 | static ssize_t hyst_store(struct device *dev, struct device_attribute *attr, |
144 | struct device_attribute *attr, const char *buf, size_t count) | 144 | const char *buf, size_t count) |
145 | { | 145 | { |
146 | struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); | 146 | struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); |
147 | struct thermal_data *data = dev_get_drvdata(dev); | 147 | struct thermal_data *data = dev_get_drvdata(dev); |
@@ -173,80 +173,54 @@ fail: | |||
173 | * Sensors. We pass the actual i2c register to the methods. | 173 | * Sensors. We pass the actual i2c register to the methods. |
174 | */ | 174 | */ |
175 | 175 | ||
176 | static SENSOR_DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR, | 176 | static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, 0x06); |
177 | show_temp, store_temp, 0x06); | 177 | static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, 0x05); |
178 | static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, | 178 | static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp, 0x20); |
179 | show_temp, store_temp, 0x05); | 179 | static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0x00); |
180 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO | S_IWUSR, | 180 | static SENSOR_DEVICE_ATTR_2_RO(temp1_min_alarm, bit, 0x36, 0x01); |
181 | show_temp, store_temp, 0x20); | 181 | static SENSOR_DEVICE_ATTR_2_RO(temp1_max_alarm, bit, 0x35, 0x01); |
182 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0x00); | 182 | static SENSOR_DEVICE_ATTR_2_RO(temp1_crit_alarm, bit, 0x37, 0x01); |
183 | static SENSOR_DEVICE_ATTR_2(temp1_min_alarm, S_IRUGO, | 183 | static SENSOR_DEVICE_ATTR_RO(temp1_min_hyst, min_hyst, 0x06); |
184 | show_bit, NULL, 0x36, 0x01); | 184 | static SENSOR_DEVICE_ATTR_RO(temp1_max_hyst, hyst, 0x05); |
185 | static SENSOR_DEVICE_ATTR_2(temp1_max_alarm, S_IRUGO, | 185 | static SENSOR_DEVICE_ATTR_RW(temp1_crit_hyst, hyst, 0x20); |
186 | show_bit, NULL, 0x35, 0x01); | 186 | |
187 | static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO, | 187 | static SENSOR_DEVICE_ATTR_RW(temp2_min, temp, 0x08); |
188 | show_bit, NULL, 0x37, 0x01); | 188 | static SENSOR_DEVICE_ATTR_RW(temp2_max, temp, 0x07); |
189 | static SENSOR_DEVICE_ATTR(temp1_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x06); | 189 | static SENSOR_DEVICE_ATTR_RW(temp2_crit, temp, 0x19); |
190 | static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO, show_hyst, NULL, 0x05); | 190 | static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 0x01); |
191 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO | S_IWUSR, | 191 | static SENSOR_DEVICE_ATTR_2_RO(temp2_fault, bit, 0x1b, 0x02); |
192 | show_hyst, store_hyst, 0x20); | 192 | static SENSOR_DEVICE_ATTR_2_RO(temp2_min_alarm, bit, 0x36, 0x02); |
193 | 193 | static SENSOR_DEVICE_ATTR_2_RO(temp2_max_alarm, bit, 0x35, 0x02); | |
194 | static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO | S_IWUSR, | 194 | static SENSOR_DEVICE_ATTR_2_RO(temp2_crit_alarm, bit, 0x37, 0x02); |
195 | show_temp, store_temp, 0x08); | 195 | static SENSOR_DEVICE_ATTR_RO(temp2_min_hyst, min_hyst, 0x08); |
196 | static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO | S_IWUSR, | 196 | static SENSOR_DEVICE_ATTR_RO(temp2_max_hyst, hyst, 0x07); |
197 | show_temp, store_temp, 0x07); | 197 | static SENSOR_DEVICE_ATTR_RO(temp2_crit_hyst, hyst, 0x19); |
198 | static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO | S_IWUSR, | 198 | |
199 | show_temp, store_temp, 0x19); | 199 | static SENSOR_DEVICE_ATTR_RW(temp3_min, temp, 0x16); |
200 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 0x01); | 200 | static SENSOR_DEVICE_ATTR_RW(temp3_max, temp, 0x15); |
201 | static SENSOR_DEVICE_ATTR_2(temp2_fault, S_IRUGO, show_bit, NULL, 0x1b, 0x02); | 201 | static SENSOR_DEVICE_ATTR_RW(temp3_crit, temp, 0x1A); |
202 | static SENSOR_DEVICE_ATTR_2(temp2_min_alarm, S_IRUGO, | 202 | static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 0x23); |
203 | show_bit, NULL, 0x36, 0x02); | 203 | static SENSOR_DEVICE_ATTR_2_RO(temp3_fault, bit, 0x1b, 0x04); |
204 | static SENSOR_DEVICE_ATTR_2(temp2_max_alarm, S_IRUGO, | 204 | static SENSOR_DEVICE_ATTR_2_RO(temp3_min_alarm, bit, 0x36, 0x04); |
205 | show_bit, NULL, 0x35, 0x02); | 205 | static SENSOR_DEVICE_ATTR_2_RO(temp3_max_alarm, bit, 0x35, 0x04); |
206 | static SENSOR_DEVICE_ATTR_2(temp2_crit_alarm, S_IRUGO, | 206 | static SENSOR_DEVICE_ATTR_2_RO(temp3_crit_alarm, bit, 0x37, 0x04); |
207 | show_bit, NULL, 0x37, 0x02); | 207 | static SENSOR_DEVICE_ATTR_RO(temp3_min_hyst, min_hyst, 0x16); |
208 | static SENSOR_DEVICE_ATTR(temp2_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x08); | 208 | static SENSOR_DEVICE_ATTR_RO(temp3_max_hyst, hyst, 0x15); |
209 | static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IRUGO, show_hyst, NULL, 0x07); | 209 | static SENSOR_DEVICE_ATTR_RO(temp3_crit_hyst, hyst, 0x1A); |
210 | static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_hyst, NULL, 0x19); | 210 | |
211 | 211 | static SENSOR_DEVICE_ATTR_RW(temp4_min, temp, 0x2D); | |
212 | static SENSOR_DEVICE_ATTR(temp3_min, S_IRUGO | S_IWUSR, | 212 | static SENSOR_DEVICE_ATTR_RW(temp4_max, temp, 0x2C); |
213 | show_temp, store_temp, 0x16); | 213 | static SENSOR_DEVICE_ATTR_RW(temp4_crit, temp, 0x30); |
214 | static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO | S_IWUSR, | 214 | static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 0x2A); |
215 | show_temp, store_temp, 0x15); | 215 | static SENSOR_DEVICE_ATTR_2_RO(temp4_fault, bit, 0x1b, 0x08); |
216 | static SENSOR_DEVICE_ATTR(temp3_crit, S_IRUGO | S_IWUSR, | 216 | static SENSOR_DEVICE_ATTR_2_RO(temp4_min_alarm, bit, 0x36, 0x08); |
217 | show_temp, store_temp, 0x1A); | 217 | static SENSOR_DEVICE_ATTR_2_RO(temp4_max_alarm, bit, 0x35, 0x08); |
218 | static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 0x23); | 218 | static SENSOR_DEVICE_ATTR_2_RO(temp4_crit_alarm, bit, 0x37, 0x08); |
219 | static SENSOR_DEVICE_ATTR_2(temp3_fault, S_IRUGO, show_bit, NULL, 0x1b, 0x04); | 219 | static SENSOR_DEVICE_ATTR_RO(temp4_min_hyst, min_hyst, 0x2D); |
220 | static SENSOR_DEVICE_ATTR_2(temp3_min_alarm, S_IRUGO, | 220 | static SENSOR_DEVICE_ATTR_RO(temp4_max_hyst, hyst, 0x2C); |
221 | show_bit, NULL, 0x36, 0x04); | 221 | static SENSOR_DEVICE_ATTR_RO(temp4_crit_hyst, hyst, 0x30); |
222 | static SENSOR_DEVICE_ATTR_2(temp3_max_alarm, S_IRUGO, | 222 | |
223 | show_bit, NULL, 0x35, 0x04); | 223 | static SENSOR_DEVICE_ATTR_2_RW(power_state, bit, 0x03, 0x40); |
224 | static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO, | ||
225 | show_bit, NULL, 0x37, 0x04); | ||
226 | static SENSOR_DEVICE_ATTR(temp3_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x16); | ||
227 | static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO, show_hyst, NULL, 0x15); | ||
228 | static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO, show_hyst, NULL, 0x1A); | ||
229 | |||
230 | static SENSOR_DEVICE_ATTR(temp4_min, S_IRUGO | S_IWUSR, | ||
231 | show_temp, store_temp, 0x2D); | ||
232 | static SENSOR_DEVICE_ATTR(temp4_max, S_IRUGO | S_IWUSR, | ||
233 | show_temp, store_temp, 0x2C); | ||
234 | static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO | S_IWUSR, | ||
235 | show_temp, store_temp, 0x30); | ||
236 | static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 0x2A); | ||
237 | static SENSOR_DEVICE_ATTR_2(temp4_fault, S_IRUGO, show_bit, NULL, 0x1b, 0x08); | ||
238 | static SENSOR_DEVICE_ATTR_2(temp4_min_alarm, S_IRUGO, | ||
239 | show_bit, NULL, 0x36, 0x08); | ||
240 | static SENSOR_DEVICE_ATTR_2(temp4_max_alarm, S_IRUGO, | ||
241 | show_bit, NULL, 0x35, 0x08); | ||
242 | static SENSOR_DEVICE_ATTR_2(temp4_crit_alarm, S_IRUGO, | ||
243 | show_bit, NULL, 0x37, 0x08); | ||
244 | static SENSOR_DEVICE_ATTR(temp4_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x2D); | ||
245 | static SENSOR_DEVICE_ATTR(temp4_max_hyst, S_IRUGO, show_hyst, NULL, 0x2C); | ||
246 | static SENSOR_DEVICE_ATTR(temp4_crit_hyst, S_IRUGO, show_hyst, NULL, 0x30); | ||
247 | |||
248 | static SENSOR_DEVICE_ATTR_2(power_state, S_IRUGO | S_IWUSR, | ||
249 | show_bit, store_bit, 0x03, 0x40); | ||
250 | 224 | ||
251 | static struct attribute *emc1402_attrs[] = { | 225 | static struct attribute *emc1402_attrs[] = { |
252 | &sensor_dev_attr_temp1_min.dev_attr.attr, | 226 | &sensor_dev_attr_temp1_min.dev_attr.attr, |
@@ -328,14 +302,14 @@ static const struct attribute_group emc1404_group = { | |||
328 | * array. | 302 | * array. |
329 | */ | 303 | */ |
330 | static struct sensor_device_attribute_2 emc1402_alarms[] = { | 304 | static struct sensor_device_attribute_2 emc1402_alarms[] = { |
331 | SENSOR_ATTR_2(temp1_min_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x20), | 305 | SENSOR_ATTR_2_RO(temp1_min_alarm, bit, 0x02, 0x20), |
332 | SENSOR_ATTR_2(temp1_max_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x40), | 306 | SENSOR_ATTR_2_RO(temp1_max_alarm, bit, 0x02, 0x40), |
333 | SENSOR_ATTR_2(temp1_crit_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x01), | 307 | SENSOR_ATTR_2_RO(temp1_crit_alarm, bit, 0x02, 0x01), |
334 | 308 | ||
335 | SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_bit, NULL, 0x02, 0x04), | 309 | SENSOR_ATTR_2_RO(temp2_fault, bit, 0x02, 0x04), |
336 | SENSOR_ATTR_2(temp2_min_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x08), | 310 | SENSOR_ATTR_2_RO(temp2_min_alarm, bit, 0x02, 0x08), |
337 | SENSOR_ATTR_2(temp2_max_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x10), | 311 | SENSOR_ATTR_2_RO(temp2_max_alarm, bit, 0x02, 0x10), |
338 | SENSOR_ATTR_2(temp2_crit_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x02), | 312 | SENSOR_ATTR_2_RO(temp2_crit_alarm, bit, 0x02, 0x02), |
339 | }; | 313 | }; |
340 | 314 | ||
341 | static struct attribute *emc1402_alarm_attrs[] = { | 315 | static struct attribute *emc1402_alarm_attrs[] = { |