.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * lm80.c - From lm_sensors, Linux kernel modules for hardware |
---|
3 | 4 | * monitoring |
---|
.. | .. |
---|
5 | 6 | * and Philip Edelbrock <phil@netroedge.com> |
---|
6 | 7 | * |
---|
7 | 8 | * Ported to Linux 2.6 by Tiago Sousa <mirage@kaotik.org> |
---|
8 | | - * |
---|
9 | | - * This program is free software; you can redistribute it and/or modify |
---|
10 | | - * it under the terms of the GNU General Public License as published by |
---|
11 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
12 | | - * (at your option) any later version. |
---|
13 | | - * |
---|
14 | | - * This program is distributed in the hope that it will be useful, |
---|
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | | - * GNU General Public License for more details. |
---|
18 | | - * |
---|
19 | | - * You should have received a copy of the GNU General Public License |
---|
20 | | - * along with this program; if not, write to the Free Software |
---|
21 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
22 | 9 | */ |
---|
23 | 10 | |
---|
24 | 11 | #include <linux/module.h> |
---|
.. | .. |
---|
269 | 256 | * Sysfs stuff |
---|
270 | 257 | */ |
---|
271 | 258 | |
---|
272 | | -static ssize_t show_in(struct device *dev, struct device_attribute *attr, |
---|
| 259 | +static ssize_t in_show(struct device *dev, struct device_attribute *attr, |
---|
273 | 260 | char *buf) |
---|
274 | 261 | { |
---|
275 | 262 | struct lm80_data *data = lm80_update_device(dev); |
---|
.. | .. |
---|
281 | 268 | return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr][index])); |
---|
282 | 269 | } |
---|
283 | 270 | |
---|
284 | | -static ssize_t set_in(struct device *dev, struct device_attribute *attr, |
---|
285 | | - const char *buf, size_t count) |
---|
| 271 | +static ssize_t in_store(struct device *dev, struct device_attribute *attr, |
---|
| 272 | + const char *buf, size_t count) |
---|
286 | 273 | { |
---|
287 | 274 | struct lm80_data *data = dev_get_drvdata(dev); |
---|
288 | 275 | struct i2c_client *client = data->client; |
---|
.. | .. |
---|
303 | 290 | return count; |
---|
304 | 291 | } |
---|
305 | 292 | |
---|
306 | | -static ssize_t show_fan(struct device *dev, struct device_attribute *attr, |
---|
| 293 | +static ssize_t fan_show(struct device *dev, struct device_attribute *attr, |
---|
307 | 294 | char *buf) |
---|
308 | 295 | { |
---|
309 | 296 | int index = to_sensor_dev_attr_2(attr)->index; |
---|
.. | .. |
---|
315 | 302 | DIV_FROM_REG(data->fan_div[index]))); |
---|
316 | 303 | } |
---|
317 | 304 | |
---|
318 | | -static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr, |
---|
319 | | - char *buf) |
---|
| 305 | +static ssize_t fan_div_show(struct device *dev, struct device_attribute *attr, |
---|
| 306 | + char *buf) |
---|
320 | 307 | { |
---|
321 | 308 | int nr = to_sensor_dev_attr(attr)->index; |
---|
322 | 309 | struct lm80_data *data = lm80_update_device(dev); |
---|
.. | .. |
---|
325 | 312 | return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); |
---|
326 | 313 | } |
---|
327 | 314 | |
---|
328 | | -static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, |
---|
329 | | - const char *buf, size_t count) |
---|
| 315 | +static ssize_t fan_store(struct device *dev, struct device_attribute *attr, |
---|
| 316 | + const char *buf, size_t count) |
---|
330 | 317 | { |
---|
331 | 318 | int index = to_sensor_dev_attr_2(attr)->index; |
---|
332 | 319 | int nr = to_sensor_dev_attr_2(attr)->nr; |
---|
.. | .. |
---|
352 | 339 | * least surprise; the user doesn't expect the fan minimum to change just |
---|
353 | 340 | * because the divisor changed. |
---|
354 | 341 | */ |
---|
355 | | -static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, |
---|
356 | | - const char *buf, size_t count) |
---|
| 342 | +static ssize_t fan_div_store(struct device *dev, |
---|
| 343 | + struct device_attribute *attr, const char *buf, |
---|
| 344 | + size_t count) |
---|
357 | 345 | { |
---|
358 | 346 | int nr = to_sensor_dev_attr(attr)->index; |
---|
359 | 347 | struct lm80_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
410 | 398 | return count; |
---|
411 | 399 | } |
---|
412 | 400 | |
---|
413 | | -static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
---|
| 401 | +static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, |
---|
414 | 402 | char *buf) |
---|
415 | 403 | { |
---|
416 | 404 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
420 | 408 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); |
---|
421 | 409 | } |
---|
422 | 410 | |
---|
423 | | -static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, |
---|
424 | | - const char *buf, size_t count) |
---|
| 411 | +static ssize_t temp_store(struct device *dev, |
---|
| 412 | + struct device_attribute *devattr, const char *buf, |
---|
| 413 | + size_t count) |
---|
425 | 414 | { |
---|
426 | 415 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
427 | 416 | struct lm80_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
448 | 437 | return sprintf(buf, "%u\n", data->alarms); |
---|
449 | 438 | } |
---|
450 | 439 | |
---|
451 | | -static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, |
---|
| 440 | +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, |
---|
452 | 441 | char *buf) |
---|
453 | 442 | { |
---|
454 | 443 | int bitnr = to_sensor_dev_attr(attr)->index; |
---|
.. | .. |
---|
458 | 447 | return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); |
---|
459 | 448 | } |
---|
460 | 449 | |
---|
461 | | -static SENSOR_DEVICE_ATTR_2(in0_min, S_IWUSR | S_IRUGO, |
---|
462 | | - show_in, set_in, i_min, 0); |
---|
463 | | -static SENSOR_DEVICE_ATTR_2(in1_min, S_IWUSR | S_IRUGO, |
---|
464 | | - show_in, set_in, i_min, 1); |
---|
465 | | -static SENSOR_DEVICE_ATTR_2(in2_min, S_IWUSR | S_IRUGO, |
---|
466 | | - show_in, set_in, i_min, 2); |
---|
467 | | -static SENSOR_DEVICE_ATTR_2(in3_min, S_IWUSR | S_IRUGO, |
---|
468 | | - show_in, set_in, i_min, 3); |
---|
469 | | -static SENSOR_DEVICE_ATTR_2(in4_min, S_IWUSR | S_IRUGO, |
---|
470 | | - show_in, set_in, i_min, 4); |
---|
471 | | -static SENSOR_DEVICE_ATTR_2(in5_min, S_IWUSR | S_IRUGO, |
---|
472 | | - show_in, set_in, i_min, 5); |
---|
473 | | -static SENSOR_DEVICE_ATTR_2(in6_min, S_IWUSR | S_IRUGO, |
---|
474 | | - show_in, set_in, i_min, 6); |
---|
475 | | -static SENSOR_DEVICE_ATTR_2(in0_max, S_IWUSR | S_IRUGO, |
---|
476 | | - show_in, set_in, i_max, 0); |
---|
477 | | -static SENSOR_DEVICE_ATTR_2(in1_max, S_IWUSR | S_IRUGO, |
---|
478 | | - show_in, set_in, i_max, 1); |
---|
479 | | -static SENSOR_DEVICE_ATTR_2(in2_max, S_IWUSR | S_IRUGO, |
---|
480 | | - show_in, set_in, i_max, 2); |
---|
481 | | -static SENSOR_DEVICE_ATTR_2(in3_max, S_IWUSR | S_IRUGO, |
---|
482 | | - show_in, set_in, i_max, 3); |
---|
483 | | -static SENSOR_DEVICE_ATTR_2(in4_max, S_IWUSR | S_IRUGO, |
---|
484 | | - show_in, set_in, i_max, 4); |
---|
485 | | -static SENSOR_DEVICE_ATTR_2(in5_max, S_IWUSR | S_IRUGO, |
---|
486 | | - show_in, set_in, i_max, 5); |
---|
487 | | -static SENSOR_DEVICE_ATTR_2(in6_max, S_IWUSR | S_IRUGO, |
---|
488 | | - show_in, set_in, i_max, 6); |
---|
489 | | -static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, show_in, NULL, i_input, 0); |
---|
490 | | -static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, show_in, NULL, i_input, 1); |
---|
491 | | -static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, show_in, NULL, i_input, 2); |
---|
492 | | -static SENSOR_DEVICE_ATTR_2(in3_input, S_IRUGO, show_in, NULL, i_input, 3); |
---|
493 | | -static SENSOR_DEVICE_ATTR_2(in4_input, S_IRUGO, show_in, NULL, i_input, 4); |
---|
494 | | -static SENSOR_DEVICE_ATTR_2(in5_input, S_IRUGO, show_in, NULL, i_input, 5); |
---|
495 | | -static SENSOR_DEVICE_ATTR_2(in6_input, S_IRUGO, show_in, NULL, i_input, 6); |
---|
496 | | -static SENSOR_DEVICE_ATTR_2(fan1_min, S_IWUSR | S_IRUGO, |
---|
497 | | - show_fan, set_fan_min, f_min, 0); |
---|
498 | | -static SENSOR_DEVICE_ATTR_2(fan2_min, S_IWUSR | S_IRUGO, |
---|
499 | | - show_fan, set_fan_min, f_min, 1); |
---|
500 | | -static SENSOR_DEVICE_ATTR_2(fan1_input, S_IRUGO, show_fan, NULL, f_input, 0); |
---|
501 | | -static SENSOR_DEVICE_ATTR_2(fan2_input, S_IRUGO, show_fan, NULL, f_input, 1); |
---|
502 | | -static SENSOR_DEVICE_ATTR(fan1_div, S_IWUSR | S_IRUGO, |
---|
503 | | - show_fan_div, set_fan_div, 0); |
---|
504 | | -static SENSOR_DEVICE_ATTR(fan2_div, S_IWUSR | S_IRUGO, |
---|
505 | | - show_fan_div, set_fan_div, 1); |
---|
506 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, t_input); |
---|
507 | | -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp, |
---|
508 | | - set_temp, t_hot_max); |
---|
509 | | -static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, show_temp, |
---|
510 | | - set_temp, t_hot_hyst); |
---|
511 | | -static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp, |
---|
512 | | - set_temp, t_os_max); |
---|
513 | | -static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IWUSR | S_IRUGO, show_temp, |
---|
514 | | - set_temp, t_os_hyst); |
---|
| 450 | +static SENSOR_DEVICE_ATTR_2_RW(in0_min, in, i_min, 0); |
---|
| 451 | +static SENSOR_DEVICE_ATTR_2_RW(in1_min, in, i_min, 1); |
---|
| 452 | +static SENSOR_DEVICE_ATTR_2_RW(in2_min, in, i_min, 2); |
---|
| 453 | +static SENSOR_DEVICE_ATTR_2_RW(in3_min, in, i_min, 3); |
---|
| 454 | +static SENSOR_DEVICE_ATTR_2_RW(in4_min, in, i_min, 4); |
---|
| 455 | +static SENSOR_DEVICE_ATTR_2_RW(in5_min, in, i_min, 5); |
---|
| 456 | +static SENSOR_DEVICE_ATTR_2_RW(in6_min, in, i_min, 6); |
---|
| 457 | +static SENSOR_DEVICE_ATTR_2_RW(in0_max, in, i_max, 0); |
---|
| 458 | +static SENSOR_DEVICE_ATTR_2_RW(in1_max, in, i_max, 1); |
---|
| 459 | +static SENSOR_DEVICE_ATTR_2_RW(in2_max, in, i_max, 2); |
---|
| 460 | +static SENSOR_DEVICE_ATTR_2_RW(in3_max, in, i_max, 3); |
---|
| 461 | +static SENSOR_DEVICE_ATTR_2_RW(in4_max, in, i_max, 4); |
---|
| 462 | +static SENSOR_DEVICE_ATTR_2_RW(in5_max, in, i_max, 5); |
---|
| 463 | +static SENSOR_DEVICE_ATTR_2_RW(in6_max, in, i_max, 6); |
---|
| 464 | +static SENSOR_DEVICE_ATTR_2_RO(in0_input, in, i_input, 0); |
---|
| 465 | +static SENSOR_DEVICE_ATTR_2_RO(in1_input, in, i_input, 1); |
---|
| 466 | +static SENSOR_DEVICE_ATTR_2_RO(in2_input, in, i_input, 2); |
---|
| 467 | +static SENSOR_DEVICE_ATTR_2_RO(in3_input, in, i_input, 3); |
---|
| 468 | +static SENSOR_DEVICE_ATTR_2_RO(in4_input, in, i_input, 4); |
---|
| 469 | +static SENSOR_DEVICE_ATTR_2_RO(in5_input, in, i_input, 5); |
---|
| 470 | +static SENSOR_DEVICE_ATTR_2_RO(in6_input, in, i_input, 6); |
---|
| 471 | +static SENSOR_DEVICE_ATTR_2_RW(fan1_min, fan, f_min, 0); |
---|
| 472 | +static SENSOR_DEVICE_ATTR_2_RW(fan2_min, fan, f_min, 1); |
---|
| 473 | +static SENSOR_DEVICE_ATTR_2_RO(fan1_input, fan, f_input, 0); |
---|
| 474 | +static SENSOR_DEVICE_ATTR_2_RO(fan2_input, fan, f_input, 1); |
---|
| 475 | +static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0); |
---|
| 476 | +static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1); |
---|
| 477 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, t_input); |
---|
| 478 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, t_hot_max); |
---|
| 479 | +static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, temp, t_hot_hyst); |
---|
| 480 | +static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp, t_os_max); |
---|
| 481 | +static SENSOR_DEVICE_ATTR_RW(temp1_crit_hyst, temp, t_os_hyst); |
---|
515 | 482 | static DEVICE_ATTR_RO(alarms); |
---|
516 | | -static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); |
---|
517 | | -static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); |
---|
518 | | -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); |
---|
519 | | -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); |
---|
520 | | -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 4); |
---|
521 | | -static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 5); |
---|
522 | | -static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 6); |
---|
523 | | -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 10); |
---|
524 | | -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 11); |
---|
525 | | -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 8); |
---|
526 | | -static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 13); |
---|
| 483 | +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0); |
---|
| 484 | +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1); |
---|
| 485 | +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2); |
---|
| 486 | +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3); |
---|
| 487 | +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 4); |
---|
| 488 | +static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 5); |
---|
| 489 | +static SENSOR_DEVICE_ATTR_RO(in6_alarm, alarm, 6); |
---|
| 490 | +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 10); |
---|
| 491 | +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 11); |
---|
| 492 | +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 8); |
---|
| 493 | +static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 13); |
---|
527 | 494 | |
---|
528 | 495 | /* |
---|
529 | 496 | * Real code |
---|
.. | .. |
---|
624 | 591 | return 0; |
---|
625 | 592 | } |
---|
626 | 593 | |
---|
627 | | -static int lm80_probe(struct i2c_client *client, |
---|
628 | | - const struct i2c_device_id *id) |
---|
| 594 | +static int lm80_probe(struct i2c_client *client) |
---|
629 | 595 | { |
---|
630 | 596 | struct device *dev = &client->dev; |
---|
631 | 597 | struct device *hwmon_dev; |
---|
.. | .. |
---|
667 | 633 | .driver = { |
---|
668 | 634 | .name = "lm80", |
---|
669 | 635 | }, |
---|
670 | | - .probe = lm80_probe, |
---|
| 636 | + .probe_new = lm80_probe, |
---|
671 | 637 | .id_table = lm80_id, |
---|
672 | 638 | .detect = lm80_detect, |
---|
673 | 639 | .address_list = normal_i2c, |
---|