.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * adm1025.c |
---|
3 | 4 | * |
---|
.. | .. |
---|
12 | 13 | * resolution of about 0.5% of the nominal value). Temperature values are |
---|
13 | 14 | * reported with a 1 deg resolution and a 3 deg accuracy. Complete |
---|
14 | 15 | * datasheet can be obtained from Analog's website at: |
---|
15 | | - * http://www.onsemi.com/PowerSolutions/product.do?id=ADM1025 |
---|
| 16 | + * https://www.onsemi.com/PowerSolutions/product.do?id=ADM1025 |
---|
16 | 17 | * |
---|
17 | 18 | * This driver also supports the ADM1025A, which differs from the ADM1025 |
---|
18 | 19 | * only in that it has "open-drain VID inputs while the ADM1025 has |
---|
.. | .. |
---|
29 | 30 | * Since the ADM1025 was the first chipset supported by this driver, most |
---|
30 | 31 | * comments will refer to this chipset, but are actually general and |
---|
31 | 32 | * concern all supported chipsets, unless mentioned otherwise. |
---|
32 | | - * |
---|
33 | | - * This program is free software; you can redistribute it and/or modify |
---|
34 | | - * it under the terms of the GNU General Public License as published by |
---|
35 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
36 | | - * (at your option) any later version. |
---|
37 | | - * |
---|
38 | | - * This program is distributed in the hope that it will be useful, |
---|
39 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
40 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
41 | | - * GNU General Public License for more details. |
---|
42 | | - * |
---|
43 | | - * You should have received a copy of the GNU General Public License |
---|
44 | | - * along with this program; if not, write to the Free Software |
---|
45 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
46 | 33 | */ |
---|
47 | 34 | |
---|
48 | 35 | #include <linux/module.h> |
---|
.. | .. |
---|
174 | 161 | */ |
---|
175 | 162 | |
---|
176 | 163 | static ssize_t |
---|
177 | | -show_in(struct device *dev, struct device_attribute *attr, char *buf) |
---|
| 164 | +in_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
178 | 165 | { |
---|
179 | 166 | int index = to_sensor_dev_attr(attr)->index; |
---|
180 | 167 | struct adm1025_data *data = adm1025_update_device(dev); |
---|
.. | .. |
---|
183 | 170 | } |
---|
184 | 171 | |
---|
185 | 172 | static ssize_t |
---|
186 | | -show_in_min(struct device *dev, struct device_attribute *attr, char *buf) |
---|
| 173 | +in_min_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
187 | 174 | { |
---|
188 | 175 | int index = to_sensor_dev_attr(attr)->index; |
---|
189 | 176 | struct adm1025_data *data = adm1025_update_device(dev); |
---|
.. | .. |
---|
192 | 179 | } |
---|
193 | 180 | |
---|
194 | 181 | static ssize_t |
---|
195 | | -show_in_max(struct device *dev, struct device_attribute *attr, char *buf) |
---|
| 182 | +in_max_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
196 | 183 | { |
---|
197 | 184 | int index = to_sensor_dev_attr(attr)->index; |
---|
198 | 185 | struct adm1025_data *data = adm1025_update_device(dev); |
---|
.. | .. |
---|
201 | 188 | } |
---|
202 | 189 | |
---|
203 | 190 | static ssize_t |
---|
204 | | -show_temp(struct device *dev, struct device_attribute *attr, char *buf) |
---|
| 191 | +temp_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
205 | 192 | { |
---|
206 | 193 | int index = to_sensor_dev_attr(attr)->index; |
---|
207 | 194 | struct adm1025_data *data = adm1025_update_device(dev); |
---|
.. | .. |
---|
209 | 196 | } |
---|
210 | 197 | |
---|
211 | 198 | static ssize_t |
---|
212 | | -show_temp_min(struct device *dev, struct device_attribute *attr, char *buf) |
---|
| 199 | +temp_min_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
213 | 200 | { |
---|
214 | 201 | int index = to_sensor_dev_attr(attr)->index; |
---|
215 | 202 | struct adm1025_data *data = adm1025_update_device(dev); |
---|
.. | .. |
---|
217 | 204 | } |
---|
218 | 205 | |
---|
219 | 206 | static ssize_t |
---|
220 | | -show_temp_max(struct device *dev, struct device_attribute *attr, char *buf) |
---|
| 207 | +temp_max_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
221 | 208 | { |
---|
222 | 209 | int index = to_sensor_dev_attr(attr)->index; |
---|
223 | 210 | struct adm1025_data *data = adm1025_update_device(dev); |
---|
224 | 211 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[index])); |
---|
225 | 212 | } |
---|
226 | 213 | |
---|
227 | | -static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, |
---|
228 | | - const char *buf, size_t count) |
---|
| 214 | +static ssize_t in_min_store(struct device *dev, struct device_attribute *attr, |
---|
| 215 | + const char *buf, size_t count) |
---|
229 | 216 | { |
---|
230 | 217 | int index = to_sensor_dev_attr(attr)->index; |
---|
231 | 218 | struct adm1025_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
245 | 232 | return count; |
---|
246 | 233 | } |
---|
247 | 234 | |
---|
248 | | -static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
---|
249 | | - const char *buf, size_t count) |
---|
| 235 | +static ssize_t in_max_store(struct device *dev, struct device_attribute *attr, |
---|
| 236 | + const char *buf, size_t count) |
---|
250 | 237 | { |
---|
251 | 238 | int index = to_sensor_dev_attr(attr)->index; |
---|
252 | 239 | struct adm1025_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
266 | 253 | return count; |
---|
267 | 254 | } |
---|
268 | 255 | |
---|
269 | | -#define set_in(offset) \ |
---|
270 | | -static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ |
---|
271 | | - show_in, NULL, offset); \ |
---|
272 | | -static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \ |
---|
273 | | - show_in_min, set_in_min, offset); \ |
---|
274 | | -static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \ |
---|
275 | | - show_in_max, set_in_max, offset) |
---|
276 | | -set_in(0); |
---|
277 | | -set_in(1); |
---|
278 | | -set_in(2); |
---|
279 | | -set_in(3); |
---|
280 | | -set_in(4); |
---|
281 | | -set_in(5); |
---|
| 256 | +static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0); |
---|
| 257 | +static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0); |
---|
| 258 | +static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0); |
---|
| 259 | +static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1); |
---|
| 260 | +static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1); |
---|
| 261 | +static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1); |
---|
| 262 | +static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2); |
---|
| 263 | +static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2); |
---|
| 264 | +static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2); |
---|
| 265 | +static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3); |
---|
| 266 | +static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3); |
---|
| 267 | +static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3); |
---|
| 268 | +static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4); |
---|
| 269 | +static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4); |
---|
| 270 | +static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4); |
---|
| 271 | +static SENSOR_DEVICE_ATTR_RO(in5_input, in, 5); |
---|
| 272 | +static SENSOR_DEVICE_ATTR_RW(in5_min, in_min, 5); |
---|
| 273 | +static SENSOR_DEVICE_ATTR_RW(in5_max, in_max, 5); |
---|
282 | 274 | |
---|
283 | | -static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
---|
284 | | - const char *buf, size_t count) |
---|
| 275 | +static ssize_t temp_min_store(struct device *dev, |
---|
| 276 | + struct device_attribute *attr, const char *buf, |
---|
| 277 | + size_t count) |
---|
285 | 278 | { |
---|
286 | 279 | int index = to_sensor_dev_attr(attr)->index; |
---|
287 | 280 | struct adm1025_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
301 | 294 | return count; |
---|
302 | 295 | } |
---|
303 | 296 | |
---|
304 | | -static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, |
---|
305 | | - const char *buf, size_t count) |
---|
| 297 | +static ssize_t temp_max_store(struct device *dev, |
---|
| 298 | + struct device_attribute *attr, const char *buf, |
---|
| 299 | + size_t count) |
---|
306 | 300 | { |
---|
307 | 301 | int index = to_sensor_dev_attr(attr)->index; |
---|
308 | 302 | struct adm1025_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
322 | 316 | return count; |
---|
323 | 317 | } |
---|
324 | 318 | |
---|
325 | | -#define set_temp(offset) \ |
---|
326 | | -static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ |
---|
327 | | - show_temp, NULL, offset - 1); \ |
---|
328 | | -static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \ |
---|
329 | | - show_temp_min, set_temp_min, offset - 1); \ |
---|
330 | | -static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \ |
---|
331 | | - show_temp_max, set_temp_max, offset - 1) |
---|
332 | | -set_temp(1); |
---|
333 | | -set_temp(2); |
---|
| 319 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); |
---|
| 320 | +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); |
---|
| 321 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); |
---|
| 322 | +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); |
---|
| 323 | +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); |
---|
| 324 | +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); |
---|
334 | 325 | |
---|
335 | 326 | static ssize_t |
---|
336 | 327 | alarms_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
.. | .. |
---|
341 | 332 | static DEVICE_ATTR_RO(alarms); |
---|
342 | 333 | |
---|
343 | 334 | static ssize_t |
---|
344 | | -show_alarm(struct device *dev, struct device_attribute *attr, char *buf) |
---|
| 335 | +alarm_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
345 | 336 | { |
---|
346 | 337 | int bitnr = to_sensor_dev_attr(attr)->index; |
---|
347 | 338 | struct adm1025_data *data = adm1025_update_device(dev); |
---|
348 | 339 | return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); |
---|
349 | 340 | } |
---|
350 | | -static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); |
---|
351 | | -static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); |
---|
352 | | -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); |
---|
353 | | -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); |
---|
354 | | -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); |
---|
355 | | -static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 9); |
---|
356 | | -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 5); |
---|
357 | | -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 4); |
---|
358 | | -static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_alarm, NULL, 14); |
---|
| 341 | +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0); |
---|
| 342 | +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1); |
---|
| 343 | +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2); |
---|
| 344 | +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3); |
---|
| 345 | +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 8); |
---|
| 346 | +static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 9); |
---|
| 347 | +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 5); |
---|
| 348 | +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 4); |
---|
| 349 | +static SENSOR_DEVICE_ATTR_RO(temp1_fault, alarm, 14); |
---|
359 | 350 | |
---|
360 | 351 | static ssize_t |
---|
361 | 352 | cpu0_vid_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
.. | .. |
---|
526 | 517 | (reg&0x7E)|0x01); |
---|
527 | 518 | } |
---|
528 | 519 | |
---|
529 | | -static int adm1025_probe(struct i2c_client *client, |
---|
530 | | - const struct i2c_device_id *id) |
---|
| 520 | +static int adm1025_probe(struct i2c_client *client) |
---|
531 | 521 | { |
---|
532 | 522 | struct device *dev = &client->dev; |
---|
533 | 523 | struct device *hwmon_dev; |
---|
.. | .. |
---|
569 | 559 | .driver = { |
---|
570 | 560 | .name = "adm1025", |
---|
571 | 561 | }, |
---|
572 | | - .probe = adm1025_probe, |
---|
| 562 | + .probe_new = adm1025_probe, |
---|
573 | 563 | .id_table = adm1025_id, |
---|
574 | 564 | .detect = adm1025_detect, |
---|
575 | 565 | .address_list = normal_i2c, |
---|