forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/hwmon/ltc4260.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Driver for Linear Technology LTC4260 I2C Positive Voltage 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>
....@@ -79,7 +70,7 @@
7970 return val;
8071 }
8172
82
-static ssize_t ltc4260_show_value(struct device *dev,
73
+static ssize_t ltc4260_value_show(struct device *dev,
8374 struct device_attribute *da, char *buf)
8475 {
8576 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
....@@ -91,7 +82,7 @@
9182 return snprintf(buf, PAGE_SIZE, "%d\n", value);
9283 }
9384
94
-static ssize_t ltc4260_show_bool(struct device *dev,
85
+static ssize_t ltc4260_bool_show(struct device *dev,
9586 struct device_attribute *da, char *buf)
9687 {
9788 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
....@@ -111,30 +102,24 @@
111102 }
112103
113104 /* Voltages */
114
-static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc4260_show_value, NULL,
115
- LTC4260_SOURCE);
116
-static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc4260_show_value, NULL,
117
- LTC4260_ADIN);
105
+static SENSOR_DEVICE_ATTR_RO(in1_input, ltc4260_value, LTC4260_SOURCE);
106
+static SENSOR_DEVICE_ATTR_RO(in2_input, ltc4260_value, LTC4260_ADIN);
118107
119108 /*
120109 * Voltage alarms
121110 * UV/OV faults are associated with the input voltage, and the POWER BAD and
122111 * FET SHORT faults are associated with the output voltage.
123112 */
124
-static SENSOR_DEVICE_ATTR(in1_min_alarm, S_IRUGO, ltc4260_show_bool, NULL,
125
- FAULT_UV);
126
-static SENSOR_DEVICE_ATTR(in1_max_alarm, S_IRUGO, ltc4260_show_bool, NULL,
127
- FAULT_OV);
128
-static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, ltc4260_show_bool, NULL,
129
- FAULT_POWER_BAD | FAULT_FET_SHORT);
113
+static SENSOR_DEVICE_ATTR_RO(in1_min_alarm, ltc4260_bool, FAULT_UV);
114
+static SENSOR_DEVICE_ATTR_RO(in1_max_alarm, ltc4260_bool, FAULT_OV);
115
+static SENSOR_DEVICE_ATTR_RO(in2_alarm, ltc4260_bool,
116
+ FAULT_POWER_BAD | FAULT_FET_SHORT);
130117
131118 /* Current (via sense resistor) */
132
-static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc4260_show_value, NULL,
133
- LTC4260_SENSE);
119
+static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc4260_value, LTC4260_SENSE);
134120
135121 /* Overcurrent alarm */
136
-static SENSOR_DEVICE_ATTR(curr1_max_alarm, S_IRUGO, ltc4260_show_bool, NULL,
137
- FAULT_OC);
122
+static SENSOR_DEVICE_ATTR_RO(curr1_max_alarm, ltc4260_bool, FAULT_OC);
138123
139124 static struct attribute *ltc4260_attrs[] = {
140125 &sensor_dev_attr_in1_input.dev_attr.attr,
....@@ -156,8 +141,7 @@
156141 .max_register = LTC4260_ADIN,
157142 };
158143
159
-static int ltc4260_probe(struct i2c_client *client,
160
- const struct i2c_device_id *id)
144
+static int ltc4260_probe(struct i2c_client *client)
161145 {
162146 struct device *dev = &client->dev;
163147 struct device *hwmon_dev;
....@@ -189,7 +173,7 @@
189173 .driver = {
190174 .name = "ltc4260",
191175 },
192
- .probe = ltc4260_probe,
176
+ .probe_new = ltc4260_probe,
193177 .id_table = ltc4260_id,
194178 };
195179