hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/hwmon/max6697.c
....@@ -1,18 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (c) 2012 Guenter Roeck <linux@roeck-us.net>
34 *
45 * based on max1668.c
56 * Copyright (c) 2011 David George <david.george@ska.ac.za>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
167 */
178
189 #include <linux/module.h>
....@@ -66,6 +57,8 @@
6657 #define MAX6581_REG_IDEALITY_SELECT 0x4c
6758 #define MAX6581_REG_OFFSET 0x4d
6859 #define MAX6581_REG_OFFSET_SELECT 0x4e
60
+#define MAX6581_OFFSET_MIN -31750
61
+#define MAX6581_OFFSET_MAX 31750
6962
7063 #define MAX6697_CONV_TIME 156 /* ms per channel, worst case */
7164
....@@ -181,6 +174,11 @@
181174 },
182175 };
183176
177
+static inline int max6581_offset_to_millic(int val)
178
+{
179
+ return sign_extend32(val, 7) * 250;
180
+}
181
+
184182 static struct max6697_data *max6697_update_device(struct device *dev)
185183 {
186184 struct max6697_data *data = dev_get_drvdata(dev);
....@@ -251,7 +249,7 @@
251249 return ret;
252250 }
253251
254
-static ssize_t show_temp_input(struct device *dev,
252
+static ssize_t temp_input_show(struct device *dev,
255253 struct device_attribute *devattr, char *buf)
256254 {
257255 int index = to_sensor_dev_attr(devattr)->index;
....@@ -267,8 +265,8 @@
267265 return sprintf(buf, "%d\n", temp * 125);
268266 }
269267
270
-static ssize_t show_temp(struct device *dev,
271
- struct device_attribute *devattr, char *buf)
268
+static ssize_t temp_show(struct device *dev, struct device_attribute *devattr,
269
+ char *buf)
272270 {
273271 int nr = to_sensor_dev_attr_2(devattr)->nr;
274272 int index = to_sensor_dev_attr_2(devattr)->index;
....@@ -284,7 +282,7 @@
284282 return sprintf(buf, "%d\n", temp * 1000);
285283 }
286284
287
-static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
285
+static ssize_t alarm_show(struct device *dev, struct device_attribute *attr,
288286 char *buf)
289287 {
290288 int index = to_sensor_dev_attr(attr)->index;
....@@ -299,9 +297,9 @@
299297 return sprintf(buf, "%u\n", (data->alarms >> index) & 0x1);
300298 }
301299
302
-static ssize_t set_temp(struct device *dev,
303
- struct device_attribute *devattr,
304
- const char *buf, size_t count)
300
+static ssize_t temp_store(struct device *dev,
301
+ struct device_attribute *devattr, const char *buf,
302
+ size_t count)
305303 {
306304 int nr = to_sensor_dev_attr_2(devattr)->nr;
307305 int index = to_sensor_dev_attr_2(devattr)->index;
....@@ -326,79 +324,136 @@
326324 return ret < 0 ? ret : count;
327325 }
328326
329
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0);
330
-static SENSOR_DEVICE_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp, set_temp,
331
- 0, MAX6697_TEMP_MAX);
332
-static SENSOR_DEVICE_ATTR_2(temp1_crit, S_IRUGO | S_IWUSR, show_temp, set_temp,
333
- 0, MAX6697_TEMP_CRIT);
327
+static ssize_t offset_store(struct device *dev, struct device_attribute *devattr, const char *buf,
328
+ size_t count)
329
+{
330
+ int val, ret, index, select;
331
+ struct max6697_data *data;
332
+ bool channel_enabled;
333
+ long temp;
334334
335
-static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input, NULL, 1);
336
-static SENSOR_DEVICE_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp, set_temp,
337
- 1, MAX6697_TEMP_MAX);
338
-static SENSOR_DEVICE_ATTR_2(temp2_crit, S_IRUGO | S_IWUSR, show_temp, set_temp,
339
- 1, MAX6697_TEMP_CRIT);
335
+ index = to_sensor_dev_attr(devattr)->index;
336
+ data = dev_get_drvdata(dev);
337
+ ret = kstrtol(buf, 10, &temp);
338
+ if (ret < 0)
339
+ return ret;
340340
341
-static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp_input, NULL, 2);
342
-static SENSOR_DEVICE_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp, set_temp,
343
- 2, MAX6697_TEMP_MAX);
344
-static SENSOR_DEVICE_ATTR_2(temp3_crit, S_IRUGO | S_IWUSR, show_temp, set_temp,
345
- 2, MAX6697_TEMP_CRIT);
341
+ mutex_lock(&data->update_lock);
342
+ select = i2c_smbus_read_byte_data(data->client, MAX6581_REG_OFFSET_SELECT);
343
+ if (select < 0) {
344
+ ret = select;
345
+ goto abort;
346
+ }
347
+ channel_enabled = (select & (1 << (index - 1)));
348
+ temp = clamp_val(temp, MAX6581_OFFSET_MIN, MAX6581_OFFSET_MAX);
349
+ val = DIV_ROUND_CLOSEST(temp, 250);
350
+ /* disable the offset for channel if the new offset is 0 */
351
+ if (val == 0) {
352
+ if (channel_enabled)
353
+ ret = i2c_smbus_write_byte_data(data->client, MAX6581_REG_OFFSET_SELECT,
354
+ select & ~(1 << (index - 1)));
355
+ ret = ret < 0 ? ret : count;
356
+ goto abort;
357
+ }
358
+ if (!channel_enabled) {
359
+ ret = i2c_smbus_write_byte_data(data->client, MAX6581_REG_OFFSET_SELECT,
360
+ select | (1 << (index - 1)));
361
+ if (ret < 0)
362
+ goto abort;
363
+ }
364
+ ret = i2c_smbus_write_byte_data(data->client, MAX6581_REG_OFFSET, val);
365
+ ret = ret < 0 ? ret : count;
346366
347
-static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp_input, NULL, 3);
348
-static SENSOR_DEVICE_ATTR_2(temp4_max, S_IRUGO | S_IWUSR, show_temp, set_temp,
349
- 3, MAX6697_TEMP_MAX);
350
-static SENSOR_DEVICE_ATTR_2(temp4_crit, S_IRUGO | S_IWUSR, show_temp, set_temp,
351
- 3, MAX6697_TEMP_CRIT);
367
+abort:
368
+ mutex_unlock(&data->update_lock);
369
+ return ret;
370
+}
352371
353
-static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_temp_input, NULL, 4);
354
-static SENSOR_DEVICE_ATTR_2(temp5_max, S_IRUGO | S_IWUSR, show_temp, set_temp,
355
- 4, MAX6697_TEMP_MAX);
356
-static SENSOR_DEVICE_ATTR_2(temp5_crit, S_IRUGO | S_IWUSR, show_temp, set_temp,
357
- 4, MAX6697_TEMP_CRIT);
372
+static ssize_t offset_show(struct device *dev, struct device_attribute *devattr, char *buf)
373
+{
374
+ struct max6697_data *data;
375
+ int select, ret, index;
358376
359
-static SENSOR_DEVICE_ATTR(temp6_input, S_IRUGO, show_temp_input, NULL, 5);
360
-static SENSOR_DEVICE_ATTR_2(temp6_max, S_IRUGO | S_IWUSR, show_temp, set_temp,
361
- 5, MAX6697_TEMP_MAX);
362
-static SENSOR_DEVICE_ATTR_2(temp6_crit, S_IRUGO | S_IWUSR, show_temp, set_temp,
363
- 5, MAX6697_TEMP_CRIT);
377
+ index = to_sensor_dev_attr(devattr)->index;
378
+ data = dev_get_drvdata(dev);
379
+ mutex_lock(&data->update_lock);
380
+ select = i2c_smbus_read_byte_data(data->client, MAX6581_REG_OFFSET_SELECT);
381
+ if (select < 0)
382
+ ret = select;
383
+ else if (select & (1 << (index - 1)))
384
+ ret = i2c_smbus_read_byte_data(data->client, MAX6581_REG_OFFSET);
385
+ else
386
+ ret = 0;
387
+ mutex_unlock(&data->update_lock);
388
+ return ret < 0 ? ret : sprintf(buf, "%d\n", max6581_offset_to_millic(ret));
389
+}
364390
365
-static SENSOR_DEVICE_ATTR(temp7_input, S_IRUGO, show_temp_input, NULL, 6);
366
-static SENSOR_DEVICE_ATTR_2(temp7_max, S_IRUGO | S_IWUSR, show_temp, set_temp,
367
- 6, MAX6697_TEMP_MAX);
368
-static SENSOR_DEVICE_ATTR_2(temp7_crit, S_IRUGO | S_IWUSR, show_temp, set_temp,
369
- 6, MAX6697_TEMP_CRIT);
391
+static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_input, 0);
392
+static SENSOR_DEVICE_ATTR_2_RW(temp1_max, temp, 0, MAX6697_TEMP_MAX);
393
+static SENSOR_DEVICE_ATTR_2_RW(temp1_crit, temp, 0, MAX6697_TEMP_CRIT);
370394
371
-static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_temp_input, NULL, 7);
372
-static SENSOR_DEVICE_ATTR_2(temp8_max, S_IRUGO | S_IWUSR, show_temp, set_temp,
373
- 7, MAX6697_TEMP_MAX);
374
-static SENSOR_DEVICE_ATTR_2(temp8_crit, S_IRUGO | S_IWUSR, show_temp, set_temp,
375
- 7, MAX6697_TEMP_CRIT);
395
+static SENSOR_DEVICE_ATTR_RO(temp2_input, temp_input, 1);
396
+static SENSOR_DEVICE_ATTR_2_RW(temp2_max, temp, 1, MAX6697_TEMP_MAX);
397
+static SENSOR_DEVICE_ATTR_2_RW(temp2_crit, temp, 1, MAX6697_TEMP_CRIT);
376398
377
-static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 22);
378
-static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 16);
379
-static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_alarm, NULL, 17);
380
-static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_alarm, NULL, 18);
381
-static SENSOR_DEVICE_ATTR(temp5_max_alarm, S_IRUGO, show_alarm, NULL, 19);
382
-static SENSOR_DEVICE_ATTR(temp6_max_alarm, S_IRUGO, show_alarm, NULL, 20);
383
-static SENSOR_DEVICE_ATTR(temp7_max_alarm, S_IRUGO, show_alarm, NULL, 21);
384
-static SENSOR_DEVICE_ATTR(temp8_max_alarm, S_IRUGO, show_alarm, NULL, 23);
399
+static SENSOR_DEVICE_ATTR_RO(temp3_input, temp_input, 2);
400
+static SENSOR_DEVICE_ATTR_2_RW(temp3_max, temp, 2, MAX6697_TEMP_MAX);
401
+static SENSOR_DEVICE_ATTR_2_RW(temp3_crit, temp, 2, MAX6697_TEMP_CRIT);
385402
386
-static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 14);
387
-static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 8);
388
-static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 9);
389
-static SENSOR_DEVICE_ATTR(temp4_crit_alarm, S_IRUGO, show_alarm, NULL, 10);
390
-static SENSOR_DEVICE_ATTR(temp5_crit_alarm, S_IRUGO, show_alarm, NULL, 11);
391
-static SENSOR_DEVICE_ATTR(temp6_crit_alarm, S_IRUGO, show_alarm, NULL, 12);
392
-static SENSOR_DEVICE_ATTR(temp7_crit_alarm, S_IRUGO, show_alarm, NULL, 13);
393
-static SENSOR_DEVICE_ATTR(temp8_crit_alarm, S_IRUGO, show_alarm, NULL, 15);
403
+static SENSOR_DEVICE_ATTR_RO(temp4_input, temp_input, 3);
404
+static SENSOR_DEVICE_ATTR_2_RW(temp4_max, temp, 3, MAX6697_TEMP_MAX);
405
+static SENSOR_DEVICE_ATTR_2_RW(temp4_crit, temp, 3, MAX6697_TEMP_CRIT);
394406
395
-static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 1);
396
-static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 2);
397
-static SENSOR_DEVICE_ATTR(temp4_fault, S_IRUGO, show_alarm, NULL, 3);
398
-static SENSOR_DEVICE_ATTR(temp5_fault, S_IRUGO, show_alarm, NULL, 4);
399
-static SENSOR_DEVICE_ATTR(temp6_fault, S_IRUGO, show_alarm, NULL, 5);
400
-static SENSOR_DEVICE_ATTR(temp7_fault, S_IRUGO, show_alarm, NULL, 6);
401
-static SENSOR_DEVICE_ATTR(temp8_fault, S_IRUGO, show_alarm, NULL, 7);
407
+static SENSOR_DEVICE_ATTR_RO(temp5_input, temp_input, 4);
408
+static SENSOR_DEVICE_ATTR_2_RW(temp5_max, temp, 4, MAX6697_TEMP_MAX);
409
+static SENSOR_DEVICE_ATTR_2_RW(temp5_crit, temp, 4, MAX6697_TEMP_CRIT);
410
+
411
+static SENSOR_DEVICE_ATTR_RO(temp6_input, temp_input, 5);
412
+static SENSOR_DEVICE_ATTR_2_RW(temp6_max, temp, 5, MAX6697_TEMP_MAX);
413
+static SENSOR_DEVICE_ATTR_2_RW(temp6_crit, temp, 5, MAX6697_TEMP_CRIT);
414
+
415
+static SENSOR_DEVICE_ATTR_RO(temp7_input, temp_input, 6);
416
+static SENSOR_DEVICE_ATTR_2_RW(temp7_max, temp, 6, MAX6697_TEMP_MAX);
417
+static SENSOR_DEVICE_ATTR_2_RW(temp7_crit, temp, 6, MAX6697_TEMP_CRIT);
418
+
419
+static SENSOR_DEVICE_ATTR_RO(temp8_input, temp_input, 7);
420
+static SENSOR_DEVICE_ATTR_2_RW(temp8_max, temp, 7, MAX6697_TEMP_MAX);
421
+static SENSOR_DEVICE_ATTR_2_RW(temp8_crit, temp, 7, MAX6697_TEMP_CRIT);
422
+
423
+static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 22);
424
+static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 16);
425
+static SENSOR_DEVICE_ATTR_RO(temp3_max_alarm, alarm, 17);
426
+static SENSOR_DEVICE_ATTR_RO(temp4_max_alarm, alarm, 18);
427
+static SENSOR_DEVICE_ATTR_RO(temp5_max_alarm, alarm, 19);
428
+static SENSOR_DEVICE_ATTR_RO(temp6_max_alarm, alarm, 20);
429
+static SENSOR_DEVICE_ATTR_RO(temp7_max_alarm, alarm, 21);
430
+static SENSOR_DEVICE_ATTR_RO(temp8_max_alarm, alarm, 23);
431
+
432
+static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 14);
433
+static SENSOR_DEVICE_ATTR_RO(temp2_crit_alarm, alarm, 8);
434
+static SENSOR_DEVICE_ATTR_RO(temp3_crit_alarm, alarm, 9);
435
+static SENSOR_DEVICE_ATTR_RO(temp4_crit_alarm, alarm, 10);
436
+static SENSOR_DEVICE_ATTR_RO(temp5_crit_alarm, alarm, 11);
437
+static SENSOR_DEVICE_ATTR_RO(temp6_crit_alarm, alarm, 12);
438
+static SENSOR_DEVICE_ATTR_RO(temp7_crit_alarm, alarm, 13);
439
+static SENSOR_DEVICE_ATTR_RO(temp8_crit_alarm, alarm, 15);
440
+
441
+static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 1);
442
+static SENSOR_DEVICE_ATTR_RO(temp3_fault, alarm, 2);
443
+static SENSOR_DEVICE_ATTR_RO(temp4_fault, alarm, 3);
444
+static SENSOR_DEVICE_ATTR_RO(temp5_fault, alarm, 4);
445
+static SENSOR_DEVICE_ATTR_RO(temp6_fault, alarm, 5);
446
+static SENSOR_DEVICE_ATTR_RO(temp7_fault, alarm, 6);
447
+static SENSOR_DEVICE_ATTR_RO(temp8_fault, alarm, 7);
448
+
449
+/* There is no offset for local temperature so starting from temp2 */
450
+static SENSOR_DEVICE_ATTR_RW(temp2_offset, offset, 1);
451
+static SENSOR_DEVICE_ATTR_RW(temp3_offset, offset, 2);
452
+static SENSOR_DEVICE_ATTR_RW(temp4_offset, offset, 3);
453
+static SENSOR_DEVICE_ATTR_RW(temp5_offset, offset, 4);
454
+static SENSOR_DEVICE_ATTR_RW(temp6_offset, offset, 5);
455
+static SENSOR_DEVICE_ATTR_RW(temp7_offset, offset, 6);
456
+static SENSOR_DEVICE_ATTR_RW(temp8_offset, offset, 7);
402457
403458 static DEVICE_ATTR(dummy, 0, NULL, NULL);
404459
....@@ -408,8 +463,8 @@
408463 struct device *dev = container_of(kobj, struct device, kobj);
409464 struct max6697_data *data = dev_get_drvdata(dev);
410465 const struct max6697_chip_data *chip = data->chip;
411
- int channel = index / 6; /* channel number */
412
- int nr = index % 6; /* attribute index within channel */
466
+ int channel = index / 7; /* channel number */
467
+ int nr = index % 7; /* attribute index within channel */
413468
414469 if (channel >= chip->channels)
415470 return 0;
....@@ -418,6 +473,10 @@
418473 return 0;
419474 if (nr == 5 && !(chip->have_fault & (1 << channel)))
420475 return 0;
476
+ /* offset reg is only supported on max6581 remote channels */
477
+ if (nr == 6)
478
+ if (data->type != max6581 || channel == 0)
479
+ return 0;
421480
422481 return attr->mode;
423482 }
....@@ -434,6 +493,7 @@
434493 &sensor_dev_attr_temp1_crit.dev_attr.attr,
435494 &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr,
436495 &dev_attr_dummy.attr,
496
+ &dev_attr_dummy.attr,
437497
438498 &sensor_dev_attr_temp2_input.dev_attr.attr,
439499 &sensor_dev_attr_temp2_max.dev_attr.attr,
....@@ -441,6 +501,7 @@
441501 &sensor_dev_attr_temp2_crit.dev_attr.attr,
442502 &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr,
443503 &sensor_dev_attr_temp2_fault.dev_attr.attr,
504
+ &sensor_dev_attr_temp2_offset.dev_attr.attr,
444505
445506 &sensor_dev_attr_temp3_input.dev_attr.attr,
446507 &sensor_dev_attr_temp3_max.dev_attr.attr,
....@@ -448,6 +509,7 @@
448509 &sensor_dev_attr_temp3_crit.dev_attr.attr,
449510 &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr,
450511 &sensor_dev_attr_temp3_fault.dev_attr.attr,
512
+ &sensor_dev_attr_temp3_offset.dev_attr.attr,
451513
452514 &sensor_dev_attr_temp4_input.dev_attr.attr,
453515 &sensor_dev_attr_temp4_max.dev_attr.attr,
....@@ -455,6 +517,7 @@
455517 &sensor_dev_attr_temp4_crit.dev_attr.attr,
456518 &sensor_dev_attr_temp4_crit_alarm.dev_attr.attr,
457519 &sensor_dev_attr_temp4_fault.dev_attr.attr,
520
+ &sensor_dev_attr_temp4_offset.dev_attr.attr,
458521
459522 &sensor_dev_attr_temp5_input.dev_attr.attr,
460523 &sensor_dev_attr_temp5_max.dev_attr.attr,
....@@ -462,6 +525,7 @@
462525 &sensor_dev_attr_temp5_crit.dev_attr.attr,
463526 &sensor_dev_attr_temp5_crit_alarm.dev_attr.attr,
464527 &sensor_dev_attr_temp5_fault.dev_attr.attr,
528
+ &sensor_dev_attr_temp5_offset.dev_attr.attr,
465529
466530 &sensor_dev_attr_temp6_input.dev_attr.attr,
467531 &sensor_dev_attr_temp6_max.dev_attr.attr,
....@@ -469,6 +533,7 @@
469533 &sensor_dev_attr_temp6_crit.dev_attr.attr,
470534 &sensor_dev_attr_temp6_crit_alarm.dev_attr.attr,
471535 &sensor_dev_attr_temp6_fault.dev_attr.attr,
536
+ &sensor_dev_attr_temp6_offset.dev_attr.attr,
472537
473538 &sensor_dev_attr_temp7_input.dev_attr.attr,
474539 &sensor_dev_attr_temp7_max.dev_attr.attr,
....@@ -476,6 +541,7 @@
476541 &sensor_dev_attr_temp7_crit.dev_attr.attr,
477542 &sensor_dev_attr_temp7_crit_alarm.dev_attr.attr,
478543 &sensor_dev_attr_temp7_fault.dev_attr.attr,
544
+ &sensor_dev_attr_temp7_offset.dev_attr.attr,
479545
480546 &sensor_dev_attr_temp8_input.dev_attr.attr,
481547 &sensor_dev_attr_temp8_max.dev_attr.attr,
....@@ -483,6 +549,7 @@
483549 &sensor_dev_attr_temp8_crit.dev_attr.attr,
484550 &sensor_dev_attr_temp8_crit_alarm.dev_attr.attr,
485551 &sensor_dev_attr_temp8_fault.dev_attr.attr,
552
+ &sensor_dev_attr_temp8_offset.dev_attr.attr,
486553 NULL
487554 };
488555
....@@ -618,8 +685,9 @@
618685 return 0;
619686 }
620687
621
-static int max6697_probe(struct i2c_client *client,
622
- const struct i2c_device_id *id)
688
+static const struct i2c_device_id max6697_id[];
689
+
690
+static int max6697_probe(struct i2c_client *client)
623691 {
624692 struct i2c_adapter *adapter = client->adapter;
625693 struct device *dev = &client->dev;
....@@ -637,7 +705,7 @@
637705 if (client->dev.of_node)
638706 data->type = (enum chips)of_device_get_match_data(&client->dev);
639707 else
640
- data->type = id->driver_data;
708
+ data->type = i2c_match_id(max6697_id, client)->driver_data;
641709 data->chip = &max6697_chip_data[data->type];
642710 data->client = client;
643711 mutex_init(&data->update_lock);
....@@ -667,7 +735,7 @@
667735 };
668736 MODULE_DEVICE_TABLE(i2c, max6697_id);
669737
670
-static const struct of_device_id max6697_of_match[] = {
738
+static const struct of_device_id __maybe_unused max6697_of_match[] = {
671739 {
672740 .compatible = "maxim,max6581",
673741 .data = (void *)max6581
....@@ -718,7 +786,7 @@
718786 .name = "max6697",
719787 .of_match_table = of_match_ptr(max6697_of_match),
720788 },
721
- .probe = max6697_probe,
789
+ .probe_new = max6697_probe,
722790 .id_table = max6697_id,
723791 };
724792