.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * adm1031.c - Part of lm_sensors, Linux kernel modules for hardware |
---|
3 | 4 | * monitoring |
---|
.. | .. |
---|
5 | 6 | * Supports adm1030 / adm1031 |
---|
6 | 7 | * Copyright (C) 2004 Alexandre d'Alton <alex@alexdalton.org> |
---|
7 | 8 | * Reworked by Jean Delvare <jdelvare@suse.de> |
---|
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> |
---|
.. | .. |
---|
331 | 318 | return -EINVAL; |
---|
332 | 319 | } |
---|
333 | 320 | |
---|
334 | | -static ssize_t show_fan_auto_channel(struct device *dev, |
---|
| 321 | +static ssize_t fan_auto_channel_show(struct device *dev, |
---|
335 | 322 | struct device_attribute *attr, char *buf) |
---|
336 | 323 | { |
---|
337 | 324 | int nr = to_sensor_dev_attr(attr)->index; |
---|
.. | .. |
---|
340 | 327 | } |
---|
341 | 328 | |
---|
342 | 329 | static ssize_t |
---|
343 | | -set_fan_auto_channel(struct device *dev, struct device_attribute *attr, |
---|
344 | | - const char *buf, size_t count) |
---|
| 330 | +fan_auto_channel_store(struct device *dev, struct device_attribute *attr, |
---|
| 331 | + const char *buf, size_t count) |
---|
345 | 332 | { |
---|
346 | 333 | struct adm1031_data *data = dev_get_drvdata(dev); |
---|
347 | 334 | struct i2c_client *client = data->client; |
---|
.. | .. |
---|
392 | 379 | return count; |
---|
393 | 380 | } |
---|
394 | 381 | |
---|
395 | | -static SENSOR_DEVICE_ATTR(auto_fan1_channel, S_IRUGO | S_IWUSR, |
---|
396 | | - show_fan_auto_channel, set_fan_auto_channel, 0); |
---|
397 | | -static SENSOR_DEVICE_ATTR(auto_fan2_channel, S_IRUGO | S_IWUSR, |
---|
398 | | - show_fan_auto_channel, set_fan_auto_channel, 1); |
---|
| 382 | +static SENSOR_DEVICE_ATTR_RW(auto_fan1_channel, fan_auto_channel, 0); |
---|
| 383 | +static SENSOR_DEVICE_ATTR_RW(auto_fan2_channel, fan_auto_channel, 1); |
---|
399 | 384 | |
---|
400 | 385 | /* Auto Temps */ |
---|
401 | | -static ssize_t show_auto_temp_off(struct device *dev, |
---|
| 386 | +static ssize_t auto_temp_off_show(struct device *dev, |
---|
402 | 387 | struct device_attribute *attr, char *buf) |
---|
403 | 388 | { |
---|
404 | 389 | int nr = to_sensor_dev_attr(attr)->index; |
---|
.. | .. |
---|
406 | 391 | return sprintf(buf, "%d\n", |
---|
407 | 392 | AUTO_TEMP_OFF_FROM_REG(data->auto_temp[nr])); |
---|
408 | 393 | } |
---|
409 | | -static ssize_t show_auto_temp_min(struct device *dev, |
---|
| 394 | +static ssize_t auto_temp_min_show(struct device *dev, |
---|
410 | 395 | struct device_attribute *attr, char *buf) |
---|
411 | 396 | { |
---|
412 | 397 | int nr = to_sensor_dev_attr(attr)->index; |
---|
.. | .. |
---|
415 | 400 | AUTO_TEMP_MIN_FROM_REG(data->auto_temp[nr])); |
---|
416 | 401 | } |
---|
417 | 402 | static ssize_t |
---|
418 | | -set_auto_temp_min(struct device *dev, struct device_attribute *attr, |
---|
419 | | - const char *buf, size_t count) |
---|
| 403 | +auto_temp_min_store(struct device *dev, struct device_attribute *attr, |
---|
| 404 | + const char *buf, size_t count) |
---|
420 | 405 | { |
---|
421 | 406 | struct adm1031_data *data = dev_get_drvdata(dev); |
---|
422 | 407 | struct i2c_client *client = data->client; |
---|
.. | .. |
---|
436 | 421 | mutex_unlock(&data->update_lock); |
---|
437 | 422 | return count; |
---|
438 | 423 | } |
---|
439 | | -static ssize_t show_auto_temp_max(struct device *dev, |
---|
| 424 | +static ssize_t auto_temp_max_show(struct device *dev, |
---|
440 | 425 | struct device_attribute *attr, char *buf) |
---|
441 | 426 | { |
---|
442 | 427 | int nr = to_sensor_dev_attr(attr)->index; |
---|
.. | .. |
---|
445 | 430 | AUTO_TEMP_MAX_FROM_REG(data->auto_temp[nr])); |
---|
446 | 431 | } |
---|
447 | 432 | static ssize_t |
---|
448 | | -set_auto_temp_max(struct device *dev, struct device_attribute *attr, |
---|
449 | | - const char *buf, size_t count) |
---|
| 433 | +auto_temp_max_store(struct device *dev, struct device_attribute *attr, |
---|
| 434 | + const char *buf, size_t count) |
---|
450 | 435 | { |
---|
451 | 436 | struct adm1031_data *data = dev_get_drvdata(dev); |
---|
452 | 437 | struct i2c_client *client = data->client; |
---|
.. | .. |
---|
468 | 453 | return count; |
---|
469 | 454 | } |
---|
470 | 455 | |
---|
471 | | -#define auto_temp_reg(offset) \ |
---|
472 | | -static SENSOR_DEVICE_ATTR(auto_temp##offset##_off, S_IRUGO, \ |
---|
473 | | - show_auto_temp_off, NULL, offset - 1); \ |
---|
474 | | -static SENSOR_DEVICE_ATTR(auto_temp##offset##_min, S_IRUGO | S_IWUSR, \ |
---|
475 | | - show_auto_temp_min, set_auto_temp_min, offset - 1); \ |
---|
476 | | -static SENSOR_DEVICE_ATTR(auto_temp##offset##_max, S_IRUGO | S_IWUSR, \ |
---|
477 | | - show_auto_temp_max, set_auto_temp_max, offset - 1) |
---|
478 | | - |
---|
479 | | -auto_temp_reg(1); |
---|
480 | | -auto_temp_reg(2); |
---|
481 | | -auto_temp_reg(3); |
---|
| 456 | +static SENSOR_DEVICE_ATTR_RO(auto_temp1_off, auto_temp_off, 0); |
---|
| 457 | +static SENSOR_DEVICE_ATTR_RW(auto_temp1_min, auto_temp_min, 0); |
---|
| 458 | +static SENSOR_DEVICE_ATTR_RW(auto_temp1_max, auto_temp_max, 0); |
---|
| 459 | +static SENSOR_DEVICE_ATTR_RO(auto_temp2_off, auto_temp_off, 1); |
---|
| 460 | +static SENSOR_DEVICE_ATTR_RW(auto_temp2_min, auto_temp_min, 1); |
---|
| 461 | +static SENSOR_DEVICE_ATTR_RW(auto_temp2_max, auto_temp_max, 1); |
---|
| 462 | +static SENSOR_DEVICE_ATTR_RO(auto_temp3_off, auto_temp_off, 2); |
---|
| 463 | +static SENSOR_DEVICE_ATTR_RW(auto_temp3_min, auto_temp_min, 2); |
---|
| 464 | +static SENSOR_DEVICE_ATTR_RW(auto_temp3_max, auto_temp_max, 2); |
---|
482 | 465 | |
---|
483 | 466 | /* pwm */ |
---|
484 | | -static ssize_t show_pwm(struct device *dev, |
---|
485 | | - struct device_attribute *attr, char *buf) |
---|
| 467 | +static ssize_t pwm_show(struct device *dev, struct device_attribute *attr, |
---|
| 468 | + char *buf) |
---|
486 | 469 | { |
---|
487 | 470 | int nr = to_sensor_dev_attr(attr)->index; |
---|
488 | 471 | struct adm1031_data *data = adm1031_update_device(dev); |
---|
489 | 472 | return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[nr])); |
---|
490 | 473 | } |
---|
491 | | -static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, |
---|
492 | | - const char *buf, size_t count) |
---|
| 474 | +static ssize_t pwm_store(struct device *dev, struct device_attribute *attr, |
---|
| 475 | + const char *buf, size_t count) |
---|
493 | 476 | { |
---|
494 | 477 | struct adm1031_data *data = dev_get_drvdata(dev); |
---|
495 | 478 | struct i2c_client *client = data->client; |
---|
.. | .. |
---|
517 | 500 | return count; |
---|
518 | 501 | } |
---|
519 | 502 | |
---|
520 | | -static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm, set_pwm, 0); |
---|
521 | | -static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, show_pwm, set_pwm, 1); |
---|
522 | | -static SENSOR_DEVICE_ATTR(auto_fan1_min_pwm, S_IRUGO | S_IWUSR, |
---|
523 | | - show_pwm, set_pwm, 0); |
---|
524 | | -static SENSOR_DEVICE_ATTR(auto_fan2_min_pwm, S_IRUGO | S_IWUSR, |
---|
525 | | - show_pwm, set_pwm, 1); |
---|
| 503 | +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); |
---|
| 504 | +static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1); |
---|
| 505 | +static SENSOR_DEVICE_ATTR_RW(auto_fan1_min_pwm, pwm, 0); |
---|
| 506 | +static SENSOR_DEVICE_ATTR_RW(auto_fan2_min_pwm, pwm, 1); |
---|
526 | 507 | |
---|
527 | 508 | /* Fans */ |
---|
528 | 509 | |
---|
.. | .. |
---|
572 | 553 | return res; |
---|
573 | 554 | } |
---|
574 | 555 | |
---|
575 | | - |
---|
576 | | -static ssize_t show_fan(struct device *dev, |
---|
577 | | - struct device_attribute *attr, char *buf) |
---|
| 556 | +static ssize_t fan_show(struct device *dev, struct device_attribute *attr, |
---|
| 557 | + char *buf) |
---|
578 | 558 | { |
---|
579 | 559 | int nr = to_sensor_dev_attr(attr)->index; |
---|
580 | 560 | struct adm1031_data *data = adm1031_update_device(dev); |
---|
.. | .. |
---|
585 | 565 | return sprintf(buf, "%d\n", value); |
---|
586 | 566 | } |
---|
587 | 567 | |
---|
588 | | -static ssize_t show_fan_div(struct device *dev, |
---|
589 | | - struct device_attribute *attr, char *buf) |
---|
| 568 | +static ssize_t fan_div_show(struct device *dev, struct device_attribute *attr, |
---|
| 569 | + char *buf) |
---|
590 | 570 | { |
---|
591 | 571 | int nr = to_sensor_dev_attr(attr)->index; |
---|
592 | 572 | struct adm1031_data *data = adm1031_update_device(dev); |
---|
593 | 573 | return sprintf(buf, "%d\n", FAN_DIV_FROM_REG(data->fan_div[nr])); |
---|
594 | 574 | } |
---|
595 | | -static ssize_t show_fan_min(struct device *dev, |
---|
596 | | - struct device_attribute *attr, char *buf) |
---|
| 575 | +static ssize_t fan_min_show(struct device *dev, struct device_attribute *attr, |
---|
| 576 | + char *buf) |
---|
597 | 577 | { |
---|
598 | 578 | int nr = to_sensor_dev_attr(attr)->index; |
---|
599 | 579 | struct adm1031_data *data = adm1031_update_device(dev); |
---|
.. | .. |
---|
601 | 581 | FAN_FROM_REG(data->fan_min[nr], |
---|
602 | 582 | FAN_DIV_FROM_REG(data->fan_div[nr]))); |
---|
603 | 583 | } |
---|
604 | | -static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, |
---|
605 | | - const char *buf, size_t count) |
---|
| 584 | +static ssize_t fan_min_store(struct device *dev, |
---|
| 585 | + struct device_attribute *attr, const char *buf, |
---|
| 586 | + size_t count) |
---|
606 | 587 | { |
---|
607 | 588 | struct adm1031_data *data = dev_get_drvdata(dev); |
---|
608 | 589 | struct i2c_client *client = data->client; |
---|
.. | .. |
---|
625 | 606 | mutex_unlock(&data->update_lock); |
---|
626 | 607 | return count; |
---|
627 | 608 | } |
---|
628 | | -static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, |
---|
629 | | - const char *buf, size_t count) |
---|
| 609 | +static ssize_t fan_div_store(struct device *dev, |
---|
| 610 | + struct device_attribute *attr, const char *buf, |
---|
| 611 | + size_t count) |
---|
630 | 612 | { |
---|
631 | 613 | struct adm1031_data *data = dev_get_drvdata(dev); |
---|
632 | 614 | struct i2c_client *client = data->client; |
---|
.. | .. |
---|
673 | 655 | return count; |
---|
674 | 656 | } |
---|
675 | 657 | |
---|
676 | | -#define fan_offset(offset) \ |
---|
677 | | -static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ |
---|
678 | | - show_fan, NULL, offset - 1); \ |
---|
679 | | -static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ |
---|
680 | | - show_fan_min, set_fan_min, offset - 1); \ |
---|
681 | | -static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ |
---|
682 | | - show_fan_div, set_fan_div, offset - 1) |
---|
683 | | - |
---|
684 | | -fan_offset(1); |
---|
685 | | -fan_offset(2); |
---|
686 | | - |
---|
| 658 | +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); |
---|
| 659 | +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); |
---|
| 660 | +static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0); |
---|
| 661 | +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); |
---|
| 662 | +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); |
---|
| 663 | +static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1); |
---|
687 | 664 | |
---|
688 | 665 | /* Temps */ |
---|
689 | | -static ssize_t show_temp(struct device *dev, |
---|
690 | | - struct device_attribute *attr, char *buf) |
---|
| 666 | +static ssize_t temp_show(struct device *dev, struct device_attribute *attr, |
---|
| 667 | + char *buf) |
---|
691 | 668 | { |
---|
692 | 669 | int nr = to_sensor_dev_attr(attr)->index; |
---|
693 | 670 | struct adm1031_data *data = adm1031_update_device(dev); |
---|
.. | .. |
---|
697 | 674 | (((data->ext_temp[nr] >> ((nr - 1) * 3)) & 7)); |
---|
698 | 675 | return sprintf(buf, "%d\n", TEMP_FROM_REG_EXT(data->temp[nr], ext)); |
---|
699 | 676 | } |
---|
700 | | -static ssize_t show_temp_offset(struct device *dev, |
---|
| 677 | +static ssize_t temp_offset_show(struct device *dev, |
---|
701 | 678 | struct device_attribute *attr, char *buf) |
---|
702 | 679 | { |
---|
703 | 680 | int nr = to_sensor_dev_attr(attr)->index; |
---|
.. | .. |
---|
705 | 682 | return sprintf(buf, "%d\n", |
---|
706 | 683 | TEMP_OFFSET_FROM_REG(data->temp_offset[nr])); |
---|
707 | 684 | } |
---|
708 | | -static ssize_t show_temp_min(struct device *dev, |
---|
| 685 | +static ssize_t temp_min_show(struct device *dev, |
---|
709 | 686 | struct device_attribute *attr, char *buf) |
---|
710 | 687 | { |
---|
711 | 688 | int nr = to_sensor_dev_attr(attr)->index; |
---|
712 | 689 | struct adm1031_data *data = adm1031_update_device(dev); |
---|
713 | 690 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[nr])); |
---|
714 | 691 | } |
---|
715 | | -static ssize_t show_temp_max(struct device *dev, |
---|
| 692 | +static ssize_t temp_max_show(struct device *dev, |
---|
716 | 693 | struct device_attribute *attr, char *buf) |
---|
717 | 694 | { |
---|
718 | 695 | int nr = to_sensor_dev_attr(attr)->index; |
---|
719 | 696 | struct adm1031_data *data = adm1031_update_device(dev); |
---|
720 | 697 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[nr])); |
---|
721 | 698 | } |
---|
722 | | -static ssize_t show_temp_crit(struct device *dev, |
---|
| 699 | +static ssize_t temp_crit_show(struct device *dev, |
---|
723 | 700 | struct device_attribute *attr, char *buf) |
---|
724 | 701 | { |
---|
725 | 702 | int nr = to_sensor_dev_attr(attr)->index; |
---|
726 | 703 | struct adm1031_data *data = adm1031_update_device(dev); |
---|
727 | 704 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[nr])); |
---|
728 | 705 | } |
---|
729 | | -static ssize_t set_temp_offset(struct device *dev, |
---|
730 | | - struct device_attribute *attr, const char *buf, |
---|
731 | | - size_t count) |
---|
| 706 | +static ssize_t temp_offset_store(struct device *dev, |
---|
| 707 | + struct device_attribute *attr, |
---|
| 708 | + const char *buf, size_t count) |
---|
732 | 709 | { |
---|
733 | 710 | struct adm1031_data *data = dev_get_drvdata(dev); |
---|
734 | 711 | struct i2c_client *client = data->client; |
---|
.. | .. |
---|
748 | 725 | mutex_unlock(&data->update_lock); |
---|
749 | 726 | return count; |
---|
750 | 727 | } |
---|
751 | | -static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
---|
752 | | - const char *buf, size_t count) |
---|
| 728 | +static ssize_t temp_min_store(struct device *dev, |
---|
| 729 | + struct device_attribute *attr, const char *buf, |
---|
| 730 | + size_t count) |
---|
753 | 731 | { |
---|
754 | 732 | struct adm1031_data *data = dev_get_drvdata(dev); |
---|
755 | 733 | struct i2c_client *client = data->client; |
---|
.. | .. |
---|
769 | 747 | mutex_unlock(&data->update_lock); |
---|
770 | 748 | return count; |
---|
771 | 749 | } |
---|
772 | | -static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, |
---|
773 | | - const char *buf, size_t count) |
---|
| 750 | +static ssize_t temp_max_store(struct device *dev, |
---|
| 751 | + struct device_attribute *attr, const char *buf, |
---|
| 752 | + size_t count) |
---|
774 | 753 | { |
---|
775 | 754 | struct adm1031_data *data = dev_get_drvdata(dev); |
---|
776 | 755 | struct i2c_client *client = data->client; |
---|
.. | .. |
---|
790 | 769 | mutex_unlock(&data->update_lock); |
---|
791 | 770 | return count; |
---|
792 | 771 | } |
---|
793 | | -static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, |
---|
794 | | - const char *buf, size_t count) |
---|
| 772 | +static ssize_t temp_crit_store(struct device *dev, |
---|
| 773 | + struct device_attribute *attr, const char *buf, |
---|
| 774 | + size_t count) |
---|
795 | 775 | { |
---|
796 | 776 | struct adm1031_data *data = dev_get_drvdata(dev); |
---|
797 | 777 | struct i2c_client *client = data->client; |
---|
.. | .. |
---|
812 | 792 | return count; |
---|
813 | 793 | } |
---|
814 | 794 | |
---|
815 | | -#define temp_reg(offset) \ |
---|
816 | | -static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ |
---|
817 | | - show_temp, NULL, offset - 1); \ |
---|
818 | | -static SENSOR_DEVICE_ATTR(temp##offset##_offset, S_IRUGO | S_IWUSR, \ |
---|
819 | | - show_temp_offset, set_temp_offset, offset - 1); \ |
---|
820 | | -static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ |
---|
821 | | - show_temp_min, set_temp_min, offset - 1); \ |
---|
822 | | -static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ |
---|
823 | | - show_temp_max, set_temp_max, offset - 1); \ |
---|
824 | | -static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IRUGO | S_IWUSR, \ |
---|
825 | | - show_temp_crit, set_temp_crit, offset - 1) |
---|
826 | | - |
---|
827 | | -temp_reg(1); |
---|
828 | | -temp_reg(2); |
---|
829 | | -temp_reg(3); |
---|
| 795 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); |
---|
| 796 | +static SENSOR_DEVICE_ATTR_RW(temp1_offset, temp_offset, 0); |
---|
| 797 | +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); |
---|
| 798 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); |
---|
| 799 | +static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp_crit, 0); |
---|
| 800 | +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); |
---|
| 801 | +static SENSOR_DEVICE_ATTR_RW(temp2_offset, temp_offset, 1); |
---|
| 802 | +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); |
---|
| 803 | +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); |
---|
| 804 | +static SENSOR_DEVICE_ATTR_RW(temp2_crit, temp_crit, 1); |
---|
| 805 | +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); |
---|
| 806 | +static SENSOR_DEVICE_ATTR_RW(temp3_offset, temp_offset, 2); |
---|
| 807 | +static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2); |
---|
| 808 | +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2); |
---|
| 809 | +static SENSOR_DEVICE_ATTR_RW(temp3_crit, temp_crit, 2); |
---|
830 | 810 | |
---|
831 | 811 | /* Alarms */ |
---|
832 | 812 | static ssize_t alarms_show(struct device *dev, struct device_attribute *attr, |
---|
.. | .. |
---|
838 | 818 | |
---|
839 | 819 | static DEVICE_ATTR_RO(alarms); |
---|
840 | 820 | |
---|
841 | | -static ssize_t show_alarm(struct device *dev, |
---|
842 | | - struct device_attribute *attr, char *buf) |
---|
| 821 | +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, |
---|
| 822 | + char *buf) |
---|
843 | 823 | { |
---|
844 | 824 | int bitnr = to_sensor_dev_attr(attr)->index; |
---|
845 | 825 | struct adm1031_data *data = adm1031_update_device(dev); |
---|
846 | 826 | return sprintf(buf, "%d\n", (data->alarm >> bitnr) & 1); |
---|
847 | 827 | } |
---|
848 | 828 | |
---|
849 | | -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 0); |
---|
850 | | -static SENSOR_DEVICE_ATTR(fan1_fault, S_IRUGO, show_alarm, NULL, 1); |
---|
851 | | -static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 2); |
---|
852 | | -static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); |
---|
853 | | -static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 4); |
---|
854 | | -static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 5); |
---|
855 | | -static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); |
---|
856 | | -static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 7); |
---|
857 | | -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 8); |
---|
858 | | -static SENSOR_DEVICE_ATTR(fan2_fault, S_IRUGO, show_alarm, NULL, 9); |
---|
859 | | -static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_alarm, NULL, 10); |
---|
860 | | -static SENSOR_DEVICE_ATTR(temp3_min_alarm, S_IRUGO, show_alarm, NULL, 11); |
---|
861 | | -static SENSOR_DEVICE_ATTR(temp3_crit_alarm, S_IRUGO, show_alarm, NULL, 12); |
---|
862 | | -static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 13); |
---|
863 | | -static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 14); |
---|
| 829 | +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 0); |
---|
| 830 | +static SENSOR_DEVICE_ATTR_RO(fan1_fault, alarm, 1); |
---|
| 831 | +static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 2); |
---|
| 832 | +static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, alarm, 3); |
---|
| 833 | +static SENSOR_DEVICE_ATTR_RO(temp2_crit_alarm, alarm, 4); |
---|
| 834 | +static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 5); |
---|
| 835 | +static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 6); |
---|
| 836 | +static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, 7); |
---|
| 837 | +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 8); |
---|
| 838 | +static SENSOR_DEVICE_ATTR_RO(fan2_fault, alarm, 9); |
---|
| 839 | +static SENSOR_DEVICE_ATTR_RO(temp3_max_alarm, alarm, 10); |
---|
| 840 | +static SENSOR_DEVICE_ATTR_RO(temp3_min_alarm, alarm, 11); |
---|
| 841 | +static SENSOR_DEVICE_ATTR_RO(temp3_crit_alarm, alarm, 12); |
---|
| 842 | +static SENSOR_DEVICE_ATTR_RO(temp3_fault, alarm, 13); |
---|
| 843 | +static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 14); |
---|
864 | 844 | |
---|
865 | 845 | /* Update Interval */ |
---|
866 | 846 | static const unsigned int update_intervals[] = { |
---|
.. | .. |
---|
1042 | 1022 | data->update_interval = update_intervals[i]; |
---|
1043 | 1023 | } |
---|
1044 | 1024 | |
---|
1045 | | -static int adm1031_probe(struct i2c_client *client, |
---|
1046 | | - const struct i2c_device_id *id) |
---|
| 1025 | +static const struct i2c_device_id adm1031_id[]; |
---|
| 1026 | + |
---|
| 1027 | +static int adm1031_probe(struct i2c_client *client) |
---|
1047 | 1028 | { |
---|
1048 | 1029 | struct device *dev = &client->dev; |
---|
1049 | 1030 | struct device *hwmon_dev; |
---|
.. | .. |
---|
1055 | 1036 | |
---|
1056 | 1037 | i2c_set_clientdata(client, data); |
---|
1057 | 1038 | data->client = client; |
---|
1058 | | - data->chip_type = id->driver_data; |
---|
| 1039 | + data->chip_type = i2c_match_id(adm1031_id, client)->driver_data; |
---|
1059 | 1040 | mutex_init(&data->update_lock); |
---|
1060 | 1041 | |
---|
1061 | 1042 | if (data->chip_type == adm1030) |
---|
.. | .. |
---|
1088 | 1069 | .driver = { |
---|
1089 | 1070 | .name = "adm1031", |
---|
1090 | 1071 | }, |
---|
1091 | | - .probe = adm1031_probe, |
---|
| 1072 | + .probe_new = adm1031_probe, |
---|
1092 | 1073 | .id_table = adm1031_id, |
---|
1093 | 1074 | .detect = adm1031_detect, |
---|
1094 | 1075 | .address_list = normal_i2c, |
---|