summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2018-12-10 17:02:05 -0500
committerGuenter Roeck <linux@roeck-us.net>2018-12-16 18:13:44 -0500
commitae66d2d9e881148acb0092be5a3e39982603ac07 (patch)
tree6e82217253c6379fc710da4740b30a4d707d2139
parent57549f3360eefde08b63886b1477c5751fe2e446 (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.c164
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
46static ssize_t show_temp(struct device *dev, 46static 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
60static ssize_t show_bit(struct device *dev, 60static 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
74static ssize_t store_temp(struct device *dev, 74static 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
91static ssize_t store_bit(struct device *dev, 91static 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
131static ssize_t show_hyst(struct device *dev, 131static 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
137static ssize_t show_min_hyst(struct device *dev, 137static 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
143static ssize_t store_hyst(struct device *dev, 143static 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
176static SENSOR_DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR, 176static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, 0x06);
177 show_temp, store_temp, 0x06); 177static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, 0x05);
178static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, 178static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp, 0x20);
179 show_temp, store_temp, 0x05); 179static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0x00);
180static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO | S_IWUSR, 180static SENSOR_DEVICE_ATTR_2_RO(temp1_min_alarm, bit, 0x36, 0x01);
181 show_temp, store_temp, 0x20); 181static SENSOR_DEVICE_ATTR_2_RO(temp1_max_alarm, bit, 0x35, 0x01);
182static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0x00); 182static SENSOR_DEVICE_ATTR_2_RO(temp1_crit_alarm, bit, 0x37, 0x01);
183static SENSOR_DEVICE_ATTR_2(temp1_min_alarm, S_IRUGO, 183static SENSOR_DEVICE_ATTR_RO(temp1_min_hyst, min_hyst, 0x06);
184 show_bit, NULL, 0x36, 0x01); 184static SENSOR_DEVICE_ATTR_RO(temp1_max_hyst, hyst, 0x05);
185static SENSOR_DEVICE_ATTR_2(temp1_max_alarm, S_IRUGO, 185static SENSOR_DEVICE_ATTR_RW(temp1_crit_hyst, hyst, 0x20);
186 show_bit, NULL, 0x35, 0x01); 186
187static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO, 187static SENSOR_DEVICE_ATTR_RW(temp2_min, temp, 0x08);
188 show_bit, NULL, 0x37, 0x01); 188static SENSOR_DEVICE_ATTR_RW(temp2_max, temp, 0x07);
189static SENSOR_DEVICE_ATTR(temp1_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x06); 189static SENSOR_DEVICE_ATTR_RW(temp2_crit, temp, 0x19);
190static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO, show_hyst, NULL, 0x05); 190static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 0x01);
191static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO | S_IWUSR, 191static SENSOR_DEVICE_ATTR_2_RO(temp2_fault, bit, 0x1b, 0x02);
192 show_hyst, store_hyst, 0x20); 192static SENSOR_DEVICE_ATTR_2_RO(temp2_min_alarm, bit, 0x36, 0x02);
193 193static SENSOR_DEVICE_ATTR_2_RO(temp2_max_alarm, bit, 0x35, 0x02);
194static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO | S_IWUSR, 194static SENSOR_DEVICE_ATTR_2_RO(temp2_crit_alarm, bit, 0x37, 0x02);
195 show_temp, store_temp, 0x08); 195static SENSOR_DEVICE_ATTR_RO(temp2_min_hyst, min_hyst, 0x08);
196static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO | S_IWUSR, 196static SENSOR_DEVICE_ATTR_RO(temp2_max_hyst, hyst, 0x07);
197 show_temp, store_temp, 0x07); 197static SENSOR_DEVICE_ATTR_RO(temp2_crit_hyst, hyst, 0x19);
198static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO | S_IWUSR, 198
199 show_temp, store_temp, 0x19); 199static SENSOR_DEVICE_ATTR_RW(temp3_min, temp, 0x16);
200static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 0x01); 200static SENSOR_DEVICE_ATTR_RW(temp3_max, temp, 0x15);
201static SENSOR_DEVICE_ATTR_2(temp2_fault, S_IRUGO, show_bit, NULL, 0x1b, 0x02); 201static SENSOR_DEVICE_ATTR_RW(temp3_crit, temp, 0x1A);
202static SENSOR_DEVICE_ATTR_2(temp2_min_alarm, S_IRUGO, 202static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 0x23);
203 show_bit, NULL, 0x36, 0x02); 203static SENSOR_DEVICE_ATTR_2_RO(temp3_fault, bit, 0x1b, 0x04);
204static SENSOR_DEVICE_ATTR_2(temp2_max_alarm, S_IRUGO, 204static SENSOR_DEVICE_ATTR_2_RO(temp3_min_alarm, bit, 0x36, 0x04);
205 show_bit, NULL, 0x35, 0x02); 205static SENSOR_DEVICE_ATTR_2_RO(temp3_max_alarm, bit, 0x35, 0x04);
206static SENSOR_DEVICE_ATTR_2(temp2_crit_alarm, S_IRUGO, 206static SENSOR_DEVICE_ATTR_2_RO(temp3_crit_alarm, bit, 0x37, 0x04);
207 show_bit, NULL, 0x37, 0x02); 207static SENSOR_DEVICE_ATTR_RO(temp3_min_hyst, min_hyst, 0x16);
208static SENSOR_DEVICE_ATTR(temp2_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x08); 208static SENSOR_DEVICE_ATTR_RO(temp3_max_hyst, hyst, 0x15);
209static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IRUGO, show_hyst, NULL, 0x07); 209static SENSOR_DEVICE_ATTR_RO(temp3_crit_hyst, hyst, 0x1A);
210static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO, show_hyst, NULL, 0x19); 210
211 211static SENSOR_DEVICE_ATTR_RW(temp4_min, temp, 0x2D);
212static SENSOR_DEVICE_ATTR(temp3_min, S_IRUGO | S_IWUSR, 212static SENSOR_DEVICE_ATTR_RW(temp4_max, temp, 0x2C);
213 show_temp, store_temp, 0x16); 213static SENSOR_DEVICE_ATTR_RW(temp4_crit, temp, 0x30);
214static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO | S_IWUSR, 214static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 0x2A);
215 show_temp, store_temp, 0x15); 215static SENSOR_DEVICE_ATTR_2_RO(temp4_fault, bit, 0x1b, 0x08);
216static SENSOR_DEVICE_ATTR(temp3_crit, S_IRUGO | S_IWUSR, 216static SENSOR_DEVICE_ATTR_2_RO(temp4_min_alarm, bit, 0x36, 0x08);
217 show_temp, store_temp, 0x1A); 217static SENSOR_DEVICE_ATTR_2_RO(temp4_max_alarm, bit, 0x35, 0x08);
218static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 0x23); 218static SENSOR_DEVICE_ATTR_2_RO(temp4_crit_alarm, bit, 0x37, 0x08);
219static SENSOR_DEVICE_ATTR_2(temp3_fault, S_IRUGO, show_bit, NULL, 0x1b, 0x04); 219static SENSOR_DEVICE_ATTR_RO(temp4_min_hyst, min_hyst, 0x2D);
220static SENSOR_DEVICE_ATTR_2(temp3_min_alarm, S_IRUGO, 220static SENSOR_DEVICE_ATTR_RO(temp4_max_hyst, hyst, 0x2C);
221 show_bit, NULL, 0x36, 0x04); 221static SENSOR_DEVICE_ATTR_RO(temp4_crit_hyst, hyst, 0x30);
222static SENSOR_DEVICE_ATTR_2(temp3_max_alarm, S_IRUGO, 222
223 show_bit, NULL, 0x35, 0x04); 223static SENSOR_DEVICE_ATTR_2_RW(power_state, bit, 0x03, 0x40);
224static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO,
225 show_bit, NULL, 0x37, 0x04);
226static SENSOR_DEVICE_ATTR(temp3_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x16);
227static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IRUGO, show_hyst, NULL, 0x15);
228static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO, show_hyst, NULL, 0x1A);
229
230static SENSOR_DEVICE_ATTR(temp4_min, S_IRUGO | S_IWUSR,
231 show_temp, store_temp, 0x2D);
232static SENSOR_DEVICE_ATTR(temp4_max, S_IRUGO | S_IWUSR,
233 show_temp, store_temp, 0x2C);
234static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO | S_IWUSR,
235 show_temp, store_temp, 0x30);
236static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 0x2A);
237static SENSOR_DEVICE_ATTR_2(temp4_fault, S_IRUGO, show_bit, NULL, 0x1b, 0x08);
238static SENSOR_DEVICE_ATTR_2(temp4_min_alarm, S_IRUGO,
239 show_bit, NULL, 0x36, 0x08);
240static SENSOR_DEVICE_ATTR_2(temp4_max_alarm, S_IRUGO,
241 show_bit, NULL, 0x35, 0x08);
242static SENSOR_DEVICE_ATTR_2(temp4_crit_alarm, S_IRUGO,
243 show_bit, NULL, 0x37, 0x08);
244static SENSOR_DEVICE_ATTR(temp4_min_hyst, S_IRUGO, show_min_hyst, NULL, 0x2D);
245static SENSOR_DEVICE_ATTR(temp4_max_hyst, S_IRUGO, show_hyst, NULL, 0x2C);
246static SENSOR_DEVICE_ATTR(temp4_crit_hyst, S_IRUGO, show_hyst, NULL, 0x30);
247
248static SENSOR_DEVICE_ATTR_2(power_state, S_IRUGO | S_IWUSR,
249 show_bit, store_bit, 0x03, 0x40);
250 224
251static struct attribute *emc1402_attrs[] = { 225static 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 */
330static struct sensor_device_attribute_2 emc1402_alarms[] = { 304static 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
341static struct attribute *emc1402_alarm_attrs[] = { 315static struct attribute *emc1402_alarm_attrs[] = {