hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/hwmon/ltc4261.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for Linear Technology LTC4261 I2C Negative Voltage Hot Swap Controller
34 *
....@@ -9,20 +10,6 @@
910 * Copyright (C) 2008 Ira W. Snyder <iws@ovro.caltech.edu>
1011 *
1112 * Datasheet: http://cds.linear.com/docs/Datasheet/42612fb.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.
22
- *
23
- * You should have received a copy of the GNU General Public License
24
- * along with this program; if not, write to the Free Software
25
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2613 */
2714
2815 #include <linux/kernel.h>
....@@ -132,7 +119,7 @@
132119 return val;
133120 }
134121
135
-static ssize_t ltc4261_show_value(struct device *dev,
122
+static ssize_t ltc4261_value_show(struct device *dev,
136123 struct device_attribute *da, char *buf)
137124 {
138125 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
....@@ -146,7 +133,7 @@
146133 return snprintf(buf, PAGE_SIZE, "%d\n", value);
147134 }
148135
149
-static ssize_t ltc4261_show_bool(struct device *dev,
136
+static ssize_t ltc4261_bool_show(struct device *dev,
150137 struct device_attribute *da, char *buf)
151138 {
152139 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
....@@ -166,10 +153,8 @@
166153 /*
167154 * Input voltages.
168155 */
169
-static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc4261_show_value, NULL,
170
- LTC4261_ADIN_H);
171
-static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc4261_show_value, NULL,
172
- LTC4261_ADIN2_H);
156
+static SENSOR_DEVICE_ATTR_RO(in1_input, ltc4261_value, LTC4261_ADIN_H);
157
+static SENSOR_DEVICE_ATTR_RO(in2_input, ltc4261_value, LTC4261_ADIN2_H);
173158
174159 /*
175160 * Voltage alarms. The chip has only one set of voltage alarm status bits,
....@@ -179,22 +164,16 @@
179164 * To ensure that the alarm condition is reported to the user, report it
180165 * with both voltage sensors.
181166 */
182
-static SENSOR_DEVICE_ATTR(in1_min_alarm, S_IRUGO, ltc4261_show_bool, NULL,
183
- FAULT_UV);
184
-static SENSOR_DEVICE_ATTR(in1_max_alarm, S_IRUGO, ltc4261_show_bool, NULL,
185
- FAULT_OV);
186
-static SENSOR_DEVICE_ATTR(in2_min_alarm, S_IRUGO, ltc4261_show_bool, NULL,
187
- FAULT_UV);
188
-static SENSOR_DEVICE_ATTR(in2_max_alarm, S_IRUGO, ltc4261_show_bool, NULL,
189
- FAULT_OV);
167
+static SENSOR_DEVICE_ATTR_RO(in1_min_alarm, ltc4261_bool, FAULT_UV);
168
+static SENSOR_DEVICE_ATTR_RO(in1_max_alarm, ltc4261_bool, FAULT_OV);
169
+static SENSOR_DEVICE_ATTR_RO(in2_min_alarm, ltc4261_bool, FAULT_UV);
170
+static SENSOR_DEVICE_ATTR_RO(in2_max_alarm, ltc4261_bool, FAULT_OV);
190171
191172 /* Currents (via sense resistor) */
192
-static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc4261_show_value, NULL,
193
- LTC4261_SENSE_H);
173
+static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc4261_value, LTC4261_SENSE_H);
194174
195175 /* Overcurrent alarm */
196
-static SENSOR_DEVICE_ATTR(curr1_max_alarm, S_IRUGO, ltc4261_show_bool, NULL,
197
- FAULT_OC);
176
+static SENSOR_DEVICE_ATTR_RO(curr1_max_alarm, ltc4261_bool, FAULT_OC);
198177
199178 static struct attribute *ltc4261_attrs[] = {
200179 &sensor_dev_attr_in1_input.dev_attr.attr,
....@@ -211,8 +190,7 @@
211190 };
212191 ATTRIBUTE_GROUPS(ltc4261);
213192
214
-static int ltc4261_probe(struct i2c_client *client,
215
- const struct i2c_device_id *id)
193
+static int ltc4261_probe(struct i2c_client *client)
216194 {
217195 struct i2c_adapter *adapter = client->adapter;
218196 struct device *dev = &client->dev;
....@@ -255,7 +233,7 @@
255233 .driver = {
256234 .name = "ltc4261",
257235 },
258
- .probe = ltc4261_probe,
236
+ .probe_new = ltc4261_probe,
259237 .id_table = ltc4261_id,
260238 };
261239