forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/hwmon/sht3x.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* Sensirion SHT3x-DIS humidity and temperature sensor driver.
23 * The SHT3x comes in many different versions, this driver is for the
34 * I2C version only.
....@@ -5,17 +6,6 @@
56 * Copyright (C) 2016 Sensirion AG, Switzerland
67 * Author: David Frey <david.frey@sensirion.com>
78 * Author: Pascal Sachs <pascal.sachs@sensirion.com>
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.
18
- *
199 */
2010
2111 #include <asm/page.h>
....@@ -629,40 +619,22 @@
629619 return count;
630620 }
631621
632
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, temp1_input_show, NULL, 0);
633
-static SENSOR_DEVICE_ATTR(humidity1_input, S_IRUGO, humidity1_input_show,
634
- NULL, 0);
635
-static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR,
636
- temp1_limit_show, temp1_limit_store,
637
- limit_max);
638
-static SENSOR_DEVICE_ATTR(humidity1_max, S_IRUGO | S_IWUSR,
639
- humidity1_limit_show, humidity1_limit_store,
640
- limit_max);
641
-static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR,
642
- temp1_limit_show, temp1_limit_store,
643
- limit_max_hyst);
644
-static SENSOR_DEVICE_ATTR(humidity1_max_hyst, S_IRUGO | S_IWUSR,
645
- humidity1_limit_show, humidity1_limit_store,
646
- limit_max_hyst);
647
-static SENSOR_DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR,
648
- temp1_limit_show, temp1_limit_store,
649
- limit_min);
650
-static SENSOR_DEVICE_ATTR(humidity1_min, S_IRUGO | S_IWUSR,
651
- humidity1_limit_show, humidity1_limit_store,
652
- limit_min);
653
-static SENSOR_DEVICE_ATTR(temp1_min_hyst, S_IRUGO | S_IWUSR,
654
- temp1_limit_show, temp1_limit_store,
655
- limit_min_hyst);
656
-static SENSOR_DEVICE_ATTR(humidity1_min_hyst, S_IRUGO | S_IWUSR,
657
- humidity1_limit_show, humidity1_limit_store,
658
- limit_min_hyst);
659
-static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, temp1_alarm_show, NULL, 0);
660
-static SENSOR_DEVICE_ATTR(humidity1_alarm, S_IRUGO, humidity1_alarm_show,
661
- NULL, 0);
662
-static SENSOR_DEVICE_ATTR(heater_enable, S_IRUGO | S_IWUSR,
663
- heater_enable_show, heater_enable_store, 0);
664
-static SENSOR_DEVICE_ATTR(update_interval, S_IRUGO | S_IWUSR,
665
- update_interval_show, update_interval_store, 0);
622
+static SENSOR_DEVICE_ATTR_RO(temp1_input, temp1_input, 0);
623
+static SENSOR_DEVICE_ATTR_RO(humidity1_input, humidity1_input, 0);
624
+static SENSOR_DEVICE_ATTR_RW(temp1_max, temp1_limit, limit_max);
625
+static SENSOR_DEVICE_ATTR_RW(humidity1_max, humidity1_limit, limit_max);
626
+static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, temp1_limit, limit_max_hyst);
627
+static SENSOR_DEVICE_ATTR_RW(humidity1_max_hyst, humidity1_limit,
628
+ limit_max_hyst);
629
+static SENSOR_DEVICE_ATTR_RW(temp1_min, temp1_limit, limit_min);
630
+static SENSOR_DEVICE_ATTR_RW(humidity1_min, humidity1_limit, limit_min);
631
+static SENSOR_DEVICE_ATTR_RW(temp1_min_hyst, temp1_limit, limit_min_hyst);
632
+static SENSOR_DEVICE_ATTR_RW(humidity1_min_hyst, humidity1_limit,
633
+ limit_min_hyst);
634
+static SENSOR_DEVICE_ATTR_RO(temp1_alarm, temp1_alarm, 0);
635
+static SENSOR_DEVICE_ATTR_RO(humidity1_alarm, humidity1_alarm, 0);
636
+static SENSOR_DEVICE_ATTR_RW(heater_enable, heater_enable, 0);
637
+static SENSOR_DEVICE_ATTR_RW(update_interval, update_interval, 0);
666638
667639 static struct attribute *sht3x_attrs[] = {
668640 &sensor_dev_attr_temp1_input.dev_attr.attr,
....@@ -690,8 +662,9 @@
690662 ATTRIBUTE_GROUPS(sht3x);
691663 ATTRIBUTE_GROUPS(sts3x);
692664
693
-static int sht3x_probe(struct i2c_client *client,
694
- const struct i2c_device_id *id)
665
+static const struct i2c_device_id sht3x_ids[];
666
+
667
+static int sht3x_probe(struct i2c_client *client)
695668 {
696669 int ret;
697670 struct sht3x_data *data;
....@@ -743,7 +716,7 @@
743716 if (ret)
744717 return ret;
745718
746
- if (id->driver_data == sts3x)
719
+ if (i2c_match_id(sht3x_ids, client)->driver_data == sts3x)
747720 attribute_groups = sts3x_groups;
748721 else
749722 attribute_groups = sht3x_groups;
....@@ -770,7 +743,7 @@
770743
771744 static struct i2c_driver sht3x_i2c_driver = {
772745 .driver.name = "sht3x",
773
- .probe = sht3x_probe,
746
+ .probe_new = sht3x_probe,
774747 .id_table = sht3x_ids,
775748 };
776749