hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/hwmon/tmp103.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Texas Instruments TMP103 SMBus temperature sensor driver
34 * Copyright (C) 2014 Heiko Schocher <hs@denx.de>
....@@ -6,17 +7,6 @@
67 * Texas Instruments TMP102 SMBus temperature sensor driver
78 *
89 * Copyright (C) 2010 Steven King <sfking@fdwdc.com>
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
19
- *
2010 */
2111
2212 #include <linux/module.h>
....@@ -61,9 +51,8 @@
6151 return DIV_ROUND_CLOSEST(val, 1000);
6252 }
6353
64
-static ssize_t tmp103_show_temp(struct device *dev,
65
- struct device_attribute *attr,
66
- char *buf)
54
+static ssize_t tmp103_temp_show(struct device *dev,
55
+ struct device_attribute *attr, char *buf)
6756 {
6857 struct sensor_device_attribute *sda = to_sensor_dev_attr(attr);
6958 struct regmap *regmap = dev_get_drvdata(dev);
....@@ -77,9 +66,9 @@
7766 return sprintf(buf, "%d\n", tmp103_reg_to_mc(regval));
7867 }
7968
80
-static ssize_t tmp103_set_temp(struct device *dev,
81
- struct device_attribute *attr,
82
- const char *buf, size_t count)
69
+static ssize_t tmp103_temp_store(struct device *dev,
70
+ struct device_attribute *attr,
71
+ const char *buf, size_t count)
8372 {
8473 struct sensor_device_attribute *sda = to_sensor_dev_attr(attr);
8574 struct regmap *regmap = dev_get_drvdata(dev);
....@@ -94,14 +83,11 @@
9483 return ret ? ret : count;
9584 }
9685
97
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, tmp103_show_temp, NULL ,
98
- TMP103_TEMP_REG);
86
+static SENSOR_DEVICE_ATTR_RO(temp1_input, tmp103_temp, TMP103_TEMP_REG);
9987
100
-static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, tmp103_show_temp,
101
- tmp103_set_temp, TMP103_TLOW_REG);
88
+static SENSOR_DEVICE_ATTR_RW(temp1_min, tmp103_temp, TMP103_TLOW_REG);
10289
103
-static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, tmp103_show_temp,
104
- tmp103_set_temp, TMP103_THIGH_REG);
90
+static SENSOR_DEVICE_ATTR_RW(temp1_max, tmp103_temp, TMP103_THIGH_REG);
10591
10692 static struct attribute *tmp103_attrs[] = {
10793 &sensor_dev_attr_temp1_input.dev_attr.attr,
....@@ -123,8 +109,7 @@
123109 .volatile_reg = tmp103_regmap_is_volatile,
124110 };
125111
126
-static int tmp103_probe(struct i2c_client *client,
127
- const struct i2c_device_id *id)
112
+static int tmp103_probe(struct i2c_client *client)
128113 {
129114 struct device *dev = &client->dev;
130115 struct device *hwmon_dev;
....@@ -174,7 +159,7 @@
174159 };
175160 MODULE_DEVICE_TABLE(i2c, tmp103_id);
176161
177
-static const struct of_device_id tmp103_of_match[] = {
162
+static const struct of_device_id __maybe_unused tmp103_of_match[] = {
178163 { .compatible = "ti,tmp103" },
179164 { },
180165 };
....@@ -186,7 +171,7 @@
186171 .of_match_table = of_match_ptr(tmp103_of_match),
187172 .pm = &tmp103_dev_pm_ops,
188173 },
189
- .probe = tmp103_probe,
174
+ .probe_new = tmp103_probe,
190175 .id_table = tmp103_id,
191176 };
192177