forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/hwmon/hih6130.c
....@@ -1,23 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* Honeywell HIH-6130/HIH-6131 humidity and temperature sensor driver
23 *
34 * Copyright (C) 2012 Iain Paton <ipaton0@gmail.com>
45 *
56 * heavily based on the sht21 driver
67 * Copyright (C) 2010 Urs Fleisch <urs.fleisch@sensirion.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program; if not, write to the Free Software
20
- * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA
218 *
229 * Data sheets available (2012-06-22) at
2310 * http://sensing.honeywell.com/index.php?ci_id=3106&la_id=1&defId=44872
....@@ -171,7 +158,7 @@
171158 * Will be called on read access to temp1_input sysfs attribute.
172159 * Returns number of bytes written into buffer, negative errno on error.
173160 */
174
-static ssize_t hih6130_show_temperature(struct device *dev,
161
+static ssize_t hih6130_temperature_show(struct device *dev,
175162 struct device_attribute *attr,
176163 char *buf)
177164 {
....@@ -193,7 +180,7 @@
193180 * Will be called on read access to humidity1_input sysfs attribute.
194181 * Returns number of bytes written into buffer, negative errno on error.
195182 */
196
-static ssize_t hih6130_show_humidity(struct device *dev,
183
+static ssize_t hih6130_humidity_show(struct device *dev,
197184 struct device_attribute *attr, char *buf)
198185 {
199186 struct hih6130 *hih6130 = dev_get_drvdata(dev);
....@@ -206,10 +193,8 @@
206193 }
207194
208195 /* sysfs attributes */
209
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, hih6130_show_temperature,
210
- NULL, 0);
211
-static SENSOR_DEVICE_ATTR(humidity1_input, S_IRUGO, hih6130_show_humidity,
212
- NULL, 0);
196
+static SENSOR_DEVICE_ATTR_RO(temp1_input, hih6130_temperature, 0);
197
+static SENSOR_DEVICE_ATTR_RO(humidity1_input, hih6130_humidity, 0);
213198
214199 static struct attribute *hih6130_attrs[] = {
215200 &sensor_dev_attr_temp1_input.dev_attr.attr,
....@@ -219,8 +204,7 @@
219204
220205 ATTRIBUTE_GROUPS(hih6130);
221206
222
-static int hih6130_probe(struct i2c_client *client,
223
- const struct i2c_device_id *id)
207
+static int hih6130_probe(struct i2c_client *client)
224208 {
225209 struct device *dev = &client->dev;
226210 struct hih6130 *hih6130;
....@@ -254,9 +238,18 @@
254238 };
255239 MODULE_DEVICE_TABLE(i2c, hih6130_id);
256240
241
+static const struct of_device_id __maybe_unused hih6130_of_match[] = {
242
+ { .compatible = "honeywell,hih6130", },
243
+ { }
244
+};
245
+MODULE_DEVICE_TABLE(of, hih6130_of_match);
246
+
257247 static struct i2c_driver hih6130_driver = {
258
- .driver.name = "hih6130",
259
- .probe = hih6130_probe,
248
+ .driver = {
249
+ .name = "hih6130",
250
+ .of_match_table = of_match_ptr(hih6130_of_match),
251
+ },
252
+ .probe_new = hih6130_probe,
260253 .id_table = hih6130_id,
261254 };
262255