hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwmon/adm1026.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * adm1026.c - Part of lm_sensors, Linux kernel modules for hardware
34 * monitoring
....@@ -6,21 +7,7 @@
67 *
78 * Chip details at:
89 *
9
- * <http://www.onsemi.com/PowerSolutions/product.do?id=ADM1026>
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License as published by
13
- * the Free Software Foundation; either version 2 of the License, or
14
- * (at your option) any later version.
15
- *
16
- * This program is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU General Public License
22
- * along with this program; if not, write to the Free Software
23
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
10
+ * <https://www.onsemi.com/PowerSolutions/product.do?id=ADM1026>
2411 */
2512
2613 #include <linux/module.h>
....@@ -477,24 +464,24 @@
477464 return data;
478465 }
479466
480
-static ssize_t show_in(struct device *dev, struct device_attribute *attr,
481
- char *buf)
467
+static ssize_t in_show(struct device *dev, struct device_attribute *attr,
468
+ char *buf)
482469 {
483470 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
484471 int nr = sensor_attr->index;
485472 struct adm1026_data *data = adm1026_update_device(dev);
486473 return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in[nr]));
487474 }
488
-static ssize_t show_in_min(struct device *dev, struct device_attribute *attr,
489
- char *buf)
475
+static ssize_t in_min_show(struct device *dev, struct device_attribute *attr,
476
+ char *buf)
490477 {
491478 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
492479 int nr = sensor_attr->index;
493480 struct adm1026_data *data = adm1026_update_device(dev);
494481 return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_min[nr]));
495482 }
496
-static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
497
- const char *buf, size_t count)
483
+static ssize_t in_min_store(struct device *dev, struct device_attribute *attr,
484
+ const char *buf, size_t count)
498485 {
499486 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
500487 int nr = sensor_attr->index;
....@@ -513,16 +500,16 @@
513500 mutex_unlock(&data->update_lock);
514501 return count;
515502 }
516
-static ssize_t show_in_max(struct device *dev, struct device_attribute *attr,
517
- char *buf)
503
+static ssize_t in_max_show(struct device *dev, struct device_attribute *attr,
504
+ char *buf)
518505 {
519506 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
520507 int nr = sensor_attr->index;
521508 struct adm1026_data *data = adm1026_update_device(dev);
522509 return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_max[nr]));
523510 }
524
-static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
525
- const char *buf, size_t count)
511
+static ssize_t in_max_store(struct device *dev, struct device_attribute *attr,
512
+ const char *buf, size_t count)
526513 {
527514 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
528515 int nr = sensor_attr->index;
....@@ -542,48 +529,72 @@
542529 return count;
543530 }
544531
545
-#define in_reg(offset) \
546
-static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in, \
547
- NULL, offset); \
548
-static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
549
- show_in_min, set_in_min, offset); \
550
-static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
551
- show_in_max, set_in_max, offset);
532
+static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0);
533
+static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0);
534
+static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0);
535
+static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1);
536
+static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1);
537
+static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1);
538
+static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2);
539
+static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2);
540
+static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2);
541
+static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3);
542
+static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3);
543
+static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3);
544
+static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4);
545
+static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4);
546
+static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4);
547
+static SENSOR_DEVICE_ATTR_RO(in5_input, in, 5);
548
+static SENSOR_DEVICE_ATTR_RW(in5_min, in_min, 5);
549
+static SENSOR_DEVICE_ATTR_RW(in5_max, in_max, 5);
550
+static SENSOR_DEVICE_ATTR_RO(in6_input, in, 6);
551
+static SENSOR_DEVICE_ATTR_RW(in6_min, in_min, 6);
552
+static SENSOR_DEVICE_ATTR_RW(in6_max, in_max, 6);
553
+static SENSOR_DEVICE_ATTR_RO(in7_input, in, 7);
554
+static SENSOR_DEVICE_ATTR_RW(in7_min, in_min, 7);
555
+static SENSOR_DEVICE_ATTR_RW(in7_max, in_max, 7);
556
+static SENSOR_DEVICE_ATTR_RO(in8_input, in, 8);
557
+static SENSOR_DEVICE_ATTR_RW(in8_min, in_min, 8);
558
+static SENSOR_DEVICE_ATTR_RW(in8_max, in_max, 8);
559
+static SENSOR_DEVICE_ATTR_RO(in9_input, in, 9);
560
+static SENSOR_DEVICE_ATTR_RW(in9_min, in_min, 9);
561
+static SENSOR_DEVICE_ATTR_RW(in9_max, in_max, 9);
562
+static SENSOR_DEVICE_ATTR_RO(in10_input, in, 10);
563
+static SENSOR_DEVICE_ATTR_RW(in10_min, in_min, 10);
564
+static SENSOR_DEVICE_ATTR_RW(in10_max, in_max, 10);
565
+static SENSOR_DEVICE_ATTR_RO(in11_input, in, 11);
566
+static SENSOR_DEVICE_ATTR_RW(in11_min, in_min, 11);
567
+static SENSOR_DEVICE_ATTR_RW(in11_max, in_max, 11);
568
+static SENSOR_DEVICE_ATTR_RO(in12_input, in, 12);
569
+static SENSOR_DEVICE_ATTR_RW(in12_min, in_min, 12);
570
+static SENSOR_DEVICE_ATTR_RW(in12_max, in_max, 12);
571
+static SENSOR_DEVICE_ATTR_RO(in13_input, in, 13);
572
+static SENSOR_DEVICE_ATTR_RW(in13_min, in_min, 13);
573
+static SENSOR_DEVICE_ATTR_RW(in13_max, in_max, 13);
574
+static SENSOR_DEVICE_ATTR_RO(in14_input, in, 14);
575
+static SENSOR_DEVICE_ATTR_RW(in14_min, in_min, 14);
576
+static SENSOR_DEVICE_ATTR_RW(in14_max, in_max, 14);
577
+static SENSOR_DEVICE_ATTR_RO(in15_input, in, 15);
578
+static SENSOR_DEVICE_ATTR_RW(in15_min, in_min, 15);
579
+static SENSOR_DEVICE_ATTR_RW(in15_max, in_max, 15);
552580
553
-
554
-in_reg(0);
555
-in_reg(1);
556
-in_reg(2);
557
-in_reg(3);
558
-in_reg(4);
559
-in_reg(5);
560
-in_reg(6);
561
-in_reg(7);
562
-in_reg(8);
563
-in_reg(9);
564
-in_reg(10);
565
-in_reg(11);
566
-in_reg(12);
567
-in_reg(13);
568
-in_reg(14);
569
-in_reg(15);
570
-
571
-static ssize_t show_in16(struct device *dev, struct device_attribute *attr,
581
+static ssize_t in16_show(struct device *dev, struct device_attribute *attr,
572582 char *buf)
573583 {
574584 struct adm1026_data *data = adm1026_update_device(dev);
575585 return sprintf(buf, "%d\n", INS_FROM_REG(16, data->in[16]) -
576586 NEG12_OFFSET);
577587 }
578
-static ssize_t show_in16_min(struct device *dev, struct device_attribute *attr,
579
- char *buf)
588
+static ssize_t in16_min_show(struct device *dev,
589
+ struct device_attribute *attr, char *buf)
580590 {
581591 struct adm1026_data *data = adm1026_update_device(dev);
582592 return sprintf(buf, "%d\n", INS_FROM_REG(16, data->in_min[16])
583593 - NEG12_OFFSET);
584594 }
585
-static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr,
586
- const char *buf, size_t count)
595
+static ssize_t in16_min_store(struct device *dev,
596
+ struct device_attribute *attr, const char *buf,
597
+ size_t count)
587598 {
588599 struct adm1026_data *data = dev_get_drvdata(dev);
589600 struct i2c_client *client = data->client;
....@@ -603,15 +614,16 @@
603614 mutex_unlock(&data->update_lock);
604615 return count;
605616 }
606
-static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr,
607
- char *buf)
617
+static ssize_t in16_max_show(struct device *dev,
618
+ struct device_attribute *attr, char *buf)
608619 {
609620 struct adm1026_data *data = adm1026_update_device(dev);
610621 return sprintf(buf, "%d\n", INS_FROM_REG(16, data->in_max[16])
611622 - NEG12_OFFSET);
612623 }
613
-static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr,
614
- const char *buf, size_t count)
624
+static ssize_t in16_max_store(struct device *dev,
625
+ struct device_attribute *attr, const char *buf,
626
+ size_t count)
615627 {
616628 struct adm1026_data *data = dev_get_drvdata(dev);
617629 struct i2c_client *client = data->client;
....@@ -632,17 +644,14 @@
632644 return count;
633645 }
634646
635
-static SENSOR_DEVICE_ATTR(in16_input, S_IRUGO, show_in16, NULL, 16);
636
-static SENSOR_DEVICE_ATTR(in16_min, S_IRUGO | S_IWUSR, show_in16_min,
637
- set_in16_min, 16);
638
-static SENSOR_DEVICE_ATTR(in16_max, S_IRUGO | S_IWUSR, show_in16_max,
639
- set_in16_max, 16);
640
-
647
+static SENSOR_DEVICE_ATTR_RO(in16_input, in16, 16);
648
+static SENSOR_DEVICE_ATTR_RW(in16_min, in16_min, 16);
649
+static SENSOR_DEVICE_ATTR_RW(in16_max, in16_max, 16);
641650
642651 /* Now add fan read/write functions */
643652
644
-static ssize_t show_fan(struct device *dev, struct device_attribute *attr,
645
- char *buf)
653
+static ssize_t fan_show(struct device *dev, struct device_attribute *attr,
654
+ char *buf)
646655 {
647656 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
648657 int nr = sensor_attr->index;
....@@ -650,8 +659,8 @@
650659 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr],
651660 data->fan_div[nr]));
652661 }
653
-static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr,
654
- char *buf)
662
+static ssize_t fan_min_show(struct device *dev, struct device_attribute *attr,
663
+ char *buf)
655664 {
656665 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
657666 int nr = sensor_attr->index;
....@@ -659,8 +668,9 @@
659668 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr],
660669 data->fan_div[nr]));
661670 }
662
-static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
663
- const char *buf, size_t count)
671
+static ssize_t fan_min_store(struct device *dev,
672
+ struct device_attribute *attr, const char *buf,
673
+ size_t count)
664674 {
665675 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
666676 int nr = sensor_attr->index;
....@@ -681,20 +691,22 @@
681691 return count;
682692 }
683693
684
-#define fan_offset(offset) \
685
-static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \
686
- offset - 1); \
687
-static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
688
- show_fan_min, set_fan_min, offset - 1);
689
-
690
-fan_offset(1);
691
-fan_offset(2);
692
-fan_offset(3);
693
-fan_offset(4);
694
-fan_offset(5);
695
-fan_offset(6);
696
-fan_offset(7);
697
-fan_offset(8);
694
+static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0);
695
+static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0);
696
+static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1);
697
+static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1);
698
+static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 2);
699
+static SENSOR_DEVICE_ATTR_RW(fan3_min, fan_min, 2);
700
+static SENSOR_DEVICE_ATTR_RO(fan4_input, fan, 3);
701
+static SENSOR_DEVICE_ATTR_RW(fan4_min, fan_min, 3);
702
+static SENSOR_DEVICE_ATTR_RO(fan5_input, fan, 4);
703
+static SENSOR_DEVICE_ATTR_RW(fan5_min, fan_min, 4);
704
+static SENSOR_DEVICE_ATTR_RO(fan6_input, fan, 5);
705
+static SENSOR_DEVICE_ATTR_RW(fan6_min, fan_min, 5);
706
+static SENSOR_DEVICE_ATTR_RO(fan7_input, fan, 6);
707
+static SENSOR_DEVICE_ATTR_RW(fan7_min, fan_min, 6);
708
+static SENSOR_DEVICE_ATTR_RO(fan8_input, fan, 7);
709
+static SENSOR_DEVICE_ATTR_RW(fan8_min, fan_min, 7);
698710
699711 /* Adjust fan_min to account for new fan divisor */
700712 static void fixup_fan_min(struct device *dev, int fan, int old_div)
....@@ -715,16 +727,17 @@
715727 }
716728
717729 /* Now add fan_div read/write functions */
718
-static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr,
719
- char *buf)
730
+static ssize_t fan_div_show(struct device *dev, struct device_attribute *attr,
731
+ char *buf)
720732 {
721733 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
722734 int nr = sensor_attr->index;
723735 struct adm1026_data *data = adm1026_update_device(dev);
724736 return sprintf(buf, "%d\n", data->fan_div[nr]);
725737 }
726
-static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
727
- const char *buf, size_t count)
738
+static ssize_t fan_div_store(struct device *dev,
739
+ struct device_attribute *attr, const char *buf,
740
+ size_t count)
728741 {
729742 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
730743 int nr = sensor_attr->index;
....@@ -765,38 +778,35 @@
765778 return count;
766779 }
767780
768
-#define fan_offset_div(offset) \
769
-static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
770
- show_fan_div, set_fan_div, offset - 1);
771
-
772
-fan_offset_div(1);
773
-fan_offset_div(2);
774
-fan_offset_div(3);
775
-fan_offset_div(4);
776
-fan_offset_div(5);
777
-fan_offset_div(6);
778
-fan_offset_div(7);
779
-fan_offset_div(8);
781
+static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0);
782
+static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1);
783
+static SENSOR_DEVICE_ATTR_RW(fan3_div, fan_div, 2);
784
+static SENSOR_DEVICE_ATTR_RW(fan4_div, fan_div, 3);
785
+static SENSOR_DEVICE_ATTR_RW(fan5_div, fan_div, 4);
786
+static SENSOR_DEVICE_ATTR_RW(fan6_div, fan_div, 5);
787
+static SENSOR_DEVICE_ATTR_RW(fan7_div, fan_div, 6);
788
+static SENSOR_DEVICE_ATTR_RW(fan8_div, fan_div, 7);
780789
781790 /* Temps */
782
-static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
783
- char *buf)
791
+static ssize_t temp_show(struct device *dev, struct device_attribute *attr,
792
+ char *buf)
784793 {
785794 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
786795 int nr = sensor_attr->index;
787796 struct adm1026_data *data = adm1026_update_device(dev);
788797 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr]));
789798 }
790
-static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr,
791
- char *buf)
799
+static ssize_t temp_min_show(struct device *dev,
800
+ struct device_attribute *attr, char *buf)
792801 {
793802 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
794803 int nr = sensor_attr->index;
795804 struct adm1026_data *data = adm1026_update_device(dev);
796805 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[nr]));
797806 }
798
-static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
799
- const char *buf, size_t count)
807
+static ssize_t temp_min_store(struct device *dev,
808
+ struct device_attribute *attr, const char *buf,
809
+ size_t count)
800810 {
801811 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
802812 int nr = sensor_attr->index;
....@@ -816,16 +826,17 @@
816826 mutex_unlock(&data->update_lock);
817827 return count;
818828 }
819
-static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,
820
- char *buf)
829
+static ssize_t temp_max_show(struct device *dev,
830
+ struct device_attribute *attr, char *buf)
821831 {
822832 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
823833 int nr = sensor_attr->index;
824834 struct adm1026_data *data = adm1026_update_device(dev);
825835 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[nr]));
826836 }
827
-static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
828
- const char *buf, size_t count)
837
+static ssize_t temp_max_store(struct device *dev,
838
+ struct device_attribute *attr, const char *buf,
839
+ size_t count)
829840 {
830841 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
831842 int nr = sensor_attr->index;
....@@ -846,30 +857,27 @@
846857 return count;
847858 }
848859
849
-#define temp_reg(offset) \
850
-static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \
851
- NULL, offset - 1); \
852
-static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
853
- show_temp_min, set_temp_min, offset - 1); \
854
-static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
855
- show_temp_max, set_temp_max, offset - 1);
860
+static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0);
861
+static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0);
862
+static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0);
863
+static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1);
864
+static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1);
865
+static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1);
866
+static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2);
867
+static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2);
868
+static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2);
856869
857
-
858
-temp_reg(1);
859
-temp_reg(2);
860
-temp_reg(3);
861
-
862
-static ssize_t show_temp_offset(struct device *dev,
863
- struct device_attribute *attr, char *buf)
870
+static ssize_t temp_offset_show(struct device *dev,
871
+ struct device_attribute *attr, char *buf)
864872 {
865873 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
866874 int nr = sensor_attr->index;
867875 struct adm1026_data *data = adm1026_update_device(dev);
868876 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_offset[nr]));
869877 }
870
-static ssize_t set_temp_offset(struct device *dev,
871
- struct device_attribute *attr, const char *buf,
872
- size_t count)
878
+static ssize_t temp_offset_store(struct device *dev,
879
+ struct device_attribute *attr,
880
+ const char *buf, size_t count)
873881 {
874882 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
875883 int nr = sensor_attr->index;
....@@ -890,16 +898,13 @@
890898 return count;
891899 }
892900
893
-#define temp_offset_reg(offset) \
894
-static SENSOR_DEVICE_ATTR(temp##offset##_offset, S_IRUGO | S_IWUSR, \
895
- show_temp_offset, set_temp_offset, offset - 1);
901
+static SENSOR_DEVICE_ATTR_RW(temp1_offset, temp_offset, 0);
902
+static SENSOR_DEVICE_ATTR_RW(temp2_offset, temp_offset, 1);
903
+static SENSOR_DEVICE_ATTR_RW(temp3_offset, temp_offset, 2);
896904
897
-temp_offset_reg(1);
898
-temp_offset_reg(2);
899
-temp_offset_reg(3);
900
-
901
-static ssize_t show_temp_auto_point1_temp_hyst(struct device *dev,
902
- struct device_attribute *attr, char *buf)
905
+static ssize_t temp_auto_point1_temp_hyst_show(struct device *dev,
906
+ struct device_attribute *attr,
907
+ char *buf)
903908 {
904909 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
905910 int nr = sensor_attr->index;
....@@ -907,8 +912,9 @@
907912 return sprintf(buf, "%d\n", TEMP_FROM_REG(
908913 ADM1026_FAN_ACTIVATION_TEMP_HYST + data->temp_tmin[nr]));
909914 }
910
-static ssize_t show_temp_auto_point2_temp(struct device *dev,
911
- struct device_attribute *attr, char *buf)
915
+static ssize_t temp_auto_point2_temp_show(struct device *dev,
916
+ struct device_attribute *attr,
917
+ char *buf)
912918 {
913919 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
914920 int nr = sensor_attr->index;
....@@ -916,16 +922,18 @@
916922 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_tmin[nr] +
917923 ADM1026_FAN_CONTROL_TEMP_RANGE));
918924 }
919
-static ssize_t show_temp_auto_point1_temp(struct device *dev,
920
- struct device_attribute *attr, char *buf)
925
+static ssize_t temp_auto_point1_temp_show(struct device *dev,
926
+ struct device_attribute *attr,
927
+ char *buf)
921928 {
922929 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
923930 int nr = sensor_attr->index;
924931 struct adm1026_data *data = adm1026_update_device(dev);
925932 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_tmin[nr]));
926933 }
927
-static ssize_t set_temp_auto_point1_temp(struct device *dev,
928
- struct device_attribute *attr, const char *buf, size_t count)
934
+static ssize_t temp_auto_point1_temp_store(struct device *dev,
935
+ struct device_attribute *attr,
936
+ const char *buf, size_t count)
929937 {
930938 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
931939 int nr = sensor_attr->index;
....@@ -946,18 +954,18 @@
946954 return count;
947955 }
948956
949
-#define temp_auto_point(offset) \
950
-static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp, \
951
- S_IRUGO | S_IWUSR, show_temp_auto_point1_temp, \
952
- set_temp_auto_point1_temp, offset - 1); \
953
-static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp_hyst, S_IRUGO,\
954
- show_temp_auto_point1_temp_hyst, NULL, offset - 1); \
955
-static SENSOR_DEVICE_ATTR(temp##offset##_auto_point2_temp, S_IRUGO, \
956
- show_temp_auto_point2_temp, NULL, offset - 1);
957
-
958
-temp_auto_point(1);
959
-temp_auto_point(2);
960
-temp_auto_point(3);
957
+static SENSOR_DEVICE_ATTR_RW(temp1_auto_point1_temp, temp_auto_point1_temp, 0);
958
+static SENSOR_DEVICE_ATTR_RO(temp1_auto_point1_temp_hyst,
959
+ temp_auto_point1_temp_hyst, 0);
960
+static SENSOR_DEVICE_ATTR_RO(temp1_auto_point2_temp, temp_auto_point2_temp, 0);
961
+static SENSOR_DEVICE_ATTR_RW(temp2_auto_point1_temp, temp_auto_point1_temp, 1);
962
+static SENSOR_DEVICE_ATTR_RO(temp2_auto_point1_temp_hyst,
963
+ temp_auto_point1_temp_hyst, 1);
964
+static SENSOR_DEVICE_ATTR_RO(temp2_auto_point2_temp, temp_auto_point2_temp, 1);
965
+static SENSOR_DEVICE_ATTR_RW(temp3_auto_point1_temp, temp_auto_point1_temp, 2);
966
+static SENSOR_DEVICE_ATTR_RO(temp3_auto_point1_temp_hyst,
967
+ temp_auto_point1_temp_hyst, 2);
968
+static SENSOR_DEVICE_ATTR_RO(temp3_auto_point2_temp, temp_auto_point2_temp, 2);
961969
962970 static ssize_t show_temp_crit_enable(struct device *dev,
963971 struct device_attribute *attr, char *buf)
....@@ -988,24 +996,24 @@
988996 return count;
989997 }
990998
991
-#define temp_crit_enable(offset) \
992
-static DEVICE_ATTR(temp##offset##_crit_enable, S_IRUGO | S_IWUSR, \
993
- show_temp_crit_enable, set_temp_crit_enable);
999
+static DEVICE_ATTR(temp1_crit_enable, 0644, show_temp_crit_enable,
1000
+ set_temp_crit_enable);
1001
+static DEVICE_ATTR(temp2_crit_enable, 0644, show_temp_crit_enable,
1002
+ set_temp_crit_enable);
1003
+static DEVICE_ATTR(temp3_crit_enable, 0644, show_temp_crit_enable,
1004
+ set_temp_crit_enable);
9941005
995
-temp_crit_enable(1);
996
-temp_crit_enable(2);
997
-temp_crit_enable(3);
998
-
999
-static ssize_t show_temp_crit(struct device *dev,
1000
- struct device_attribute *attr, char *buf)
1006
+static ssize_t temp_crit_show(struct device *dev,
1007
+ struct device_attribute *attr, char *buf)
10011008 {
10021009 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
10031010 int nr = sensor_attr->index;
10041011 struct adm1026_data *data = adm1026_update_device(dev);
10051012 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_crit[nr]));
10061013 }
1007
-static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
1008
- const char *buf, size_t count)
1014
+static ssize_t temp_crit_store(struct device *dev,
1015
+ struct device_attribute *attr, const char *buf,
1016
+ size_t count)
10091017 {
10101018 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
10111019 int nr = sensor_attr->index;
....@@ -1026,13 +1034,9 @@
10261034 return count;
10271035 }
10281036
1029
-#define temp_crit_reg(offset) \
1030
-static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IRUGO | S_IWUSR, \
1031
- show_temp_crit, set_temp_crit, offset - 1);
1032
-
1033
-temp_crit_reg(1);
1034
-temp_crit_reg(2);
1035
-temp_crit_reg(3);
1037
+static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp_crit, 0);
1038
+static SENSOR_DEVICE_ATTR_RW(temp2_crit, temp_crit, 1);
1039
+static SENSOR_DEVICE_ATTR_RW(temp3_crit, temp_crit, 2);
10361040
10371041 static ssize_t analog_out_show(struct device *dev,
10381042 struct device_attribute *attr, char *buf)
....@@ -1110,7 +1114,7 @@
11101114
11111115 static DEVICE_ATTR_RO(alarms);
11121116
1113
-static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
1117
+static ssize_t alarm_show(struct device *dev, struct device_attribute *attr,
11141118 char *buf)
11151119 {
11161120 struct adm1026_data *data = adm1026_update_device(dev);
....@@ -1118,34 +1122,34 @@
11181122 return sprintf(buf, "%ld\n", (data->alarms >> bitnr) & 1);
11191123 }
11201124
1121
-static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 0);
1122
-static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 1);
1123
-static SENSOR_DEVICE_ATTR(in9_alarm, S_IRUGO, show_alarm, NULL, 1);
1124
-static SENSOR_DEVICE_ATTR(in11_alarm, S_IRUGO, show_alarm, NULL, 2);
1125
-static SENSOR_DEVICE_ATTR(in12_alarm, S_IRUGO, show_alarm, NULL, 3);
1126
-static SENSOR_DEVICE_ATTR(in13_alarm, S_IRUGO, show_alarm, NULL, 4);
1127
-static SENSOR_DEVICE_ATTR(in14_alarm, S_IRUGO, show_alarm, NULL, 5);
1128
-static SENSOR_DEVICE_ATTR(in15_alarm, S_IRUGO, show_alarm, NULL, 6);
1129
-static SENSOR_DEVICE_ATTR(in16_alarm, S_IRUGO, show_alarm, NULL, 7);
1130
-static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 8);
1131
-static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 9);
1132
-static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 10);
1133
-static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 11);
1134
-static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 12);
1135
-static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 13);
1136
-static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 14);
1137
-static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 15);
1138
-static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 16);
1139
-static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 17);
1140
-static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 18);
1141
-static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, 19);
1142
-static SENSOR_DEVICE_ATTR(fan5_alarm, S_IRUGO, show_alarm, NULL, 20);
1143
-static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_alarm, NULL, 21);
1144
-static SENSOR_DEVICE_ATTR(fan7_alarm, S_IRUGO, show_alarm, NULL, 22);
1145
-static SENSOR_DEVICE_ATTR(fan8_alarm, S_IRUGO, show_alarm, NULL, 23);
1146
-static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 24);
1147
-static SENSOR_DEVICE_ATTR(in10_alarm, S_IRUGO, show_alarm, NULL, 25);
1148
-static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 26);
1125
+static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 0);
1126
+static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, 1);
1127
+static SENSOR_DEVICE_ATTR_RO(in9_alarm, alarm, 1);
1128
+static SENSOR_DEVICE_ATTR_RO(in11_alarm, alarm, 2);
1129
+static SENSOR_DEVICE_ATTR_RO(in12_alarm, alarm, 3);
1130
+static SENSOR_DEVICE_ATTR_RO(in13_alarm, alarm, 4);
1131
+static SENSOR_DEVICE_ATTR_RO(in14_alarm, alarm, 5);
1132
+static SENSOR_DEVICE_ATTR_RO(in15_alarm, alarm, 6);
1133
+static SENSOR_DEVICE_ATTR_RO(in16_alarm, alarm, 7);
1134
+static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 8);
1135
+static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 9);
1136
+static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 10);
1137
+static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 11);
1138
+static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 12);
1139
+static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 13);
1140
+static SENSOR_DEVICE_ATTR_RO(in6_alarm, alarm, 14);
1141
+static SENSOR_DEVICE_ATTR_RO(in7_alarm, alarm, 15);
1142
+static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 16);
1143
+static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 17);
1144
+static SENSOR_DEVICE_ATTR_RO(fan3_alarm, alarm, 18);
1145
+static SENSOR_DEVICE_ATTR_RO(fan4_alarm, alarm, 19);
1146
+static SENSOR_DEVICE_ATTR_RO(fan5_alarm, alarm, 20);
1147
+static SENSOR_DEVICE_ATTR_RO(fan6_alarm, alarm, 21);
1148
+static SENSOR_DEVICE_ATTR_RO(fan7_alarm, alarm, 22);
1149
+static SENSOR_DEVICE_ATTR_RO(fan8_alarm, alarm, 23);
1150
+static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 24);
1151
+static SENSOR_DEVICE_ATTR_RO(in10_alarm, alarm, 25);
1152
+static SENSOR_DEVICE_ATTR_RO(in8_alarm, alarm, 26);
11491153
11501154 static ssize_t alarm_mask_show(struct device *dev,
11511155 struct device_attribute *attr, char *buf)
....@@ -1187,7 +1191,6 @@
11871191 }
11881192
11891193 static DEVICE_ATTR_RW(alarm_mask);
1190
-
11911194
11921195 static ssize_t gpio_show(struct device *dev, struct device_attribute *attr,
11931196 char *buf)
....@@ -1371,23 +1374,23 @@
13711374
13721375 /* enable PWM fan control */
13731376 static DEVICE_ATTR_RW(pwm1);
1374
-static DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, pwm1_show, pwm1_store);
1375
-static DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, pwm1_show, pwm1_store);
1377
+static DEVICE_ATTR(pwm2, 0644, pwm1_show, pwm1_store);
1378
+static DEVICE_ATTR(pwm3, 0644, pwm1_show, pwm1_store);
13761379 static DEVICE_ATTR_RW(pwm1_enable);
1377
-static DEVICE_ATTR(pwm2_enable, S_IRUGO | S_IWUSR, pwm1_enable_show,
1380
+static DEVICE_ATTR(pwm2_enable, 0644, pwm1_enable_show,
13781381 pwm1_enable_store);
1379
-static DEVICE_ATTR(pwm3_enable, S_IRUGO | S_IWUSR, pwm1_enable_show,
1382
+static DEVICE_ATTR(pwm3_enable, 0644, pwm1_enable_show,
13801383 pwm1_enable_store);
13811384 static DEVICE_ATTR_RW(temp1_auto_point1_pwm);
1382
-static DEVICE_ATTR(temp2_auto_point1_pwm, S_IRUGO | S_IWUSR,
1383
- temp1_auto_point1_pwm_show, temp1_auto_point1_pwm_store);
1384
-static DEVICE_ATTR(temp3_auto_point1_pwm, S_IRUGO | S_IWUSR,
1385
- temp1_auto_point1_pwm_show, temp1_auto_point1_pwm_store);
1385
+static DEVICE_ATTR(temp2_auto_point1_pwm, 0644,
1386
+ temp1_auto_point1_pwm_show, temp1_auto_point1_pwm_store);
1387
+static DEVICE_ATTR(temp3_auto_point1_pwm, 0644,
1388
+ temp1_auto_point1_pwm_show, temp1_auto_point1_pwm_store);
13861389
13871390 static DEVICE_ATTR_RO(temp1_auto_point2_pwm);
1388
-static DEVICE_ATTR(temp2_auto_point2_pwm, S_IRUGO, temp1_auto_point2_pwm_show,
1391
+static DEVICE_ATTR(temp2_auto_point2_pwm, 0444, temp1_auto_point2_pwm_show,
13891392 NULL);
1390
-static DEVICE_ATTR(temp3_auto_point2_pwm, S_IRUGO, temp1_auto_point2_pwm_show,
1393
+static DEVICE_ATTR(temp3_auto_point2_pwm, 0444, temp1_auto_point2_pwm_show,
13911394 NULL);
13921395
13931396 static struct attribute *adm1026_attributes[] = {
....@@ -1813,8 +1816,7 @@
18131816 }
18141817 }
18151818
1816
-static int adm1026_probe(struct i2c_client *client,
1817
- const struct i2c_device_id *id)
1819
+static int adm1026_probe(struct i2c_client *client)
18181820 {
18191821 struct device *dev = &client->dev;
18201822 struct device *hwmon_dev;
....@@ -1857,7 +1859,7 @@
18571859 .driver = {
18581860 .name = "adm1026",
18591861 },
1860
- .probe = adm1026_probe,
1862
+ .probe_new = adm1026_probe,
18611863 .id_table = adm1026_id,
18621864 .detect = adm1026_detect,
18631865 .address_list = normal_i2c,