hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwmon/max6642.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for +/-1 degree C, SMBus-Compatible Remote/Local Temperature Sensor
34 * with Overtemperature Alarm
....@@ -15,20 +16,6 @@
1516 * one external one). Complete datasheet can be
1617 * obtained from Maxim's website at:
1718 * http://datasheets.maxim-ic.com/en/ds/MAX6642.pdf
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.
28
- *
29
- * You should have received a copy of the GNU General Public License
30
- * along with this program; if not, write to the Free Software
31
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3219 */
3320
3421
....@@ -206,7 +193,7 @@
206193 * Sysfs stuff
207194 */
208195
209
-static ssize_t show_temp_max10(struct device *dev,
196
+static ssize_t temp_max10_show(struct device *dev,
210197 struct device_attribute *dev_attr, char *buf)
211198 {
212199 struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
....@@ -216,8 +203,8 @@
216203 temp_from_reg10(data->temp_input[attr->index]));
217204 }
218205
219
-static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,
220
- char *buf)
206
+static ssize_t temp_max_show(struct device *dev,
207
+ struct device_attribute *attr, char *buf)
221208 {
222209 struct sensor_device_attribute_2 *attr2 = to_sensor_dev_attr_2(attr);
223210 struct max6642_data *data = max6642_update_device(dev);
....@@ -225,8 +212,9 @@
225212 return sprintf(buf, "%d\n", temp_from_reg(data->temp_high[attr2->nr]));
226213 }
227214
228
-static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
229
- const char *buf, size_t count)
215
+static ssize_t temp_max_store(struct device *dev,
216
+ struct device_attribute *attr, const char *buf,
217
+ size_t count)
230218 {
231219 struct sensor_device_attribute_2 *attr2 = to_sensor_dev_attr_2(attr);
232220 struct max6642_data *data = dev_get_drvdata(dev);
....@@ -245,7 +233,7 @@
245233 return count;
246234 }
247235
248
-static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
236
+static ssize_t alarm_show(struct device *dev, struct device_attribute *attr,
249237 char *buf)
250238 {
251239 int bitnr = to_sensor_dev_attr(attr)->index;
....@@ -253,15 +241,15 @@
253241 return sprintf(buf, "%d\n", (data->alarms >> bitnr) & 1);
254242 }
255243
256
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_max10, NULL, 0);
257
-static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_max10, NULL, 1);
258
-static SENSOR_DEVICE_ATTR_2(temp1_max, S_IWUSR | S_IRUGO, show_temp_max,
259
- set_temp_max, 0, MAX6642_REG_W_LOCAL_HIGH);
260
-static SENSOR_DEVICE_ATTR_2(temp2_max, S_IWUSR | S_IRUGO, show_temp_max,
261
- set_temp_max, 1, MAX6642_REG_W_REMOTE_HIGH);
262
-static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2);
263
-static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6);
264
-static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4);
244
+static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_max10, 0);
245
+static SENSOR_DEVICE_ATTR_RO(temp2_input, temp_max10, 1);
246
+static SENSOR_DEVICE_ATTR_2_RW(temp1_max, temp_max, 0,
247
+ MAX6642_REG_W_LOCAL_HIGH);
248
+static SENSOR_DEVICE_ATTR_2_RW(temp2_max, temp_max, 1,
249
+ MAX6642_REG_W_REMOTE_HIGH);
250
+static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 2);
251
+static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 6);
252
+static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 4);
265253
266254 static struct attribute *max6642_attrs[] = {
267255 &sensor_dev_attr_temp1_input.dev_attr.attr,
....@@ -276,8 +264,7 @@
276264 };
277265 ATTRIBUTE_GROUPS(max6642);
278266
279
-static int max6642_probe(struct i2c_client *client,
280
- const struct i2c_device_id *id)
267
+static int max6642_probe(struct i2c_client *client)
281268 {
282269 struct device *dev = &client->dev;
283270 struct max6642_data *data;
....@@ -314,7 +301,7 @@
314301 .driver = {
315302 .name = "max6642",
316303 },
317
- .probe = max6642_probe,
304
+ .probe_new = max6642_probe,
318305 .id_table = max6642_id,
319306 .detect = max6642_detect,
320307 .address_list = normal_i2c,