forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/hwmon/w83627hf.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * w83627hf.c - Part of lm_sensors, Linux kernel modules for hardware
34 * monitoring
....@@ -6,20 +7,6 @@
67 * and Mark Studebaker <mdsxyz123@yahoo.com>
78 * Ported to 2.6 by Bernhard C. Schrenk <clemy@clemy.org>
89 * Copyright (c) 2007 - 1012 Jean Delvare <jdelvare@suse.de>
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or
13
- * (at your option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public License
21
- * along with this program; if not, write to the Free Software
22
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2310 */
2411
2512 /*
....@@ -402,7 +389,6 @@
402389 #endif
403390 };
404391
405
-
406392 static int w83627hf_probe(struct platform_device *pdev);
407393 static int w83627hf_remove(struct platform_device *pdev);
408394
....@@ -488,28 +474,28 @@
488474 };
489475
490476 static ssize_t
491
-show_in_input(struct device *dev, struct device_attribute *devattr, char *buf)
477
+in_input_show(struct device *dev, struct device_attribute *devattr, char *buf)
492478 {
493479 int nr = to_sensor_dev_attr(devattr)->index;
494480 struct w83627hf_data *data = w83627hf_update_device(dev);
495481 return sprintf(buf, "%ld\n", (long)IN_FROM_REG(data->in[nr]));
496482 }
497483 static ssize_t
498
-show_in_min(struct device *dev, struct device_attribute *devattr, char *buf)
484
+in_min_show(struct device *dev, struct device_attribute *devattr, char *buf)
499485 {
500486 int nr = to_sensor_dev_attr(devattr)->index;
501487 struct w83627hf_data *data = w83627hf_update_device(dev);
502488 return sprintf(buf, "%ld\n", (long)IN_FROM_REG(data->in_min[nr]));
503489 }
504490 static ssize_t
505
-show_in_max(struct device *dev, struct device_attribute *devattr, char *buf)
491
+in_max_show(struct device *dev, struct device_attribute *devattr, char *buf)
506492 {
507493 int nr = to_sensor_dev_attr(devattr)->index;
508494 struct w83627hf_data *data = w83627hf_update_device(dev);
509495 return sprintf(buf, "%ld\n", (long)IN_FROM_REG(data->in_max[nr]));
510496 }
511497 static ssize_t
512
-store_in_min(struct device *dev, struct device_attribute *devattr,
498
+in_min_store(struct device *dev, struct device_attribute *devattr,
513499 const char *buf, size_t count)
514500 {
515501 int nr = to_sensor_dev_attr(devattr)->index;
....@@ -528,7 +514,7 @@
528514 return count;
529515 }
530516 static ssize_t
531
-store_in_max(struct device *dev, struct device_attribute *devattr,
517
+in_max_store(struct device *dev, struct device_attribute *devattr,
532518 const char *buf, size_t count)
533519 {
534520 int nr = to_sensor_dev_attr(devattr)->index;
....@@ -546,22 +532,31 @@
546532 mutex_unlock(&data->update_lock);
547533 return count;
548534 }
549
-#define sysfs_vin_decl(offset) \
550
-static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
551
- show_in_input, NULL, offset); \
552
-static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO|S_IWUSR, \
553
- show_in_min, store_in_min, offset); \
554
-static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO|S_IWUSR, \
555
- show_in_max, store_in_max, offset);
556535
557
-sysfs_vin_decl(1);
558
-sysfs_vin_decl(2);
559
-sysfs_vin_decl(3);
560
-sysfs_vin_decl(4);
561
-sysfs_vin_decl(5);
562
-sysfs_vin_decl(6);
563
-sysfs_vin_decl(7);
564
-sysfs_vin_decl(8);
536
+static SENSOR_DEVICE_ATTR_RO(in1_input, in_input, 1);
537
+static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1);
538
+static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1);
539
+static SENSOR_DEVICE_ATTR_RO(in2_input, in_input, 2);
540
+static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2);
541
+static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2);
542
+static SENSOR_DEVICE_ATTR_RO(in3_input, in_input, 3);
543
+static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3);
544
+static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3);
545
+static SENSOR_DEVICE_ATTR_RO(in4_input, in_input, 4);
546
+static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4);
547
+static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4);
548
+static SENSOR_DEVICE_ATTR_RO(in5_input, in_input, 5);
549
+static SENSOR_DEVICE_ATTR_RW(in5_min, in_min, 5);
550
+static SENSOR_DEVICE_ATTR_RW(in5_max, in_max, 5);
551
+static SENSOR_DEVICE_ATTR_RO(in6_input, in_input, 6);
552
+static SENSOR_DEVICE_ATTR_RW(in6_min, in_min, 6);
553
+static SENSOR_DEVICE_ATTR_RW(in6_max, in_max, 6);
554
+static SENSOR_DEVICE_ATTR_RO(in7_input, in_input, 7);
555
+static SENSOR_DEVICE_ATTR_RW(in7_min, in_min, 7);
556
+static SENSOR_DEVICE_ATTR_RW(in7_max, in_max, 7);
557
+static SENSOR_DEVICE_ATTR_RO(in8_input, in_input, 8);
558
+static SENSOR_DEVICE_ATTR_RW(in8_min, in_min, 8);
559
+static SENSOR_DEVICE_ATTR_RW(in8_max, in_max, 8);
565560
566561 /* use a different set of functions for in0 */
567562 static ssize_t show_in_0(struct w83627hf_data *data, char *buf, u8 reg)
....@@ -667,7 +662,8 @@
667662 static DEVICE_ATTR_RW(in0_max);
668663
669664 static ssize_t
670
-show_fan_input(struct device *dev, struct device_attribute *devattr, char *buf)
665
+fan_input_show(struct device *dev, struct device_attribute *devattr,
666
+ char *buf)
671667 {
672668 int nr = to_sensor_dev_attr(devattr)->index;
673669 struct w83627hf_data *data = w83627hf_update_device(dev);
....@@ -675,7 +671,7 @@
675671 (long)DIV_FROM_REG(data->fan_div[nr])));
676672 }
677673 static ssize_t
678
-show_fan_min(struct device *dev, struct device_attribute *devattr, char *buf)
674
+fan_min_show(struct device *dev, struct device_attribute *devattr, char *buf)
679675 {
680676 int nr = to_sensor_dev_attr(devattr)->index;
681677 struct w83627hf_data *data = w83627hf_update_device(dev);
....@@ -683,7 +679,7 @@
683679 (long)DIV_FROM_REG(data->fan_div[nr])));
684680 }
685681 static ssize_t
686
-store_fan_min(struct device *dev, struct device_attribute *devattr,
682
+fan_min_store(struct device *dev, struct device_attribute *devattr,
687683 const char *buf, size_t count)
688684 {
689685 int nr = to_sensor_dev_attr(devattr)->index;
....@@ -703,18 +699,16 @@
703699 mutex_unlock(&data->update_lock);
704700 return count;
705701 }
706
-#define sysfs_fan_decl(offset) \
707
-static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
708
- show_fan_input, NULL, offset - 1); \
709
-static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
710
- show_fan_min, store_fan_min, offset - 1);
711702
712
-sysfs_fan_decl(1);
713
-sysfs_fan_decl(2);
714
-sysfs_fan_decl(3);
703
+static SENSOR_DEVICE_ATTR_RO(fan1_input, fan_input, 0);
704
+static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0);
705
+static SENSOR_DEVICE_ATTR_RO(fan2_input, fan_input, 1);
706
+static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1);
707
+static SENSOR_DEVICE_ATTR_RO(fan3_input, fan_input, 2);
708
+static SENSOR_DEVICE_ATTR_RW(fan3_min, fan_min, 2);
715709
716710 static ssize_t
717
-show_temp(struct device *dev, struct device_attribute *devattr, char *buf)
711
+temp_show(struct device *dev, struct device_attribute *devattr, char *buf)
718712 {
719713 int nr = to_sensor_dev_attr(devattr)->index;
720714 struct w83627hf_data *data = w83627hf_update_device(dev);
....@@ -725,8 +719,7 @@
725719 }
726720
727721 static ssize_t
728
-show_temp_max(struct device *dev, struct device_attribute *devattr,
729
- char *buf)
722
+temp_max_show(struct device *dev, struct device_attribute *devattr, char *buf)
730723 {
731724 int nr = to_sensor_dev_attr(devattr)->index;
732725 struct w83627hf_data *data = w83627hf_update_device(dev);
....@@ -737,7 +730,7 @@
737730 }
738731
739732 static ssize_t
740
-show_temp_max_hyst(struct device *dev, struct device_attribute *devattr,
733
+temp_max_hyst_show(struct device *dev, struct device_attribute *devattr,
741734 char *buf)
742735 {
743736 int nr = to_sensor_dev_attr(devattr)->index;
....@@ -749,7 +742,7 @@
749742 }
750743
751744 static ssize_t
752
-store_temp_max(struct device *dev, struct device_attribute *devattr,
745
+temp_max_store(struct device *dev, struct device_attribute *devattr,
753746 const char *buf, size_t count)
754747 {
755748 int nr = to_sensor_dev_attr(devattr)->index;
....@@ -771,7 +764,7 @@
771764 }
772765
773766 static ssize_t
774
-store_temp_max_hyst(struct device *dev, struct device_attribute *devattr,
767
+temp_max_hyst_store(struct device *dev, struct device_attribute *devattr,
775768 const char *buf, size_t count)
776769 {
777770 int nr = to_sensor_dev_attr(devattr)->index;
....@@ -792,17 +785,15 @@
792785 return count;
793786 }
794787
795
-#define sysfs_temp_decl(offset) \
796
-static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
797
- show_temp, NULL, offset - 1); \
798
-static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO|S_IWUSR, \
799
- show_temp_max, store_temp_max, offset - 1); \
800
-static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO|S_IWUSR, \
801
- show_temp_max_hyst, store_temp_max_hyst, offset - 1);
802
-
803
-sysfs_temp_decl(1);
804
-sysfs_temp_decl(2);
805
-sysfs_temp_decl(3);
788
+static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0);
789
+static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0);
790
+static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, temp_max_hyst, 0);
791
+static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1);
792
+static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1);
793
+static SENSOR_DEVICE_ATTR_RW(temp2_max_hyst, temp_max_hyst, 1);
794
+static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2);
795
+static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2);
796
+static SENSOR_DEVICE_ATTR_RW(temp3_max_hyst, temp_max_hyst, 2);
806797
807798 static ssize_t
808799 cpu0_vid_show(struct device *dev, struct device_attribute *attr, char *buf)
....@@ -847,27 +838,27 @@
847838 static DEVICE_ATTR_RO(alarms);
848839
849840 static ssize_t
850
-show_alarm(struct device *dev, struct device_attribute *attr, char *buf)
841
+alarm_show(struct device *dev, struct device_attribute *attr, char *buf)
851842 {
852843 struct w83627hf_data *data = w83627hf_update_device(dev);
853844 int bitnr = to_sensor_dev_attr(attr)->index;
854845 return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1);
855846 }
856
-static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
857
-static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
858
-static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);
859
-static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);
860
-static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8);
861
-static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 9);
862
-static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 10);
863
-static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 16);
864
-static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 17);
865
-static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6);
866
-static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7);
867
-static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 11);
868
-static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4);
869
-static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5);
870
-static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13);
847
+static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0);
848
+static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1);
849
+static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2);
850
+static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3);
851
+static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 8);
852
+static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 9);
853
+static SENSOR_DEVICE_ATTR_RO(in6_alarm, alarm, 10);
854
+static SENSOR_DEVICE_ATTR_RO(in7_alarm, alarm, 16);
855
+static SENSOR_DEVICE_ATTR_RO(in8_alarm, alarm, 17);
856
+static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 6);
857
+static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 7);
858
+static SENSOR_DEVICE_ATTR_RO(fan3_alarm, alarm, 11);
859
+static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 4);
860
+static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 5);
861
+static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, 13);
871862
872863 static ssize_t
873864 beep_mask_show(struct device *dev, struct device_attribute *attr, char *buf)
....@@ -908,7 +899,7 @@
908899 static DEVICE_ATTR_RW(beep_mask);
909900
910901 static ssize_t
911
-show_beep(struct device *dev, struct device_attribute *attr, char *buf)
902
+beep_show(struct device *dev, struct device_attribute *attr, char *buf)
912903 {
913904 struct w83627hf_data *data = w83627hf_update_device(dev);
914905 int bitnr = to_sensor_dev_attr(attr)->index;
....@@ -916,8 +907,8 @@
916907 }
917908
918909 static ssize_t
919
-store_beep(struct device *dev, struct device_attribute *attr,
920
- const char *buf, size_t count)
910
+beep_store(struct device *dev, struct device_attribute *attr, const char *buf,
911
+ size_t count)
921912 {
922913 struct w83627hf_data *data = dev_get_drvdata(dev);
923914 int bitnr = to_sensor_dev_attr(attr)->index;
....@@ -965,41 +956,25 @@
965956 return count;
966957 }
967958
968
-static SENSOR_DEVICE_ATTR(in0_beep, S_IRUGO | S_IWUSR,
969
- show_beep, store_beep, 0);
970
-static SENSOR_DEVICE_ATTR(in1_beep, S_IRUGO | S_IWUSR,
971
- show_beep, store_beep, 1);
972
-static SENSOR_DEVICE_ATTR(in2_beep, S_IRUGO | S_IWUSR,
973
- show_beep, store_beep, 2);
974
-static SENSOR_DEVICE_ATTR(in3_beep, S_IRUGO | S_IWUSR,
975
- show_beep, store_beep, 3);
976
-static SENSOR_DEVICE_ATTR(in4_beep, S_IRUGO | S_IWUSR,
977
- show_beep, store_beep, 8);
978
-static SENSOR_DEVICE_ATTR(in5_beep, S_IRUGO | S_IWUSR,
979
- show_beep, store_beep, 9);
980
-static SENSOR_DEVICE_ATTR(in6_beep, S_IRUGO | S_IWUSR,
981
- show_beep, store_beep, 10);
982
-static SENSOR_DEVICE_ATTR(in7_beep, S_IRUGO | S_IWUSR,
983
- show_beep, store_beep, 16);
984
-static SENSOR_DEVICE_ATTR(in8_beep, S_IRUGO | S_IWUSR,
985
- show_beep, store_beep, 17);
986
-static SENSOR_DEVICE_ATTR(fan1_beep, S_IRUGO | S_IWUSR,
987
- show_beep, store_beep, 6);
988
-static SENSOR_DEVICE_ATTR(fan2_beep, S_IRUGO | S_IWUSR,
989
- show_beep, store_beep, 7);
990
-static SENSOR_DEVICE_ATTR(fan3_beep, S_IRUGO | S_IWUSR,
991
- show_beep, store_beep, 11);
992
-static SENSOR_DEVICE_ATTR(temp1_beep, S_IRUGO | S_IWUSR,
993
- show_beep, store_beep, 4);
994
-static SENSOR_DEVICE_ATTR(temp2_beep, S_IRUGO | S_IWUSR,
995
- show_beep, store_beep, 5);
996
-static SENSOR_DEVICE_ATTR(temp3_beep, S_IRUGO | S_IWUSR,
997
- show_beep, store_beep, 13);
998
-static SENSOR_DEVICE_ATTR(beep_enable, S_IRUGO | S_IWUSR,
999
- show_beep, store_beep, 15);
959
+static SENSOR_DEVICE_ATTR_RW(in0_beep, beep, 0);
960
+static SENSOR_DEVICE_ATTR_RW(in1_beep, beep, 1);
961
+static SENSOR_DEVICE_ATTR_RW(in2_beep, beep, 2);
962
+static SENSOR_DEVICE_ATTR_RW(in3_beep, beep, 3);
963
+static SENSOR_DEVICE_ATTR_RW(in4_beep, beep, 8);
964
+static SENSOR_DEVICE_ATTR_RW(in5_beep, beep, 9);
965
+static SENSOR_DEVICE_ATTR_RW(in6_beep, beep, 10);
966
+static SENSOR_DEVICE_ATTR_RW(in7_beep, beep, 16);
967
+static SENSOR_DEVICE_ATTR_RW(in8_beep, beep, 17);
968
+static SENSOR_DEVICE_ATTR_RW(fan1_beep, beep, 6);
969
+static SENSOR_DEVICE_ATTR_RW(fan2_beep, beep, 7);
970
+static SENSOR_DEVICE_ATTR_RW(fan3_beep, beep, 11);
971
+static SENSOR_DEVICE_ATTR_RW(temp1_beep, beep, 4);
972
+static SENSOR_DEVICE_ATTR_RW(temp2_beep, beep, 5);
973
+static SENSOR_DEVICE_ATTR_RW(temp3_beep, beep, 13);
974
+static SENSOR_DEVICE_ATTR_RW(beep_enable, beep, 15);
1000975
1001976 static ssize_t
1002
-show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf)
977
+fan_div_show(struct device *dev, struct device_attribute *devattr, char *buf)
1003978 {
1004979 int nr = to_sensor_dev_attr(devattr)->index;
1005980 struct w83627hf_data *data = w83627hf_update_device(dev);
....@@ -1013,7 +988,7 @@
1013988 * because the divisor changed.
1014989 */
1015990 static ssize_t
1016
-store_fan_div(struct device *dev, struct device_attribute *devattr,
991
+fan_div_store(struct device *dev, struct device_attribute *devattr,
1017992 const char *buf, size_t count)
1018993 {
1019994 int nr = to_sensor_dev_attr(devattr)->index;
....@@ -1053,15 +1028,12 @@
10531028 return count;
10541029 }
10551030
1056
-static SENSOR_DEVICE_ATTR(fan1_div, S_IRUGO|S_IWUSR,
1057
- show_fan_div, store_fan_div, 0);
1058
-static SENSOR_DEVICE_ATTR(fan2_div, S_IRUGO|S_IWUSR,
1059
- show_fan_div, store_fan_div, 1);
1060
-static SENSOR_DEVICE_ATTR(fan3_div, S_IRUGO|S_IWUSR,
1061
- show_fan_div, store_fan_div, 2);
1031
+static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0);
1032
+static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1);
1033
+static SENSOR_DEVICE_ATTR_RW(fan3_div, fan_div, 2);
10621034
10631035 static ssize_t
1064
-show_pwm(struct device *dev, struct device_attribute *devattr, char *buf)
1036
+pwm_show(struct device *dev, struct device_attribute *devattr, char *buf)
10651037 {
10661038 int nr = to_sensor_dev_attr(devattr)->index;
10671039 struct w83627hf_data *data = w83627hf_update_device(dev);
....@@ -1069,7 +1041,7 @@
10691041 }
10701042
10711043 static ssize_t
1072
-store_pwm(struct device *dev, struct device_attribute *devattr,
1044
+pwm_store(struct device *dev, struct device_attribute *devattr,
10731045 const char *buf, size_t count)
10741046 {
10751047 int nr = to_sensor_dev_attr(devattr)->index;
....@@ -1102,12 +1074,13 @@
11021074 return count;
11031075 }
11041076
1105
-static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 0);
1106
-static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 1);
1107
-static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO|S_IWUSR, show_pwm, store_pwm, 2);
1077
+static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0);
1078
+static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1);
1079
+static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, 2);
11081080
11091081 static ssize_t
1110
-show_pwm_enable(struct device *dev, struct device_attribute *devattr, char *buf)
1082
+pwm_enable_show(struct device *dev, struct device_attribute *devattr,
1083
+ char *buf)
11111084 {
11121085 int nr = to_sensor_dev_attr(devattr)->index;
11131086 struct w83627hf_data *data = w83627hf_update_device(dev);
....@@ -1115,8 +1088,8 @@
11151088 }
11161089
11171090 static ssize_t
1118
-store_pwm_enable(struct device *dev, struct device_attribute *devattr,
1119
- const char *buf, size_t count)
1091
+pwm_enable_store(struct device *dev, struct device_attribute *devattr,
1092
+ const char *buf, size_t count)
11201093 {
11211094 int nr = to_sensor_dev_attr(devattr)->index;
11221095 struct w83627hf_data *data = dev_get_drvdata(dev);
....@@ -1140,15 +1113,12 @@
11401113 return count;
11411114 }
11421115
1143
-static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
1144
- store_pwm_enable, 0);
1145
-static SENSOR_DEVICE_ATTR(pwm2_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
1146
- store_pwm_enable, 1);
1147
-static SENSOR_DEVICE_ATTR(pwm3_enable, S_IRUGO|S_IWUSR, show_pwm_enable,
1148
- store_pwm_enable, 2);
1116
+static SENSOR_DEVICE_ATTR_RW(pwm1_enable, pwm_enable, 0);
1117
+static SENSOR_DEVICE_ATTR_RW(pwm2_enable, pwm_enable, 1);
1118
+static SENSOR_DEVICE_ATTR_RW(pwm3_enable, pwm_enable, 2);
11491119
11501120 static ssize_t
1151
-show_pwm_freq(struct device *dev, struct device_attribute *devattr, char *buf)
1121
+pwm_freq_show(struct device *dev, struct device_attribute *devattr, char *buf)
11521122 {
11531123 int nr = to_sensor_dev_attr(devattr)->index;
11541124 struct w83627hf_data *data = w83627hf_update_device(dev);
....@@ -1161,7 +1131,7 @@
11611131 }
11621132
11631133 static ssize_t
1164
-store_pwm_freq(struct device *dev, struct device_attribute *devattr,
1134
+pwm_freq_store(struct device *dev, struct device_attribute *devattr,
11651135 const char *buf, size_t count)
11661136 {
11671137 int nr = to_sensor_dev_attr(devattr)->index;
....@@ -1192,15 +1162,12 @@
11921162 return count;
11931163 }
11941164
1195
-static SENSOR_DEVICE_ATTR(pwm1_freq, S_IRUGO|S_IWUSR,
1196
- show_pwm_freq, store_pwm_freq, 0);
1197
-static SENSOR_DEVICE_ATTR(pwm2_freq, S_IRUGO|S_IWUSR,
1198
- show_pwm_freq, store_pwm_freq, 1);
1199
-static SENSOR_DEVICE_ATTR(pwm3_freq, S_IRUGO|S_IWUSR,
1200
- show_pwm_freq, store_pwm_freq, 2);
1165
+static SENSOR_DEVICE_ATTR_RW(pwm1_freq, pwm_freq, 0);
1166
+static SENSOR_DEVICE_ATTR_RW(pwm2_freq, pwm_freq, 1);
1167
+static SENSOR_DEVICE_ATTR_RW(pwm3_freq, pwm_freq, 2);
12011168
12021169 static ssize_t
1203
-show_temp_type(struct device *dev, struct device_attribute *devattr,
1170
+temp_type_show(struct device *dev, struct device_attribute *devattr,
12041171 char *buf)
12051172 {
12061173 int nr = to_sensor_dev_attr(devattr)->index;
....@@ -1209,7 +1176,7 @@
12091176 }
12101177
12111178 static ssize_t
1212
-store_temp_type(struct device *dev, struct device_attribute *devattr,
1179
+temp_type_store(struct device *dev, struct device_attribute *devattr,
12131180 const char *buf, size_t count)
12141181 {
12151182 int nr = to_sensor_dev_attr(devattr)->index;
....@@ -1246,7 +1213,7 @@
12461213 case W83781D_DEFAULT_BETA:
12471214 dev_warn(dev, "Sensor type %d is deprecated, please use 4 "
12481215 "instead\n", W83781D_DEFAULT_BETA);
1249
- /* fall through */
1216
+ fallthrough;
12501217 case 4: /* thermistor */
12511218 tmp = w83627hf_read_value(data, W83781D_REG_SCFG1);
12521219 w83627hf_write_value(data, W83781D_REG_SCFG1,
....@@ -1264,13 +1231,9 @@
12641231 return count;
12651232 }
12661233
1267
-#define sysfs_temp_type(offset) \
1268
-static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO | S_IWUSR, \
1269
- show_temp_type, store_temp_type, offset - 1);
1270
-
1271
-sysfs_temp_type(1);
1272
-sysfs_temp_type(2);
1273
-sysfs_temp_type(3);
1234
+static SENSOR_DEVICE_ATTR_RW(temp1_type, temp_type, 0);
1235
+static SENSOR_DEVICE_ATTR_RW(temp2_type, temp_type, 1);
1236
+static SENSOR_DEVICE_ATTR_RW(temp3_type, temp_type, 2);
12741237
12751238 static ssize_t
12761239 name_show(struct device *dev, struct device_attribute *devattr, char *buf)
....@@ -1604,7 +1567,6 @@
16041567
16051568 return 0;
16061569 }
1607
-
16081570
16091571 /* Registers 0x50-0x5f are banked */
16101572 static inline void w83627hf_set_bank(struct w83627hf_data *data, u16 reg)