hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/hwmon/ltc4222.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for Linear Technology LTC4222 Dual Hot Swap controller
34 *
45 * Copyright (c) 2014 Guenter Roeck
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
156 */
167
178 #include <linux/kernel.h>
....@@ -94,7 +85,7 @@
9485 return val;
9586 }
9687
97
-static ssize_t ltc4222_show_value(struct device *dev,
88
+static ssize_t ltc4222_value_show(struct device *dev,
9889 struct device_attribute *da, char *buf)
9990 {
10091 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
....@@ -106,7 +97,7 @@
10697 return snprintf(buf, PAGE_SIZE, "%d\n", value);
10798 }
10899
109
-static ssize_t ltc4222_show_bool(struct device *dev,
100
+static ssize_t ltc4222_bool_show(struct device *dev,
110101 struct device_attribute *da, char *buf)
111102 {
112103 struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(da);
....@@ -125,45 +116,39 @@
125116 }
126117
127118 /* Voltages */
128
-static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc4222_show_value, NULL,
129
- LTC4222_SOURCE1);
130
-static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc4222_show_value, NULL,
131
- LTC4222_ADIN1);
132
-static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, ltc4222_show_value, NULL,
133
- LTC4222_SOURCE2);
134
-static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, ltc4222_show_value, NULL,
135
- LTC4222_ADIN2);
119
+static SENSOR_DEVICE_ATTR_RO(in1_input, ltc4222_value, LTC4222_SOURCE1);
120
+static SENSOR_DEVICE_ATTR_RO(in2_input, ltc4222_value, LTC4222_ADIN1);
121
+static SENSOR_DEVICE_ATTR_RO(in3_input, ltc4222_value, LTC4222_SOURCE2);
122
+static SENSOR_DEVICE_ATTR_RO(in4_input, ltc4222_value, LTC4222_ADIN2);
136123
137124 /*
138125 * Voltage alarms
139126 * UV/OV faults are associated with the input voltage, and power bad and fet
140127 * faults are associated with the output voltage.
141128 */
142
-static SENSOR_DEVICE_ATTR_2(in1_min_alarm, S_IRUGO, ltc4222_show_bool, NULL,
143
- LTC4222_FAULT1, FAULT_UV);
144
-static SENSOR_DEVICE_ATTR_2(in1_max_alarm, S_IRUGO, ltc4222_show_bool, NULL,
145
- LTC4222_FAULT1, FAULT_OV);
146
-static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, ltc4222_show_bool, NULL,
147
- LTC4222_FAULT1, FAULT_POWER_BAD | FAULT_FET_BAD);
129
+static SENSOR_DEVICE_ATTR_2_RO(in1_min_alarm, ltc4222_bool, LTC4222_FAULT1,
130
+ FAULT_UV);
131
+static SENSOR_DEVICE_ATTR_2_RO(in1_max_alarm, ltc4222_bool, LTC4222_FAULT1,
132
+ FAULT_OV);
133
+static SENSOR_DEVICE_ATTR_2_RO(in2_alarm, ltc4222_bool, LTC4222_FAULT1,
134
+ FAULT_POWER_BAD | FAULT_FET_BAD);
148135
149
-static SENSOR_DEVICE_ATTR_2(in3_min_alarm, S_IRUGO, ltc4222_show_bool, NULL,
150
- LTC4222_FAULT2, FAULT_UV);
151
-static SENSOR_DEVICE_ATTR_2(in3_max_alarm, S_IRUGO, ltc4222_show_bool, NULL,
152
- LTC4222_FAULT2, FAULT_OV);
153
-static SENSOR_DEVICE_ATTR_2(in4_alarm, S_IRUGO, ltc4222_show_bool, NULL,
154
- LTC4222_FAULT2, FAULT_POWER_BAD | FAULT_FET_BAD);
136
+static SENSOR_DEVICE_ATTR_2_RO(in3_min_alarm, ltc4222_bool, LTC4222_FAULT2,
137
+ FAULT_UV);
138
+static SENSOR_DEVICE_ATTR_2_RO(in3_max_alarm, ltc4222_bool, LTC4222_FAULT2,
139
+ FAULT_OV);
140
+static SENSOR_DEVICE_ATTR_2_RO(in4_alarm, ltc4222_bool, LTC4222_FAULT2,
141
+ FAULT_POWER_BAD | FAULT_FET_BAD);
155142
156143 /* Current (via sense resistor) */
157
-static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc4222_show_value, NULL,
158
- LTC4222_SENSE1);
159
-static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, ltc4222_show_value, NULL,
160
- LTC4222_SENSE2);
144
+static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc4222_value, LTC4222_SENSE1);
145
+static SENSOR_DEVICE_ATTR_RO(curr2_input, ltc4222_value, LTC4222_SENSE2);
161146
162147 /* Overcurrent alarm */
163
-static SENSOR_DEVICE_ATTR_2(curr1_max_alarm, S_IRUGO, ltc4222_show_bool, NULL,
164
- LTC4222_FAULT1, FAULT_OC);
165
-static SENSOR_DEVICE_ATTR_2(curr2_max_alarm, S_IRUGO, ltc4222_show_bool, NULL,
166
- LTC4222_FAULT2, FAULT_OC);
148
+static SENSOR_DEVICE_ATTR_2_RO(curr1_max_alarm, ltc4222_bool, LTC4222_FAULT1,
149
+ FAULT_OC);
150
+static SENSOR_DEVICE_ATTR_2_RO(curr2_max_alarm, ltc4222_bool, LTC4222_FAULT2,
151
+ FAULT_OC);
167152
168153 static struct attribute *ltc4222_attrs[] = {
169154 &sensor_dev_attr_in1_input.dev_attr.attr,
....@@ -192,8 +177,7 @@
192177 .max_register = LTC4222_ADC_CONTROL,
193178 };
194179
195
-static int ltc4222_probe(struct i2c_client *client,
196
- const struct i2c_device_id *id)
180
+static int ltc4222_probe(struct i2c_client *client)
197181 {
198182 struct device *dev = &client->dev;
199183 struct device *hwmon_dev;
....@@ -226,7 +210,7 @@
226210 .driver = {
227211 .name = "ltc4222",
228212 },
229
- .probe = ltc4222_probe,
213
+ .probe_new = ltc4222_probe,
230214 .id_table = ltc4222_id,
231215 };
232216