hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/drivers/hwmon/lm77.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * lm77.c - Part of lm_sensors, Linux kernel modules for hardware
34 * monitoring
....@@ -9,16 +10,6 @@
910 * resolution made by National Semiconductor. Complete datasheet can be
1011 * obtained at their site:
1112 * http://www.national.com/pf/LM/LM77.html
12
- *
13
- * This program is free software; you can redistribute it and/or modify
14
- * it under the terms of the GNU General Public License as published by
15
- * the Free Software Foundation; either version 2 of the License, or
16
- * (at your option) any later version.
17
- *
18
- * This program is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- * GNU General Public License for more details.
2213 */
2314
2415 #include <linux/module.h>
....@@ -137,7 +128,7 @@
137128
138129 /* sysfs stuff */
139130
140
-static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
131
+static ssize_t temp_show(struct device *dev, struct device_attribute *devattr,
141132 char *buf)
142133 {
143134 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
....@@ -146,7 +137,7 @@
146137 return sprintf(buf, "%d\n", data->temp[attr->index]);
147138 }
148139
149
-static ssize_t show_temp_hyst(struct device *dev,
140
+static ssize_t temp_hyst_show(struct device *dev,
150141 struct device_attribute *devattr, char *buf)
151142 {
152143 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
....@@ -160,8 +151,9 @@
160151 return sprintf(buf, "%d\n", temp);
161152 }
162153
163
-static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
164
- const char *buf, size_t count)
154
+static ssize_t temp_store(struct device *dev,
155
+ struct device_attribute *devattr, const char *buf,
156
+ size_t count)
165157 {
166158 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
167159 struct lm77_data *data = dev_get_drvdata(dev);
....@@ -186,9 +178,9 @@
186178 * hysteresis is stored as a relative value on the chip, so it has to be
187179 * converted first.
188180 */
189
-static ssize_t set_temp_hyst(struct device *dev,
190
- struct device_attribute *devattr,
191
- const char *buf, size_t count)
181
+static ssize_t temp_hyst_store(struct device *dev,
182
+ struct device_attribute *devattr,
183
+ const char *buf, size_t count)
192184 {
193185 struct lm77_data *data = dev_get_drvdata(dev);
194186 struct i2c_client *client = data->client;
....@@ -208,7 +200,7 @@
208200 return count;
209201 }
210202
211
-static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
203
+static ssize_t alarm_show(struct device *dev, struct device_attribute *attr,
212204 char *buf)
213205 {
214206 int bitnr = to_sensor_dev_attr(attr)->index;
....@@ -216,22 +208,18 @@
216208 return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1);
217209 }
218210
219
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, t_input);
220
-static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp, set_temp,
221
- t_crit);
222
-static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp, set_temp,
223
- t_min);
224
-static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp, set_temp,
225
- t_max);
211
+static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, t_input);
212
+static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp, t_crit);
213
+static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, t_min);
214
+static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, t_max);
226215
227
-static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp_hyst,
228
- set_temp_hyst, t_crit);
229
-static SENSOR_DEVICE_ATTR(temp1_min_hyst, S_IRUGO, show_temp_hyst, NULL, t_min);
230
-static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO, show_temp_hyst, NULL, t_max);
216
+static SENSOR_DEVICE_ATTR_RW(temp1_crit_hyst, temp_hyst, t_crit);
217
+static SENSOR_DEVICE_ATTR_RO(temp1_min_hyst, temp_hyst, t_min);
218
+static SENSOR_DEVICE_ATTR_RO(temp1_max_hyst, temp_hyst, t_max);
231219
232
-static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 2);
233
-static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 0);
234
-static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 1);
220
+static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 2);
221
+static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, 0);
222
+static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 1);
235223
236224 static struct attribute *lm77_attrs[] = {
237225 &sensor_dev_attr_temp1_input.dev_attr.attr,
....@@ -327,7 +315,7 @@
327315 lm77_write_value(client, LM77_REG_CONF, conf & 0xfe);
328316 }
329317
330
-static int lm77_probe(struct i2c_client *client, const struct i2c_device_id *id)
318
+static int lm77_probe(struct i2c_client *client)
331319 {
332320 struct device *dev = &client->dev;
333321 struct device *hwmon_dev;
....@@ -360,7 +348,7 @@
360348 .driver = {
361349 .name = "lm77",
362350 },
363
- .probe = lm77_probe,
351
+ .probe_new = lm77_probe,
364352 .id_table = lm77_id,
365353 .detect = lm77_detect,
366354 .address_list = normal_i2c,