.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * A hwmon driver for the Analog Devices ADT7470 |
---|
3 | 4 | * Copyright (C) 2007 IBM |
---|
4 | 5 | * |
---|
5 | 6 | * Author: Darrick J. Wong <darrick.wong@oracle.com> |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License as published by |
---|
9 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
10 | | - * (at your option) any later version. |
---|
11 | | - * |
---|
12 | | - * This program is distributed in the hope that it will be useful, |
---|
13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | | - * GNU General Public License for more details. |
---|
16 | | - * |
---|
17 | | - * You should have received a copy of the GNU General Public License |
---|
18 | | - * along with this program; if not, write to the Free Software |
---|
19 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
20 | 7 | */ |
---|
21 | 8 | |
---|
22 | 9 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
.. | .. |
---|
33 | 20 | #include <linux/kthread.h> |
---|
34 | 21 | #include <linux/slab.h> |
---|
35 | 22 | #include <linux/util_macros.h> |
---|
| 23 | +#include <linux/sched.h> |
---|
36 | 24 | |
---|
37 | 25 | /* Addresses to scan */ |
---|
38 | 26 | static const unsigned short normal_i2c[] = { 0x2C, 0x2E, 0x2F, I2C_CLIENT_END }; |
---|
.. | .. |
---|
273 | 261 | adt7470_read_temperatures(client, data); |
---|
274 | 262 | mutex_unlock(&data->lock); |
---|
275 | 263 | |
---|
276 | | - set_current_state(TASK_INTERRUPTIBLE); |
---|
277 | 264 | if (kthread_should_stop()) |
---|
278 | 265 | break; |
---|
279 | 266 | |
---|
280 | | - schedule_timeout(msecs_to_jiffies(data->auto_update_interval)); |
---|
| 267 | + schedule_timeout_interruptible(msecs_to_jiffies(data->auto_update_interval)); |
---|
281 | 268 | } |
---|
282 | 269 | |
---|
283 | 270 | return 0; |
---|
.. | .. |
---|
459 | 446 | return count; |
---|
460 | 447 | } |
---|
461 | 448 | |
---|
462 | | -static ssize_t show_temp_min(struct device *dev, |
---|
463 | | - struct device_attribute *devattr, |
---|
464 | | - char *buf) |
---|
| 449 | +static ssize_t temp_min_show(struct device *dev, |
---|
| 450 | + struct device_attribute *devattr, char *buf) |
---|
465 | 451 | { |
---|
466 | 452 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
467 | 453 | struct adt7470_data *data = adt7470_update_device(dev); |
---|
468 | 454 | return sprintf(buf, "%d\n", 1000 * data->temp_min[attr->index]); |
---|
469 | 455 | } |
---|
470 | 456 | |
---|
471 | | -static ssize_t set_temp_min(struct device *dev, |
---|
472 | | - struct device_attribute *devattr, |
---|
473 | | - const char *buf, |
---|
474 | | - size_t count) |
---|
| 457 | +static ssize_t temp_min_store(struct device *dev, |
---|
| 458 | + struct device_attribute *devattr, |
---|
| 459 | + const char *buf, size_t count) |
---|
475 | 460 | { |
---|
476 | 461 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
477 | 462 | struct adt7470_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
493 | 478 | return count; |
---|
494 | 479 | } |
---|
495 | 480 | |
---|
496 | | -static ssize_t show_temp_max(struct device *dev, |
---|
497 | | - struct device_attribute *devattr, |
---|
498 | | - char *buf) |
---|
| 481 | +static ssize_t temp_max_show(struct device *dev, |
---|
| 482 | + struct device_attribute *devattr, char *buf) |
---|
499 | 483 | { |
---|
500 | 484 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
501 | 485 | struct adt7470_data *data = adt7470_update_device(dev); |
---|
502 | 486 | return sprintf(buf, "%d\n", 1000 * data->temp_max[attr->index]); |
---|
503 | 487 | } |
---|
504 | 488 | |
---|
505 | | -static ssize_t set_temp_max(struct device *dev, |
---|
506 | | - struct device_attribute *devattr, |
---|
507 | | - const char *buf, |
---|
508 | | - size_t count) |
---|
| 489 | +static ssize_t temp_max_store(struct device *dev, |
---|
| 490 | + struct device_attribute *devattr, |
---|
| 491 | + const char *buf, size_t count) |
---|
509 | 492 | { |
---|
510 | 493 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
511 | 494 | struct adt7470_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
527 | 510 | return count; |
---|
528 | 511 | } |
---|
529 | 512 | |
---|
530 | | -static ssize_t show_temp(struct device *dev, struct device_attribute *devattr, |
---|
| 513 | +static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, |
---|
531 | 514 | char *buf) |
---|
532 | 515 | { |
---|
533 | 516 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
565 | 548 | return count; |
---|
566 | 549 | } |
---|
567 | 550 | |
---|
568 | | -static ssize_t show_fan_max(struct device *dev, |
---|
569 | | - struct device_attribute *devattr, |
---|
570 | | - char *buf) |
---|
| 551 | +static ssize_t fan_max_show(struct device *dev, |
---|
| 552 | + struct device_attribute *devattr, char *buf) |
---|
571 | 553 | { |
---|
572 | 554 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
573 | 555 | struct adt7470_data *data = adt7470_update_device(dev); |
---|
.. | .. |
---|
579 | 561 | return sprintf(buf, "0\n"); |
---|
580 | 562 | } |
---|
581 | 563 | |
---|
582 | | -static ssize_t set_fan_max(struct device *dev, |
---|
583 | | - struct device_attribute *devattr, |
---|
584 | | - const char *buf, size_t count) |
---|
| 564 | +static ssize_t fan_max_store(struct device *dev, |
---|
| 565 | + struct device_attribute *devattr, |
---|
| 566 | + const char *buf, size_t count) |
---|
585 | 567 | { |
---|
586 | 568 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
587 | 569 | struct adt7470_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
602 | 584 | return count; |
---|
603 | 585 | } |
---|
604 | 586 | |
---|
605 | | -static ssize_t show_fan_min(struct device *dev, |
---|
606 | | - struct device_attribute *devattr, |
---|
607 | | - char *buf) |
---|
| 587 | +static ssize_t fan_min_show(struct device *dev, |
---|
| 588 | + struct device_attribute *devattr, char *buf) |
---|
608 | 589 | { |
---|
609 | 590 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
610 | 591 | struct adt7470_data *data = adt7470_update_device(dev); |
---|
.. | .. |
---|
616 | 597 | return sprintf(buf, "0\n"); |
---|
617 | 598 | } |
---|
618 | 599 | |
---|
619 | | -static ssize_t set_fan_min(struct device *dev, |
---|
620 | | - struct device_attribute *devattr, |
---|
621 | | - const char *buf, size_t count) |
---|
| 600 | +static ssize_t fan_min_store(struct device *dev, |
---|
| 601 | + struct device_attribute *devattr, |
---|
| 602 | + const char *buf, size_t count) |
---|
622 | 603 | { |
---|
623 | 604 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
624 | 605 | struct adt7470_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
639 | 620 | return count; |
---|
640 | 621 | } |
---|
641 | 622 | |
---|
642 | | -static ssize_t show_fan(struct device *dev, struct device_attribute *devattr, |
---|
| 623 | +static ssize_t fan_show(struct device *dev, struct device_attribute *devattr, |
---|
643 | 624 | char *buf) |
---|
644 | 625 | { |
---|
645 | 626 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
652 | 633 | return sprintf(buf, "0\n"); |
---|
653 | 634 | } |
---|
654 | 635 | |
---|
655 | | -static ssize_t show_force_pwm_max(struct device *dev, |
---|
656 | | - struct device_attribute *devattr, |
---|
657 | | - char *buf) |
---|
| 636 | +static ssize_t force_pwm_max_show(struct device *dev, |
---|
| 637 | + struct device_attribute *devattr, char *buf) |
---|
658 | 638 | { |
---|
659 | 639 | struct adt7470_data *data = adt7470_update_device(dev); |
---|
660 | 640 | return sprintf(buf, "%d\n", data->force_pwm_max); |
---|
661 | 641 | } |
---|
662 | 642 | |
---|
663 | | -static ssize_t set_force_pwm_max(struct device *dev, |
---|
664 | | - struct device_attribute *devattr, |
---|
665 | | - const char *buf, |
---|
666 | | - size_t count) |
---|
| 643 | +static ssize_t force_pwm_max_store(struct device *dev, |
---|
| 644 | + struct device_attribute *devattr, |
---|
| 645 | + const char *buf, size_t count) |
---|
667 | 646 | { |
---|
668 | 647 | struct adt7470_data *data = dev_get_drvdata(dev); |
---|
669 | 648 | struct i2c_client *client = data->client; |
---|
.. | .. |
---|
686 | 665 | return count; |
---|
687 | 666 | } |
---|
688 | 667 | |
---|
689 | | -static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, |
---|
| 668 | +static ssize_t pwm_show(struct device *dev, struct device_attribute *devattr, |
---|
690 | 669 | char *buf) |
---|
691 | 670 | { |
---|
692 | 671 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
.. | .. |
---|
694 | 673 | return sprintf(buf, "%d\n", data->pwm[attr->index]); |
---|
695 | 674 | } |
---|
696 | 675 | |
---|
697 | | -static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, |
---|
698 | | - const char *buf, size_t count) |
---|
| 676 | +static ssize_t pwm_store(struct device *dev, struct device_attribute *devattr, |
---|
| 677 | + const char *buf, size_t count) |
---|
699 | 678 | { |
---|
700 | 679 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
701 | 680 | struct adt7470_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
779 | 758 | return count; |
---|
780 | 759 | } |
---|
781 | 760 | |
---|
782 | | -static ssize_t show_pwm_max(struct device *dev, |
---|
783 | | - struct device_attribute *devattr, |
---|
784 | | - char *buf) |
---|
| 761 | +static ssize_t pwm_max_show(struct device *dev, |
---|
| 762 | + struct device_attribute *devattr, char *buf) |
---|
785 | 763 | { |
---|
786 | 764 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
787 | 765 | struct adt7470_data *data = adt7470_update_device(dev); |
---|
788 | 766 | return sprintf(buf, "%d\n", data->pwm_max[attr->index]); |
---|
789 | 767 | } |
---|
790 | 768 | |
---|
791 | | -static ssize_t set_pwm_max(struct device *dev, |
---|
792 | | - struct device_attribute *devattr, |
---|
793 | | - const char *buf, |
---|
794 | | - size_t count) |
---|
| 769 | +static ssize_t pwm_max_store(struct device *dev, |
---|
| 770 | + struct device_attribute *devattr, |
---|
| 771 | + const char *buf, size_t count) |
---|
795 | 772 | { |
---|
796 | 773 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
797 | 774 | struct adt7470_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
812 | 789 | return count; |
---|
813 | 790 | } |
---|
814 | 791 | |
---|
815 | | -static ssize_t show_pwm_min(struct device *dev, |
---|
816 | | - struct device_attribute *devattr, |
---|
817 | | - char *buf) |
---|
| 792 | +static ssize_t pwm_min_show(struct device *dev, |
---|
| 793 | + struct device_attribute *devattr, char *buf) |
---|
818 | 794 | { |
---|
819 | 795 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
820 | 796 | struct adt7470_data *data = adt7470_update_device(dev); |
---|
821 | 797 | return sprintf(buf, "%d\n", data->pwm_min[attr->index]); |
---|
822 | 798 | } |
---|
823 | 799 | |
---|
824 | | -static ssize_t set_pwm_min(struct device *dev, |
---|
825 | | - struct device_attribute *devattr, |
---|
826 | | - const char *buf, |
---|
827 | | - size_t count) |
---|
| 800 | +static ssize_t pwm_min_store(struct device *dev, |
---|
| 801 | + struct device_attribute *devattr, |
---|
| 802 | + const char *buf, size_t count) |
---|
828 | 803 | { |
---|
829 | 804 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
830 | 805 | struct adt7470_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
845 | 820 | return count; |
---|
846 | 821 | } |
---|
847 | 822 | |
---|
848 | | -static ssize_t show_pwm_tmax(struct device *dev, |
---|
849 | | - struct device_attribute *devattr, |
---|
850 | | - char *buf) |
---|
| 823 | +static ssize_t pwm_tmax_show(struct device *dev, |
---|
| 824 | + struct device_attribute *devattr, char *buf) |
---|
851 | 825 | { |
---|
852 | 826 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
853 | 827 | struct adt7470_data *data = adt7470_update_device(dev); |
---|
.. | .. |
---|
855 | 829 | return sprintf(buf, "%d\n", 1000 * (20 + data->pwm_tmin[attr->index])); |
---|
856 | 830 | } |
---|
857 | 831 | |
---|
858 | | -static ssize_t show_pwm_tmin(struct device *dev, |
---|
859 | | - struct device_attribute *devattr, |
---|
860 | | - char *buf) |
---|
| 832 | +static ssize_t pwm_tmin_show(struct device *dev, |
---|
| 833 | + struct device_attribute *devattr, char *buf) |
---|
861 | 834 | { |
---|
862 | 835 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
863 | 836 | struct adt7470_data *data = adt7470_update_device(dev); |
---|
864 | 837 | return sprintf(buf, "%d\n", 1000 * data->pwm_tmin[attr->index]); |
---|
865 | 838 | } |
---|
866 | 839 | |
---|
867 | | -static ssize_t set_pwm_tmin(struct device *dev, |
---|
868 | | - struct device_attribute *devattr, |
---|
869 | | - const char *buf, |
---|
870 | | - size_t count) |
---|
| 840 | +static ssize_t pwm_tmin_store(struct device *dev, |
---|
| 841 | + struct device_attribute *devattr, |
---|
| 842 | + const char *buf, size_t count) |
---|
871 | 843 | { |
---|
872 | 844 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
873 | 845 | struct adt7470_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
889 | 861 | return count; |
---|
890 | 862 | } |
---|
891 | 863 | |
---|
892 | | -static ssize_t show_pwm_auto(struct device *dev, |
---|
893 | | - struct device_attribute *devattr, |
---|
894 | | - char *buf) |
---|
| 864 | +static ssize_t pwm_auto_show(struct device *dev, |
---|
| 865 | + struct device_attribute *devattr, char *buf) |
---|
895 | 866 | { |
---|
896 | 867 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
897 | 868 | struct adt7470_data *data = adt7470_update_device(dev); |
---|
898 | 869 | return sprintf(buf, "%d\n", 1 + data->pwm_automatic[attr->index]); |
---|
899 | 870 | } |
---|
900 | 871 | |
---|
901 | | -static ssize_t set_pwm_auto(struct device *dev, |
---|
902 | | - struct device_attribute *devattr, |
---|
903 | | - const char *buf, |
---|
904 | | - size_t count) |
---|
| 872 | +static ssize_t pwm_auto_store(struct device *dev, |
---|
| 873 | + struct device_attribute *devattr, |
---|
| 874 | + const char *buf, size_t count) |
---|
905 | 875 | { |
---|
906 | 876 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
907 | 877 | struct adt7470_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
936 | 906 | return count; |
---|
937 | 907 | } |
---|
938 | 908 | |
---|
939 | | -static ssize_t show_pwm_auto_temp(struct device *dev, |
---|
940 | | - struct device_attribute *devattr, |
---|
941 | | - char *buf) |
---|
| 909 | +static ssize_t pwm_auto_temp_show(struct device *dev, |
---|
| 910 | + struct device_attribute *devattr, char *buf) |
---|
942 | 911 | { |
---|
943 | 912 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
944 | 913 | struct adt7470_data *data = adt7470_update_device(dev); |
---|
.. | .. |
---|
959 | 928 | return ilog2(input) + 1; |
---|
960 | 929 | } |
---|
961 | 930 | |
---|
962 | | -static ssize_t set_pwm_auto_temp(struct device *dev, |
---|
963 | | - struct device_attribute *devattr, |
---|
964 | | - const char *buf, |
---|
965 | | - size_t count) |
---|
| 931 | +static ssize_t pwm_auto_temp_store(struct device *dev, |
---|
| 932 | + struct device_attribute *devattr, |
---|
| 933 | + const char *buf, size_t count) |
---|
966 | 934 | { |
---|
967 | 935 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
968 | 936 | struct adt7470_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
996 | 964 | return count; |
---|
997 | 965 | } |
---|
998 | 966 | |
---|
999 | | -static ssize_t show_alarm(struct device *dev, |
---|
1000 | | - struct device_attribute *devattr, |
---|
1001 | | - char *buf) |
---|
| 967 | +static ssize_t alarm_show(struct device *dev, |
---|
| 968 | + struct device_attribute *devattr, char *buf) |
---|
1002 | 969 | { |
---|
1003 | 970 | struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); |
---|
1004 | 971 | struct adt7470_data *data = adt7470_update_device(dev); |
---|
.. | .. |
---|
1013 | 980 | static DEVICE_ATTR_RW(num_temp_sensors); |
---|
1014 | 981 | static DEVICE_ATTR_RW(auto_update_interval); |
---|
1015 | 982 | |
---|
1016 | | -static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, |
---|
1017 | | - set_temp_max, 0); |
---|
1018 | | -static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, |
---|
1019 | | - set_temp_max, 1); |
---|
1020 | | -static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_temp_max, |
---|
1021 | | - set_temp_max, 2); |
---|
1022 | | -static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_temp_max, |
---|
1023 | | - set_temp_max, 3); |
---|
1024 | | -static SENSOR_DEVICE_ATTR(temp5_max, S_IWUSR | S_IRUGO, show_temp_max, |
---|
1025 | | - set_temp_max, 4); |
---|
1026 | | -static SENSOR_DEVICE_ATTR(temp6_max, S_IWUSR | S_IRUGO, show_temp_max, |
---|
1027 | | - set_temp_max, 5); |
---|
1028 | | -static SENSOR_DEVICE_ATTR(temp7_max, S_IWUSR | S_IRUGO, show_temp_max, |
---|
1029 | | - set_temp_max, 6); |
---|
1030 | | -static SENSOR_DEVICE_ATTR(temp8_max, S_IWUSR | S_IRUGO, show_temp_max, |
---|
1031 | | - set_temp_max, 7); |
---|
1032 | | -static SENSOR_DEVICE_ATTR(temp9_max, S_IWUSR | S_IRUGO, show_temp_max, |
---|
1033 | | - set_temp_max, 8); |
---|
1034 | | -static SENSOR_DEVICE_ATTR(temp10_max, S_IWUSR | S_IRUGO, show_temp_max, |
---|
1035 | | - set_temp_max, 9); |
---|
| 983 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); |
---|
| 984 | +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); |
---|
| 985 | +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2); |
---|
| 986 | +static SENSOR_DEVICE_ATTR_RW(temp4_max, temp_max, 3); |
---|
| 987 | +static SENSOR_DEVICE_ATTR_RW(temp5_max, temp_max, 4); |
---|
| 988 | +static SENSOR_DEVICE_ATTR_RW(temp6_max, temp_max, 5); |
---|
| 989 | +static SENSOR_DEVICE_ATTR_RW(temp7_max, temp_max, 6); |
---|
| 990 | +static SENSOR_DEVICE_ATTR_RW(temp8_max, temp_max, 7); |
---|
| 991 | +static SENSOR_DEVICE_ATTR_RW(temp9_max, temp_max, 8); |
---|
| 992 | +static SENSOR_DEVICE_ATTR_RW(temp10_max, temp_max, 9); |
---|
1036 | 993 | |
---|
1037 | | -static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_min, |
---|
1038 | | - set_temp_min, 0); |
---|
1039 | | -static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_min, |
---|
1040 | | - set_temp_min, 1); |
---|
1041 | | -static SENSOR_DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_temp_min, |
---|
1042 | | - set_temp_min, 2); |
---|
1043 | | -static SENSOR_DEVICE_ATTR(temp4_min, S_IWUSR | S_IRUGO, show_temp_min, |
---|
1044 | | - set_temp_min, 3); |
---|
1045 | | -static SENSOR_DEVICE_ATTR(temp5_min, S_IWUSR | S_IRUGO, show_temp_min, |
---|
1046 | | - set_temp_min, 4); |
---|
1047 | | -static SENSOR_DEVICE_ATTR(temp6_min, S_IWUSR | S_IRUGO, show_temp_min, |
---|
1048 | | - set_temp_min, 5); |
---|
1049 | | -static SENSOR_DEVICE_ATTR(temp7_min, S_IWUSR | S_IRUGO, show_temp_min, |
---|
1050 | | - set_temp_min, 6); |
---|
1051 | | -static SENSOR_DEVICE_ATTR(temp8_min, S_IWUSR | S_IRUGO, show_temp_min, |
---|
1052 | | - set_temp_min, 7); |
---|
1053 | | -static SENSOR_DEVICE_ATTR(temp9_min, S_IWUSR | S_IRUGO, show_temp_min, |
---|
1054 | | - set_temp_min, 8); |
---|
1055 | | -static SENSOR_DEVICE_ATTR(temp10_min, S_IWUSR | S_IRUGO, show_temp_min, |
---|
1056 | | - set_temp_min, 9); |
---|
| 994 | +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); |
---|
| 995 | +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); |
---|
| 996 | +static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2); |
---|
| 997 | +static SENSOR_DEVICE_ATTR_RW(temp4_min, temp_min, 3); |
---|
| 998 | +static SENSOR_DEVICE_ATTR_RW(temp5_min, temp_min, 4); |
---|
| 999 | +static SENSOR_DEVICE_ATTR_RW(temp6_min, temp_min, 5); |
---|
| 1000 | +static SENSOR_DEVICE_ATTR_RW(temp7_min, temp_min, 6); |
---|
| 1001 | +static SENSOR_DEVICE_ATTR_RW(temp8_min, temp_min, 7); |
---|
| 1002 | +static SENSOR_DEVICE_ATTR_RW(temp9_min, temp_min, 8); |
---|
| 1003 | +static SENSOR_DEVICE_ATTR_RW(temp10_min, temp_min, 9); |
---|
1057 | 1004 | |
---|
1058 | | -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); |
---|
1059 | | -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); |
---|
1060 | | -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); |
---|
1061 | | -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); |
---|
1062 | | -static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_temp, NULL, 4); |
---|
1063 | | -static SENSOR_DEVICE_ATTR(temp6_input, S_IRUGO, show_temp, NULL, 5); |
---|
1064 | | -static SENSOR_DEVICE_ATTR(temp7_input, S_IRUGO, show_temp, NULL, 6); |
---|
1065 | | -static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_temp, NULL, 7); |
---|
1066 | | -static SENSOR_DEVICE_ATTR(temp9_input, S_IRUGO, show_temp, NULL, 8); |
---|
1067 | | -static SENSOR_DEVICE_ATTR(temp10_input, S_IRUGO, show_temp, NULL, 9); |
---|
| 1005 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); |
---|
| 1006 | +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); |
---|
| 1007 | +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); |
---|
| 1008 | +static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 3); |
---|
| 1009 | +static SENSOR_DEVICE_ATTR_RO(temp5_input, temp, 4); |
---|
| 1010 | +static SENSOR_DEVICE_ATTR_RO(temp6_input, temp, 5); |
---|
| 1011 | +static SENSOR_DEVICE_ATTR_RO(temp7_input, temp, 6); |
---|
| 1012 | +static SENSOR_DEVICE_ATTR_RO(temp8_input, temp, 7); |
---|
| 1013 | +static SENSOR_DEVICE_ATTR_RO(temp9_input, temp, 8); |
---|
| 1014 | +static SENSOR_DEVICE_ATTR_RO(temp10_input, temp, 9); |
---|
1068 | 1015 | |
---|
1069 | | -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, |
---|
1070 | | - ADT7470_R1T_ALARM); |
---|
1071 | | -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, |
---|
1072 | | - ADT7470_R2T_ALARM); |
---|
1073 | | -static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, |
---|
1074 | | - ADT7470_R3T_ALARM); |
---|
1075 | | -static SENSOR_DEVICE_ATTR(temp4_alarm, S_IRUGO, show_alarm, NULL, |
---|
1076 | | - ADT7470_R4T_ALARM); |
---|
1077 | | -static SENSOR_DEVICE_ATTR(temp5_alarm, S_IRUGO, show_alarm, NULL, |
---|
1078 | | - ADT7470_R5T_ALARM); |
---|
1079 | | -static SENSOR_DEVICE_ATTR(temp6_alarm, S_IRUGO, show_alarm, NULL, |
---|
1080 | | - ADT7470_R6T_ALARM); |
---|
1081 | | -static SENSOR_DEVICE_ATTR(temp7_alarm, S_IRUGO, show_alarm, NULL, |
---|
1082 | | - ADT7470_R7T_ALARM); |
---|
1083 | | -static SENSOR_DEVICE_ATTR(temp8_alarm, S_IRUGO, show_alarm, NULL, |
---|
1084 | | - ALARM2(ADT7470_R8T_ALARM)); |
---|
1085 | | -static SENSOR_DEVICE_ATTR(temp9_alarm, S_IRUGO, show_alarm, NULL, |
---|
1086 | | - ALARM2(ADT7470_R9T_ALARM)); |
---|
1087 | | -static SENSOR_DEVICE_ATTR(temp10_alarm, S_IRUGO, show_alarm, NULL, |
---|
1088 | | - ALARM2(ADT7470_R10T_ALARM)); |
---|
| 1016 | +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, ADT7470_R1T_ALARM); |
---|
| 1017 | +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, ADT7470_R2T_ALARM); |
---|
| 1018 | +static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, ADT7470_R3T_ALARM); |
---|
| 1019 | +static SENSOR_DEVICE_ATTR_RO(temp4_alarm, alarm, ADT7470_R4T_ALARM); |
---|
| 1020 | +static SENSOR_DEVICE_ATTR_RO(temp5_alarm, alarm, ADT7470_R5T_ALARM); |
---|
| 1021 | +static SENSOR_DEVICE_ATTR_RO(temp6_alarm, alarm, ADT7470_R6T_ALARM); |
---|
| 1022 | +static SENSOR_DEVICE_ATTR_RO(temp7_alarm, alarm, ADT7470_R7T_ALARM); |
---|
| 1023 | +static SENSOR_DEVICE_ATTR_RO(temp8_alarm, alarm, ALARM2(ADT7470_R8T_ALARM)); |
---|
| 1024 | +static SENSOR_DEVICE_ATTR_RO(temp9_alarm, alarm, ALARM2(ADT7470_R9T_ALARM)); |
---|
| 1025 | +static SENSOR_DEVICE_ATTR_RO(temp10_alarm, alarm, ALARM2(ADT7470_R10T_ALARM)); |
---|
1089 | 1026 | |
---|
1090 | | -static SENSOR_DEVICE_ATTR(fan1_max, S_IWUSR | S_IRUGO, show_fan_max, |
---|
1091 | | - set_fan_max, 0); |
---|
1092 | | -static SENSOR_DEVICE_ATTR(fan2_max, S_IWUSR | S_IRUGO, show_fan_max, |
---|
1093 | | - set_fan_max, 1); |
---|
1094 | | -static SENSOR_DEVICE_ATTR(fan3_max, S_IWUSR | S_IRUGO, show_fan_max, |
---|
1095 | | - set_fan_max, 2); |
---|
1096 | | -static SENSOR_DEVICE_ATTR(fan4_max, S_IWUSR | S_IRUGO, show_fan_max, |
---|
1097 | | - set_fan_max, 3); |
---|
| 1027 | +static SENSOR_DEVICE_ATTR_RW(fan1_max, fan_max, 0); |
---|
| 1028 | +static SENSOR_DEVICE_ATTR_RW(fan2_max, fan_max, 1); |
---|
| 1029 | +static SENSOR_DEVICE_ATTR_RW(fan3_max, fan_max, 2); |
---|
| 1030 | +static SENSOR_DEVICE_ATTR_RW(fan4_max, fan_max, 3); |
---|
1098 | 1031 | |
---|
1099 | | -static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, |
---|
1100 | | - set_fan_min, 0); |
---|
1101 | | -static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, |
---|
1102 | | - set_fan_min, 1); |
---|
1103 | | -static SENSOR_DEVICE_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, |
---|
1104 | | - set_fan_min, 2); |
---|
1105 | | -static SENSOR_DEVICE_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, |
---|
1106 | | - set_fan_min, 3); |
---|
| 1032 | +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); |
---|
| 1033 | +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); |
---|
| 1034 | +static SENSOR_DEVICE_ATTR_RW(fan3_min, fan_min, 2); |
---|
| 1035 | +static SENSOR_DEVICE_ATTR_RW(fan4_min, fan_min, 3); |
---|
1107 | 1036 | |
---|
1108 | | -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); |
---|
1109 | | -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); |
---|
1110 | | -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); |
---|
1111 | | -static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3); |
---|
| 1037 | +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); |
---|
| 1038 | +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); |
---|
| 1039 | +static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 2); |
---|
| 1040 | +static SENSOR_DEVICE_ATTR_RO(fan4_input, fan, 3); |
---|
1112 | 1041 | |
---|
1113 | | -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, |
---|
1114 | | - ALARM2(ADT7470_FAN1_ALARM)); |
---|
1115 | | -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, |
---|
1116 | | - ALARM2(ADT7470_FAN2_ALARM)); |
---|
1117 | | -static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, |
---|
1118 | | - ALARM2(ADT7470_FAN3_ALARM)); |
---|
1119 | | -static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, |
---|
1120 | | - ALARM2(ADT7470_FAN4_ALARM)); |
---|
| 1042 | +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, ALARM2(ADT7470_FAN1_ALARM)); |
---|
| 1043 | +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, ALARM2(ADT7470_FAN2_ALARM)); |
---|
| 1044 | +static SENSOR_DEVICE_ATTR_RO(fan3_alarm, alarm, ALARM2(ADT7470_FAN3_ALARM)); |
---|
| 1045 | +static SENSOR_DEVICE_ATTR_RO(fan4_alarm, alarm, ALARM2(ADT7470_FAN4_ALARM)); |
---|
1121 | 1046 | |
---|
1122 | | -static SENSOR_DEVICE_ATTR(force_pwm_max, S_IWUSR | S_IRUGO, |
---|
1123 | | - show_force_pwm_max, set_force_pwm_max, 0); |
---|
| 1047 | +static SENSOR_DEVICE_ATTR_RW(force_pwm_max, force_pwm_max, 0); |
---|
1124 | 1048 | |
---|
1125 | | -static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0); |
---|
1126 | | -static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1); |
---|
1127 | | -static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2); |
---|
1128 | | -static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 3); |
---|
| 1049 | +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); |
---|
| 1050 | +static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1); |
---|
| 1051 | +static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, 2); |
---|
| 1052 | +static SENSOR_DEVICE_ATTR_RW(pwm4, pwm, 3); |
---|
1129 | 1053 | |
---|
1130 | 1054 | static DEVICE_ATTR_RW(pwm1_freq); |
---|
1131 | 1055 | |
---|
1132 | | -static SENSOR_DEVICE_ATTR(pwm1_auto_point1_pwm, S_IWUSR | S_IRUGO, |
---|
1133 | | - show_pwm_min, set_pwm_min, 0); |
---|
1134 | | -static SENSOR_DEVICE_ATTR(pwm2_auto_point1_pwm, S_IWUSR | S_IRUGO, |
---|
1135 | | - show_pwm_min, set_pwm_min, 1); |
---|
1136 | | -static SENSOR_DEVICE_ATTR(pwm3_auto_point1_pwm, S_IWUSR | S_IRUGO, |
---|
1137 | | - show_pwm_min, set_pwm_min, 2); |
---|
1138 | | -static SENSOR_DEVICE_ATTR(pwm4_auto_point1_pwm, S_IWUSR | S_IRUGO, |
---|
1139 | | - show_pwm_min, set_pwm_min, 3); |
---|
| 1056 | +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point1_pwm, pwm_min, 0); |
---|
| 1057 | +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point1_pwm, pwm_min, 1); |
---|
| 1058 | +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point1_pwm, pwm_min, 2); |
---|
| 1059 | +static SENSOR_DEVICE_ATTR_RW(pwm4_auto_point1_pwm, pwm_min, 3); |
---|
1140 | 1060 | |
---|
1141 | | -static SENSOR_DEVICE_ATTR(pwm1_auto_point2_pwm, S_IWUSR | S_IRUGO, |
---|
1142 | | - show_pwm_max, set_pwm_max, 0); |
---|
1143 | | -static SENSOR_DEVICE_ATTR(pwm2_auto_point2_pwm, S_IWUSR | S_IRUGO, |
---|
1144 | | - show_pwm_max, set_pwm_max, 1); |
---|
1145 | | -static SENSOR_DEVICE_ATTR(pwm3_auto_point2_pwm, S_IWUSR | S_IRUGO, |
---|
1146 | | - show_pwm_max, set_pwm_max, 2); |
---|
1147 | | -static SENSOR_DEVICE_ATTR(pwm4_auto_point2_pwm, S_IWUSR | S_IRUGO, |
---|
1148 | | - show_pwm_max, set_pwm_max, 3); |
---|
| 1061 | +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point2_pwm, pwm_max, 0); |
---|
| 1062 | +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point2_pwm, pwm_max, 1); |
---|
| 1063 | +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point2_pwm, pwm_max, 2); |
---|
| 1064 | +static SENSOR_DEVICE_ATTR_RW(pwm4_auto_point2_pwm, pwm_max, 3); |
---|
1149 | 1065 | |
---|
1150 | | -static SENSOR_DEVICE_ATTR(pwm1_auto_point1_temp, S_IWUSR | S_IRUGO, |
---|
1151 | | - show_pwm_tmin, set_pwm_tmin, 0); |
---|
1152 | | -static SENSOR_DEVICE_ATTR(pwm2_auto_point1_temp, S_IWUSR | S_IRUGO, |
---|
1153 | | - show_pwm_tmin, set_pwm_tmin, 1); |
---|
1154 | | -static SENSOR_DEVICE_ATTR(pwm3_auto_point1_temp, S_IWUSR | S_IRUGO, |
---|
1155 | | - show_pwm_tmin, set_pwm_tmin, 2); |
---|
1156 | | -static SENSOR_DEVICE_ATTR(pwm4_auto_point1_temp, S_IWUSR | S_IRUGO, |
---|
1157 | | - show_pwm_tmin, set_pwm_tmin, 3); |
---|
| 1066 | +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_point1_temp, pwm_tmin, 0); |
---|
| 1067 | +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_point1_temp, pwm_tmin, 1); |
---|
| 1068 | +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_point1_temp, pwm_tmin, 2); |
---|
| 1069 | +static SENSOR_DEVICE_ATTR_RW(pwm4_auto_point1_temp, pwm_tmin, 3); |
---|
1158 | 1070 | |
---|
1159 | | -static SENSOR_DEVICE_ATTR(pwm1_auto_point2_temp, S_IRUGO, show_pwm_tmax, |
---|
1160 | | - NULL, 0); |
---|
1161 | | -static SENSOR_DEVICE_ATTR(pwm2_auto_point2_temp, S_IRUGO, show_pwm_tmax, |
---|
1162 | | - NULL, 1); |
---|
1163 | | -static SENSOR_DEVICE_ATTR(pwm3_auto_point2_temp, S_IRUGO, show_pwm_tmax, |
---|
1164 | | - NULL, 2); |
---|
1165 | | -static SENSOR_DEVICE_ATTR(pwm4_auto_point2_temp, S_IRUGO, show_pwm_tmax, |
---|
1166 | | - NULL, 3); |
---|
| 1071 | +static SENSOR_DEVICE_ATTR_RO(pwm1_auto_point2_temp, pwm_tmax, 0); |
---|
| 1072 | +static SENSOR_DEVICE_ATTR_RO(pwm2_auto_point2_temp, pwm_tmax, 1); |
---|
| 1073 | +static SENSOR_DEVICE_ATTR_RO(pwm3_auto_point2_temp, pwm_tmax, 2); |
---|
| 1074 | +static SENSOR_DEVICE_ATTR_RO(pwm4_auto_point2_temp, pwm_tmax, 3); |
---|
1167 | 1075 | |
---|
1168 | | -static SENSOR_DEVICE_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, show_pwm_auto, |
---|
1169 | | - set_pwm_auto, 0); |
---|
1170 | | -static SENSOR_DEVICE_ATTR(pwm2_enable, S_IWUSR | S_IRUGO, show_pwm_auto, |
---|
1171 | | - set_pwm_auto, 1); |
---|
1172 | | -static SENSOR_DEVICE_ATTR(pwm3_enable, S_IWUSR | S_IRUGO, show_pwm_auto, |
---|
1173 | | - set_pwm_auto, 2); |
---|
1174 | | -static SENSOR_DEVICE_ATTR(pwm4_enable, S_IWUSR | S_IRUGO, show_pwm_auto, |
---|
1175 | | - set_pwm_auto, 3); |
---|
| 1076 | +static SENSOR_DEVICE_ATTR_RW(pwm1_enable, pwm_auto, 0); |
---|
| 1077 | +static SENSOR_DEVICE_ATTR_RW(pwm2_enable, pwm_auto, 1); |
---|
| 1078 | +static SENSOR_DEVICE_ATTR_RW(pwm3_enable, pwm_auto, 2); |
---|
| 1079 | +static SENSOR_DEVICE_ATTR_RW(pwm4_enable, pwm_auto, 3); |
---|
1176 | 1080 | |
---|
1177 | | -static SENSOR_DEVICE_ATTR(pwm1_auto_channels_temp, S_IWUSR | S_IRUGO, |
---|
1178 | | - show_pwm_auto_temp, set_pwm_auto_temp, 0); |
---|
1179 | | -static SENSOR_DEVICE_ATTR(pwm2_auto_channels_temp, S_IWUSR | S_IRUGO, |
---|
1180 | | - show_pwm_auto_temp, set_pwm_auto_temp, 1); |
---|
1181 | | -static SENSOR_DEVICE_ATTR(pwm3_auto_channels_temp, S_IWUSR | S_IRUGO, |
---|
1182 | | - show_pwm_auto_temp, set_pwm_auto_temp, 2); |
---|
1183 | | -static SENSOR_DEVICE_ATTR(pwm4_auto_channels_temp, S_IWUSR | S_IRUGO, |
---|
1184 | | - show_pwm_auto_temp, set_pwm_auto_temp, 3); |
---|
| 1081 | +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_channels_temp, pwm_auto_temp, 0); |
---|
| 1082 | +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_channels_temp, pwm_auto_temp, 1); |
---|
| 1083 | +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_channels_temp, pwm_auto_temp, 2); |
---|
| 1084 | +static SENSOR_DEVICE_ATTR_RW(pwm4_auto_channels_temp, pwm_auto_temp, 3); |
---|
1185 | 1085 | |
---|
1186 | 1086 | static struct attribute *adt7470_attrs[] = { |
---|
1187 | 1087 | &dev_attr_alarm_mask.attr, |
---|
.. | .. |
---|
1317 | 1217 | } |
---|
1318 | 1218 | } |
---|
1319 | 1219 | |
---|
1320 | | -static int adt7470_probe(struct i2c_client *client, |
---|
1321 | | - const struct i2c_device_id *id) |
---|
| 1220 | +static int adt7470_probe(struct i2c_client *client) |
---|
1322 | 1221 | { |
---|
1323 | 1222 | struct device *dev = &client->dev; |
---|
1324 | 1223 | struct adt7470_data *data; |
---|
.. | .. |
---|
1376 | 1275 | .driver = { |
---|
1377 | 1276 | .name = "adt7470", |
---|
1378 | 1277 | }, |
---|
1379 | | - .probe = adt7470_probe, |
---|
| 1278 | + .probe_new = adt7470_probe, |
---|
1380 | 1279 | .remove = adt7470_remove, |
---|
1381 | 1280 | .id_table = adt7470_id, |
---|
1382 | 1281 | .detect = adt7470_detect, |
---|