hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/hwmon/lm73.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * LM73 Sensor driver
34 * Based on LM75
....@@ -9,10 +10,6 @@
910 * Adrien Demarez <adrien.demarez@bolloretelecom.eu>
1011 * Jeremy Laine <jeremy.laine@bolloretelecom.eu>
1112 * Chris Verges <kg4ysn@gmail.com>
12
- *
13
- * This software program is licensed subject to the GNU General Public License
14
- * (GPL).Version 2,June 1991, available at
15
- * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
1613 */
1714
1815 #include <linux/module.h>
....@@ -62,8 +59,8 @@
6259
6360 /*-----------------------------------------------------------------------*/
6461
65
-static ssize_t set_temp(struct device *dev, struct device_attribute *da,
66
- const char *buf, size_t count)
62
+static ssize_t temp_store(struct device *dev, struct device_attribute *da,
63
+ const char *buf, size_t count)
6764 {
6865 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
6966 struct lm73_data *data = dev_get_drvdata(dev);
....@@ -81,7 +78,7 @@
8178 return (err < 0) ? err : count;
8279 }
8380
84
-static ssize_t show_temp(struct device *dev, struct device_attribute *da,
81
+static ssize_t temp_show(struct device *dev, struct device_attribute *da,
8582 char *buf)
8683 {
8784 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
....@@ -98,8 +95,8 @@
9895 return scnprintf(buf, PAGE_SIZE, "%d\n", temp);
9996 }
10097
101
-static ssize_t set_convrate(struct device *dev, struct device_attribute *da,
102
- const char *buf, size_t count)
98
+static ssize_t convrate_store(struct device *dev, struct device_attribute *da,
99
+ const char *buf, size_t count)
103100 {
104101 struct lm73_data *data = dev_get_drvdata(dev);
105102 unsigned long convrate;
....@@ -133,7 +130,7 @@
133130 return count;
134131 }
135132
136
-static ssize_t show_convrate(struct device *dev, struct device_attribute *da,
133
+static ssize_t convrate_show(struct device *dev, struct device_attribute *da,
137134 char *buf)
138135 {
139136 struct lm73_data *data = dev_get_drvdata(dev);
....@@ -143,7 +140,7 @@
143140 return scnprintf(buf, PAGE_SIZE, "%hu\n", lm73_convrates[res]);
144141 }
145142
146
-static ssize_t show_maxmin_alarm(struct device *dev,
143
+static ssize_t maxmin_alarm_show(struct device *dev,
147144 struct device_attribute *da, char *buf)
148145 {
149146 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
....@@ -168,18 +165,14 @@
168165
169166 /* sysfs attributes for hwmon */
170167
171
-static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO,
172
- show_temp, set_temp, LM73_REG_MAX);
173
-static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO,
174
- show_temp, set_temp, LM73_REG_MIN);
175
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO,
176
- show_temp, NULL, LM73_REG_INPUT);
177
-static SENSOR_DEVICE_ATTR(update_interval, S_IWUSR | S_IRUGO,
178
- show_convrate, set_convrate, 0);
179
-static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO,
180
- show_maxmin_alarm, NULL, LM73_CTRL_HI_SHIFT);
181
-static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO,
182
- show_maxmin_alarm, NULL, LM73_CTRL_LO_SHIFT);
168
+static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, LM73_REG_MAX);
169
+static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, LM73_REG_MIN);
170
+static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, LM73_REG_INPUT);
171
+static SENSOR_DEVICE_ATTR_RW(update_interval, convrate, 0);
172
+static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, maxmin_alarm,
173
+ LM73_CTRL_HI_SHIFT);
174
+static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, maxmin_alarm,
175
+ LM73_CTRL_LO_SHIFT);
183176
184177 static struct attribute *lm73_attrs[] = {
185178 &sensor_dev_attr_temp1_input.dev_attr.attr,
....@@ -197,7 +190,7 @@
197190 /* device probe and removal */
198191
199192 static int
200
-lm73_probe(struct i2c_client *client, const struct i2c_device_id *id)
193
+lm73_probe(struct i2c_client *client)
201194 {
202195 struct device *dev = &client->dev;
203196 struct device *hwmon_dev;
....@@ -269,12 +262,22 @@
269262 return 0;
270263 }
271264
265
+static const struct of_device_id lm73_of_match[] = {
266
+ {
267
+ .compatible = "ti,lm73",
268
+ },
269
+ { },
270
+};
271
+
272
+MODULE_DEVICE_TABLE(of, lm73_of_match);
273
+
272274 static struct i2c_driver lm73_driver = {
273275 .class = I2C_CLASS_HWMON,
274276 .driver = {
275277 .name = "lm73",
278
+ .of_match_table = lm73_of_match,
276279 },
277
- .probe = lm73_probe,
280
+ .probe_new = lm73_probe,
278281 .id_table = lm73_ids,
279282 .detect = lm73_detect,
280283 .address_list = normal_i2c,