hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwmon/lm83.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * lm83.c - Part of lm_sensors, Linux kernel modules for hardware
34 * monitoring
....@@ -15,16 +16,6 @@
1516 * Also supports the LM82 temp sensor, which is basically a stripped down
1617 * model of the LM83. Datasheet is here:
1718 * http://www.national.com/pf/LM/LM82.html
18
- *
19
- * This program is free software; you can redistribute it and/or modify
20
- * it under the terms of the GNU General Public License as published by
21
- * the Free Software Foundation; either version 2 of the License, or
22
- * (at your option) any later version.
23
- *
24
- * This program is distributed in the hope that it will be useful,
25
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- * GNU General Public License for more details.
2819 */
2920
3021 #include <linux/module.h>
....@@ -158,7 +149,7 @@
158149 * Sysfs stuff
159150 */
160151
161
-static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
152
+static ssize_t temp_show(struct device *dev, struct device_attribute *devattr,
162153 char *buf)
163154 {
164155 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
....@@ -166,8 +157,9 @@
166157 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index]));
167158 }
168159
169
-static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
170
- const char *buf, size_t count)
160
+static ssize_t temp_store(struct device *dev,
161
+ struct device_attribute *devattr, const char *buf,
162
+ size_t count)
171163 {
172164 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
173165 struct lm83_data *data = dev_get_drvdata(dev);
....@@ -195,8 +187,8 @@
195187 return sprintf(buf, "%d\n", data->alarms);
196188 }
197189
198
-static ssize_t show_alarm(struct device *dev, struct device_attribute
199
- *devattr, char *buf)
190
+static ssize_t alarm_show(struct device *dev,
191
+ struct device_attribute *devattr, char *buf)
200192 {
201193 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
202194 struct lm83_data *data = lm83_update_device(dev);
....@@ -205,36 +197,31 @@
205197 return sprintf(buf, "%d\n", (data->alarms >> bitnr) & 1);
206198 }
207199
208
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
209
-static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);
210
-static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);
211
-static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3);
212
-static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp,
213
- set_temp, 4);
214
-static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp,
215
- set_temp, 5);
216
-static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp,
217
- set_temp, 6);
218
-static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp,
219
- set_temp, 7);
220
-static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp, NULL, 8);
221
-static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp, NULL, 8);
222
-static SENSOR_DEVICE_ATTR(temp3_crit, S_IWUSR | S_IRUGO, show_temp,
223
- set_temp, 8);
224
-static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp, NULL, 8);
200
+static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0);
201
+static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1);
202
+static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2);
203
+static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 3);
204
+static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, 4);
205
+static SENSOR_DEVICE_ATTR_RW(temp2_max, temp, 5);
206
+static SENSOR_DEVICE_ATTR_RW(temp3_max, temp, 6);
207
+static SENSOR_DEVICE_ATTR_RW(temp4_max, temp, 7);
208
+static SENSOR_DEVICE_ATTR_RO(temp1_crit, temp, 8);
209
+static SENSOR_DEVICE_ATTR_RO(temp2_crit, temp, 8);
210
+static SENSOR_DEVICE_ATTR_RW(temp3_crit, temp, 8);
211
+static SENSOR_DEVICE_ATTR_RO(temp4_crit, temp, 8);
225212
226213 /* Individual alarm files */
227
-static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 0);
228
-static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 1);
229
-static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 2);
230
-static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_alarm, NULL, 4);
231
-static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6);
232
-static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 8);
233
-static SENSOR_DEVICE_ATTR(temp4_crit_alarm, S_IRUGO, show_alarm, NULL, 9);
234
-static SENSOR_DEVICE_ATTR(temp4_fault, S_IRUGO, show_alarm, NULL, 10);
235
-static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_alarm, NULL, 12);
236
-static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 13);
237
-static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 15);
214
+static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 0);
215
+static SENSOR_DEVICE_ATTR_RO(temp3_crit_alarm, alarm, 1);
216
+static SENSOR_DEVICE_ATTR_RO(temp3_fault, alarm, 2);
217
+static SENSOR_DEVICE_ATTR_RO(temp3_max_alarm, alarm, 4);
218
+static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 6);
219
+static SENSOR_DEVICE_ATTR_RO(temp2_crit_alarm, alarm, 8);
220
+static SENSOR_DEVICE_ATTR_RO(temp4_crit_alarm, alarm, 9);
221
+static SENSOR_DEVICE_ATTR_RO(temp4_fault, alarm, 10);
222
+static SENSOR_DEVICE_ATTR_RO(temp4_max_alarm, alarm, 12);
223
+static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 13);
224
+static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 15);
238225 /* Raw alarm file for compatibility */
239226 static DEVICE_ATTR_RO(alarms);
240227
....@@ -330,8 +317,9 @@
330317 return 0;
331318 }
332319
333
-static int lm83_probe(struct i2c_client *new_client,
334
- const struct i2c_device_id *id)
320
+static const struct i2c_device_id lm83_id[];
321
+
322
+static int lm83_probe(struct i2c_client *new_client)
335323 {
336324 struct device *hwmon_dev;
337325 struct lm83_data *data;
....@@ -351,7 +339,7 @@
351339 * declare 1 and 3 common, and then 2 and 4 only for the LM83.
352340 */
353341 data->groups[0] = &lm83_group;
354
- if (id->driver_data == lm83)
342
+ if (i2c_match_id(lm83_id, new_client)->driver_data == lm83)
355343 data->groups[1] = &lm83_group_opt;
356344
357345 hwmon_dev = devm_hwmon_device_register_with_groups(&new_client->dev,
....@@ -376,7 +364,7 @@
376364 .driver = {
377365 .name = "lm83",
378366 },
379
- .probe = lm83_probe,
367
+ .probe_new = lm83_probe,
380368 .id_table = lm83_id,
381369 .detect = lm83_detect,
382370 .address_list = normal_i2c,