hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwmon/adt7470.c
....@@ -1,22 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * A hwmon driver for the Analog Devices ADT7470
34 * Copyright (C) 2007 IBM
45 *
56 * 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
207 */
218
229 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -33,6 +20,7 @@
3320 #include <linux/kthread.h>
3421 #include <linux/slab.h>
3522 #include <linux/util_macros.h>
23
+#include <linux/sched.h>
3624
3725 /* Addresses to scan */
3826 static const unsigned short normal_i2c[] = { 0x2C, 0x2E, 0x2F, I2C_CLIENT_END };
....@@ -273,11 +261,10 @@
273261 adt7470_read_temperatures(client, data);
274262 mutex_unlock(&data->lock);
275263
276
- set_current_state(TASK_INTERRUPTIBLE);
277264 if (kthread_should_stop())
278265 break;
279266
280
- schedule_timeout(msecs_to_jiffies(data->auto_update_interval));
267
+ schedule_timeout_interruptible(msecs_to_jiffies(data->auto_update_interval));
281268 }
282269
283270 return 0;
....@@ -459,19 +446,17 @@
459446 return count;
460447 }
461448
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)
465451 {
466452 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
467453 struct adt7470_data *data = adt7470_update_device(dev);
468454 return sprintf(buf, "%d\n", 1000 * data->temp_min[attr->index]);
469455 }
470456
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)
475460 {
476461 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
477462 struct adt7470_data *data = dev_get_drvdata(dev);
....@@ -493,19 +478,17 @@
493478 return count;
494479 }
495480
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)
499483 {
500484 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
501485 struct adt7470_data *data = adt7470_update_device(dev);
502486 return sprintf(buf, "%d\n", 1000 * data->temp_max[attr->index]);
503487 }
504488
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)
509492 {
510493 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
511494 struct adt7470_data *data = dev_get_drvdata(dev);
....@@ -527,7 +510,7 @@
527510 return count;
528511 }
529512
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,
531514 char *buf)
532515 {
533516 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
....@@ -565,9 +548,8 @@
565548 return count;
566549 }
567550
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)
571553 {
572554 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
573555 struct adt7470_data *data = adt7470_update_device(dev);
....@@ -579,9 +561,9 @@
579561 return sprintf(buf, "0\n");
580562 }
581563
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)
585567 {
586568 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
587569 struct adt7470_data *data = dev_get_drvdata(dev);
....@@ -602,9 +584,8 @@
602584 return count;
603585 }
604586
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)
608589 {
609590 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
610591 struct adt7470_data *data = adt7470_update_device(dev);
....@@ -616,9 +597,9 @@
616597 return sprintf(buf, "0\n");
617598 }
618599
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)
622603 {
623604 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
624605 struct adt7470_data *data = dev_get_drvdata(dev);
....@@ -639,7 +620,7 @@
639620 return count;
640621 }
641622
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,
643624 char *buf)
644625 {
645626 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
....@@ -652,18 +633,16 @@
652633 return sprintf(buf, "0\n");
653634 }
654635
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)
658638 {
659639 struct adt7470_data *data = adt7470_update_device(dev);
660640 return sprintf(buf, "%d\n", data->force_pwm_max);
661641 }
662642
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)
667646 {
668647 struct adt7470_data *data = dev_get_drvdata(dev);
669648 struct i2c_client *client = data->client;
....@@ -686,7 +665,7 @@
686665 return count;
687666 }
688667
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,
690669 char *buf)
691670 {
692671 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
....@@ -694,8 +673,8 @@
694673 return sprintf(buf, "%d\n", data->pwm[attr->index]);
695674 }
696675
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)
699678 {
700679 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
701680 struct adt7470_data *data = dev_get_drvdata(dev);
....@@ -779,19 +758,17 @@
779758 return count;
780759 }
781760
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)
785763 {
786764 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
787765 struct adt7470_data *data = adt7470_update_device(dev);
788766 return sprintf(buf, "%d\n", data->pwm_max[attr->index]);
789767 }
790768
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)
795772 {
796773 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
797774 struct adt7470_data *data = dev_get_drvdata(dev);
....@@ -812,19 +789,17 @@
812789 return count;
813790 }
814791
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)
818794 {
819795 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
820796 struct adt7470_data *data = adt7470_update_device(dev);
821797 return sprintf(buf, "%d\n", data->pwm_min[attr->index]);
822798 }
823799
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)
828803 {
829804 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
830805 struct adt7470_data *data = dev_get_drvdata(dev);
....@@ -845,9 +820,8 @@
845820 return count;
846821 }
847822
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)
851825 {
852826 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
853827 struct adt7470_data *data = adt7470_update_device(dev);
....@@ -855,19 +829,17 @@
855829 return sprintf(buf, "%d\n", 1000 * (20 + data->pwm_tmin[attr->index]));
856830 }
857831
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)
861834 {
862835 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
863836 struct adt7470_data *data = adt7470_update_device(dev);
864837 return sprintf(buf, "%d\n", 1000 * data->pwm_tmin[attr->index]);
865838 }
866839
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)
871843 {
872844 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
873845 struct adt7470_data *data = dev_get_drvdata(dev);
....@@ -889,19 +861,17 @@
889861 return count;
890862 }
891863
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)
895866 {
896867 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
897868 struct adt7470_data *data = adt7470_update_device(dev);
898869 return sprintf(buf, "%d\n", 1 + data->pwm_automatic[attr->index]);
899870 }
900871
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)
905875 {
906876 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
907877 struct adt7470_data *data = dev_get_drvdata(dev);
....@@ -936,9 +906,8 @@
936906 return count;
937907 }
938908
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)
942911 {
943912 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
944913 struct adt7470_data *data = adt7470_update_device(dev);
....@@ -959,10 +928,9 @@
959928 return ilog2(input) + 1;
960929 }
961930
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)
966934 {
967935 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
968936 struct adt7470_data *data = dev_get_drvdata(dev);
....@@ -996,9 +964,8 @@
996964 return count;
997965 }
998966
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)
1002969 {
1003970 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
1004971 struct adt7470_data *data = adt7470_update_device(dev);
....@@ -1013,175 +980,108 @@
1013980 static DEVICE_ATTR_RW(num_temp_sensors);
1014981 static DEVICE_ATTR_RW(auto_update_interval);
1015982
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);
1036993
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);
10571004
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);
10681015
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));
10891026
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);
10981031
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);
11071036
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);
11121041
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));
11211046
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);
11241048
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);
11291053
11301054 static DEVICE_ATTR_RW(pwm1_freq);
11311055
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);
11401060
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);
11491065
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);
11581070
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);
11671075
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);
11761080
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);
11851085
11861086 static struct attribute *adt7470_attrs[] = {
11871087 &dev_attr_alarm_mask.attr,
....@@ -1317,8 +1217,7 @@
13171217 }
13181218 }
13191219
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)
13221221 {
13231222 struct device *dev = &client->dev;
13241223 struct adt7470_data *data;
....@@ -1376,7 +1275,7 @@
13761275 .driver = {
13771276 .name = "adt7470",
13781277 },
1379
- .probe = adt7470_probe,
1278
+ .probe_new = adt7470_probe,
13801279 .remove = adt7470_remove,
13811280 .id_table = adt7470_id,
13821281 .detect = adt7470_detect,