hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwmon/max1619.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * max1619.c - Part of lm_sensors, Linux kernel modules for hardware
34 * monitoring
....@@ -9,16 +10,6 @@
910 * one external one). Complete datasheet can be
1011 * obtained from Maxim's website at:
1112 * http://pdfserv.maxim-ic.com/en/ds/MAX1619.pdf
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>
....@@ -145,7 +136,7 @@
145136 * Sysfs stuff
146137 */
147138
148
-static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
139
+static ssize_t temp_show(struct device *dev, struct device_attribute *devattr,
149140 char *buf)
150141 {
151142 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
....@@ -154,8 +145,9 @@
154145 return sprintf(buf, "%d\n", temp_from_reg(data->temp[attr->index]));
155146 }
156147
157
-static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
158
- const char *buf, size_t count)
148
+static ssize_t temp_store(struct device *dev,
149
+ struct device_attribute *devattr, const char *buf,
150
+ size_t count)
159151 {
160152 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
161153 struct max1619_data *data = dev_get_drvdata(dev);
....@@ -180,7 +172,7 @@
180172 return sprintf(buf, "%d\n", data->alarms);
181173 }
182174
183
-static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
175
+static ssize_t alarm_show(struct device *dev, struct device_attribute *attr,
184176 char *buf)
185177 {
186178 int bitnr = to_sensor_dev_attr(attr)->index;
....@@ -188,22 +180,18 @@
188180 return sprintf(buf, "%d\n", (data->alarms >> bitnr) & 1);
189181 }
190182
191
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, t_input1);
192
-static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, t_input2);
193
-static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp, set_temp,
194
- t_low2);
195
-static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp, set_temp,
196
- t_high2);
197
-static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp, set_temp,
198
- t_crit2);
199
-static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_temp,
200
- set_temp, t_hyst2);
183
+static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, t_input1);
184
+static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, t_input2);
185
+static SENSOR_DEVICE_ATTR_RW(temp2_min, temp, t_low2);
186
+static SENSOR_DEVICE_ATTR_RW(temp2_max, temp, t_high2);
187
+static SENSOR_DEVICE_ATTR_RW(temp2_crit, temp, t_crit2);
188
+static SENSOR_DEVICE_ATTR_RW(temp2_crit_hyst, temp, t_hyst2);
201189
202190 static DEVICE_ATTR_RO(alarms);
203
-static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 1);
204
-static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2);
205
-static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3);
206
-static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4);
191
+static SENSOR_DEVICE_ATTR_RO(temp2_crit_alarm, alarm, 1);
192
+static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 2);
193
+static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, alarm, 3);
194
+static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 4);
207195
208196 static struct attribute *max1619_attrs[] = {
209197 &sensor_dev_attr_temp1_input.dev_attr.attr,
....@@ -273,8 +261,7 @@
273261 config & 0xBF); /* run */
274262 }
275263
276
-static int max1619_probe(struct i2c_client *new_client,
277
- const struct i2c_device_id *id)
264
+static int max1619_probe(struct i2c_client *new_client)
278265 {
279266 struct max1619_data *data;
280267 struct device *hwmon_dev;
....@@ -318,7 +305,7 @@
318305 .name = "max1619",
319306 .of_match_table = of_match_ptr(max1619_of_match),
320307 },
321
- .probe = max1619_probe,
308
+ .probe_new = max1619_probe,
322309 .id_table = max1619_id,
323310 .detect = max1619_detect,
324311 .address_list = normal_i2c,