hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/hwmon/lm95245.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright (C) 2011 Alexander Stein <alexander.stein@systec-electronic.com>
34 *
....@@ -5,16 +6,6 @@
56 * It reports up to two temperatures (its own plus an external one).
67 *
78 * This driver is based on lm95241.c
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
189 */
1910
2011 #include <linux/err.h>
....@@ -91,19 +82,6 @@
9182 #define MANUFACTURER_ID 0x01
9283 #define LM95235_REVISION 0xB1
9384 #define LM95245_REVISION 0xB3
94
-
95
-static const u8 lm95245_reg_address[] = {
96
- LM95245_REG_R_LOCAL_TEMPH_S,
97
- LM95245_REG_R_LOCAL_TEMPL_S,
98
- LM95245_REG_R_REMOTE_TEMPH_S,
99
- LM95245_REG_R_REMOTE_TEMPL_S,
100
- LM95245_REG_R_REMOTE_TEMPH_U,
101
- LM95245_REG_R_REMOTE_TEMPL_U,
102
- LM95245_REG_RW_LOCAL_OS_TCRIT_LIMIT,
103
- LM95245_REG_RW_REMOTE_TCRIT_LIMIT,
104
- LM95245_REG_RW_COMMON_HYSTERESIS,
105
- LM95245_REG_R_STATUS1,
106
-};
10785
10886 /* Client data (each client gets its own) */
10987 struct lm95245_data {
....@@ -421,14 +399,14 @@
421399 case hwmon_temp_max_hyst:
422400 case hwmon_temp_crit_alarm:
423401 case hwmon_temp_fault:
424
- return S_IRUGO;
402
+ return 0444;
425403 case hwmon_temp_type:
426404 case hwmon_temp_max:
427405 case hwmon_temp_crit:
428406 case hwmon_temp_offset:
429
- return S_IRUGO | S_IWUSR;
407
+ return 0644;
430408 case hwmon_temp_crit_hyst:
431
- return (channel == 0) ? S_IRUGO | S_IWUSR : S_IRUGO;
409
+ return (channel == 0) ? 0644 : 0444;
432410 default:
433411 return 0;
434412 }
....@@ -442,7 +420,7 @@
442420 case hwmon_chip:
443421 switch (attr) {
444422 case hwmon_chip_update_interval:
445
- return S_IRUGO | S_IWUSR;
423
+ return 0644;
446424 default:
447425 return 0;
448426 }
....@@ -541,35 +519,20 @@
541519 .writeable_reg = lm95245_is_writeable_reg,
542520 .volatile_reg = lm95245_is_volatile_reg,
543521 .cache_type = REGCACHE_RBTREE,
544
- .use_single_rw = true,
545
-};
546
-
547
-static const u32 lm95245_chip_config[] = {
548
- HWMON_C_UPDATE_INTERVAL,
549
- 0
550
-};
551
-
552
-static const struct hwmon_channel_info lm95245_chip = {
553
- .type = hwmon_chip,
554
- .config = lm95245_chip_config,
555
-};
556
-
557
-static const u32 lm95245_temp_config[] = {
558
- HWMON_T_INPUT | HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_CRIT_ALARM,
559
- HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST | HWMON_T_CRIT |
560
- HWMON_T_CRIT_HYST | HWMON_T_FAULT | HWMON_T_MAX_ALARM |
561
- HWMON_T_CRIT_ALARM | HWMON_T_TYPE | HWMON_T_OFFSET,
562
- 0
563
-};
564
-
565
-static const struct hwmon_channel_info lm95245_temp = {
566
- .type = hwmon_temp,
567
- .config = lm95245_temp_config,
522
+ .use_single_read = true,
523
+ .use_single_write = true,
568524 };
569525
570526 static const struct hwmon_channel_info *lm95245_info[] = {
571
- &lm95245_chip,
572
- &lm95245_temp,
527
+ HWMON_CHANNEL_INFO(chip,
528
+ HWMON_C_UPDATE_INTERVAL),
529
+ HWMON_CHANNEL_INFO(temp,
530
+ HWMON_T_INPUT | HWMON_T_CRIT | HWMON_T_CRIT_HYST |
531
+ HWMON_T_CRIT_ALARM,
532
+ HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST |
533
+ HWMON_T_CRIT | HWMON_T_CRIT_HYST | HWMON_T_FAULT |
534
+ HWMON_T_MAX_ALARM | HWMON_T_CRIT_ALARM |
535
+ HWMON_T_TYPE | HWMON_T_OFFSET),
573536 NULL
574537 };
575538
....@@ -584,8 +547,7 @@
584547 .info = lm95245_info,
585548 };
586549
587
-static int lm95245_probe(struct i2c_client *client,
588
- const struct i2c_device_id *id)
550
+static int lm95245_probe(struct i2c_client *client)
589551 {
590552 struct device *dev = &client->dev;
591553 struct lm95245_data *data;
....@@ -622,7 +584,7 @@
622584 };
623585 MODULE_DEVICE_TABLE(i2c, lm95245_id);
624586
625
-static const struct of_device_id lm95245_of_match[] = {
587
+static const struct of_device_id __maybe_unused lm95245_of_match[] = {
626588 { .compatible = "national,lm95235" },
627589 { .compatible = "national,lm95245" },
628590 { },
....@@ -635,7 +597,7 @@
635597 .name = "lm95245",
636598 .of_match_table = of_match_ptr(lm95245_of_match),
637599 },
638
- .probe = lm95245_probe,
600
+ .probe_new = lm95245_probe,
639601 .id_table = lm95245_id,
640602 .detect = lm95245_detect,
641603 .address_list = normal_i2c,