.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * lm85.c - Part of lm_sensors, Linux kernel modules for hardware |
---|
3 | 4 | * monitoring |
---|
.. | .. |
---|
8 | 9 | * Copyright (C) 2007--2014 Jean Delvare <jdelvare@suse.de> |
---|
9 | 10 | * |
---|
10 | 11 | * Chip details at <http://www.national.com/ds/LM/LM85.pdf> |
---|
11 | | - * |
---|
12 | | - * This program is free software; you can redistribute it and/or modify |
---|
13 | | - * it under the terms of the GNU General Public License as published by |
---|
14 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
15 | | - * (at your option) any later version. |
---|
16 | | - * |
---|
17 | | - * This program is distributed in the hope that it will be useful, |
---|
18 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
20 | | - * GNU General Public License for more details. |
---|
21 | | - * |
---|
22 | | - * You should have received a copy of the GNU General Public License |
---|
23 | | - * along with this program; if not, write to the Free Software |
---|
24 | | - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
25 | 12 | */ |
---|
26 | 13 | |
---|
27 | 14 | #include <linux/module.h> |
---|
.. | .. |
---|
41 | 28 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END }; |
---|
42 | 29 | |
---|
43 | 30 | enum chips { |
---|
44 | | - lm85, |
---|
| 31 | + lm85, lm96000, |
---|
45 | 32 | adm1027, adt7463, adt7468, |
---|
46 | 33 | emc6d100, emc6d102, emc6d103, emc6d103s |
---|
47 | 34 | }; |
---|
.. | .. |
---|
165 | 152 | #define PWM_TO_REG(val) clamp_val(val, 0, 255) |
---|
166 | 153 | #define PWM_FROM_REG(val) (val) |
---|
167 | 154 | |
---|
168 | | - |
---|
169 | 155 | /* |
---|
170 | 156 | * ZONEs have the following parameters: |
---|
171 | 157 | * Limit (low) temp, 1. degC |
---|
.. | .. |
---|
198 | 184 | #define RANGE_FROM_REG(val) lm85_range_map[(val) & 0x0f] |
---|
199 | 185 | |
---|
200 | 186 | /* These are the PWM frequency encodings */ |
---|
201 | | -static const int lm85_freq_map[8] = { /* 1 Hz */ |
---|
| 187 | +static const int lm85_freq_map[] = { /* 1 Hz */ |
---|
202 | 188 | 10, 15, 23, 30, 38, 47, 61, 94 |
---|
203 | 189 | }; |
---|
204 | | -static const int adm1027_freq_map[8] = { /* 1 Hz */ |
---|
| 190 | + |
---|
| 191 | +static const int lm96000_freq_map[] = { /* 1 Hz */ |
---|
| 192 | + 10, 15, 23, 30, 38, 47, 61, 94, |
---|
| 193 | + 22500, 24000, 25700, 25700, 27700, 27700, 30000, 30000 |
---|
| 194 | +}; |
---|
| 195 | + |
---|
| 196 | +static const int adm1027_freq_map[] = { /* 1 Hz */ |
---|
205 | 197 | 11, 15, 22, 29, 35, 44, 59, 88 |
---|
206 | 198 | }; |
---|
207 | | -#define FREQ_MAP_LEN 8 |
---|
208 | 199 | |
---|
209 | 200 | static int FREQ_TO_REG(const int *map, |
---|
210 | 201 | unsigned int map_size, unsigned long freq) |
---|
.. | .. |
---|
212 | 203 | return find_closest(freq, map, map_size); |
---|
213 | 204 | } |
---|
214 | 205 | |
---|
215 | | -static int FREQ_FROM_REG(const int *map, u8 reg) |
---|
| 206 | +static int FREQ_FROM_REG(const int *map, unsigned int map_size, u8 reg) |
---|
216 | 207 | { |
---|
217 | | - return map[reg & 0x07]; |
---|
| 208 | + return map[reg % map_size]; |
---|
218 | 209 | } |
---|
219 | 210 | |
---|
220 | 211 | /* |
---|
.. | .. |
---|
296 | 287 | struct i2c_client *client; |
---|
297 | 288 | const struct attribute_group *groups[6]; |
---|
298 | 289 | const int *freq_map; |
---|
| 290 | + unsigned int freq_map_size; |
---|
| 291 | + |
---|
299 | 292 | enum chips type; |
---|
300 | 293 | |
---|
301 | 294 | bool has_vid5; /* true if VID5 is configured for ADT7463 or ADT7468 */ |
---|
.. | .. |
---|
514 | 507 | data->autofan[i].config = |
---|
515 | 508 | lm85_read_value(client, LM85_REG_AFAN_CONFIG(i)); |
---|
516 | 509 | val = lm85_read_value(client, LM85_REG_AFAN_RANGE(i)); |
---|
517 | | - data->pwm_freq[i] = val & 0x07; |
---|
| 510 | + data->pwm_freq[i] = val % data->freq_map_size; |
---|
518 | 511 | data->zone[i].range = val >> 4; |
---|
519 | 512 | data->autofan[i].min_pwm = |
---|
520 | 513 | lm85_read_value(client, LM85_REG_AFAN_MINPWM(i)); |
---|
.. | .. |
---|
556 | 549 | } |
---|
557 | 550 | |
---|
558 | 551 | /* 4 Fans */ |
---|
559 | | -static ssize_t show_fan(struct device *dev, struct device_attribute *attr, |
---|
560 | | - char *buf) |
---|
| 552 | +static ssize_t fan_show(struct device *dev, struct device_attribute *attr, |
---|
| 553 | + char *buf) |
---|
561 | 554 | { |
---|
562 | 555 | int nr = to_sensor_dev_attr(attr)->index; |
---|
563 | 556 | struct lm85_data *data = lm85_update_device(dev); |
---|
564 | 557 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr])); |
---|
565 | 558 | } |
---|
566 | 559 | |
---|
567 | | -static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr, |
---|
568 | | - char *buf) |
---|
| 560 | +static ssize_t fan_min_show(struct device *dev, struct device_attribute *attr, |
---|
| 561 | + char *buf) |
---|
569 | 562 | { |
---|
570 | 563 | int nr = to_sensor_dev_attr(attr)->index; |
---|
571 | 564 | struct lm85_data *data = lm85_update_device(dev); |
---|
572 | 565 | return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr])); |
---|
573 | 566 | } |
---|
574 | 567 | |
---|
575 | | -static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, |
---|
576 | | - const char *buf, size_t count) |
---|
| 568 | +static ssize_t fan_min_store(struct device *dev, |
---|
| 569 | + struct device_attribute *attr, const char *buf, |
---|
| 570 | + size_t count) |
---|
577 | 571 | { |
---|
578 | 572 | int nr = to_sensor_dev_attr(attr)->index; |
---|
579 | 573 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
592 | 586 | return count; |
---|
593 | 587 | } |
---|
594 | 588 | |
---|
595 | | -#define show_fan_offset(offset) \ |
---|
596 | | -static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \ |
---|
597 | | - show_fan, NULL, offset - 1); \ |
---|
598 | | -static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ |
---|
599 | | - show_fan_min, set_fan_min, offset - 1) |
---|
600 | | - |
---|
601 | | -show_fan_offset(1); |
---|
602 | | -show_fan_offset(2); |
---|
603 | | -show_fan_offset(3); |
---|
604 | | -show_fan_offset(4); |
---|
| 589 | +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); |
---|
| 590 | +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); |
---|
| 591 | +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); |
---|
| 592 | +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); |
---|
| 593 | +static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 2); |
---|
| 594 | +static SENSOR_DEVICE_ATTR_RW(fan3_min, fan_min, 2); |
---|
| 595 | +static SENSOR_DEVICE_ATTR_RO(fan4_input, fan, 3); |
---|
| 596 | +static SENSOR_DEVICE_ATTR_RW(fan4_min, fan_min, 3); |
---|
605 | 597 | |
---|
606 | 598 | /* vid, vrm, alarms */ |
---|
607 | 599 | |
---|
.. | .. |
---|
660 | 652 | |
---|
661 | 653 | static DEVICE_ATTR_RO(alarms); |
---|
662 | 654 | |
---|
663 | | -static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, |
---|
664 | | - char *buf) |
---|
| 655 | +static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, |
---|
| 656 | + char *buf) |
---|
665 | 657 | { |
---|
666 | 658 | int nr = to_sensor_dev_attr(attr)->index; |
---|
667 | 659 | struct lm85_data *data = lm85_update_device(dev); |
---|
668 | 660 | return sprintf(buf, "%u\n", (data->alarms >> nr) & 1); |
---|
669 | 661 | } |
---|
670 | 662 | |
---|
671 | | -static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); |
---|
672 | | -static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); |
---|
673 | | -static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2); |
---|
674 | | -static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3); |
---|
675 | | -static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8); |
---|
676 | | -static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 18); |
---|
677 | | -static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 16); |
---|
678 | | -static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 17); |
---|
679 | | -static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4); |
---|
680 | | -static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_alarm, NULL, 14); |
---|
681 | | -static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5); |
---|
682 | | -static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 6); |
---|
683 | | -static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 15); |
---|
684 | | -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 10); |
---|
685 | | -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 11); |
---|
686 | | -static SENSOR_DEVICE_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 12); |
---|
687 | | -static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, 13); |
---|
| 663 | +static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0); |
---|
| 664 | +static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1); |
---|
| 665 | +static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2); |
---|
| 666 | +static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3); |
---|
| 667 | +static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 8); |
---|
| 668 | +static SENSOR_DEVICE_ATTR_RO(in5_alarm, alarm, 18); |
---|
| 669 | +static SENSOR_DEVICE_ATTR_RO(in6_alarm, alarm, 16); |
---|
| 670 | +static SENSOR_DEVICE_ATTR_RO(in7_alarm, alarm, 17); |
---|
| 671 | +static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 4); |
---|
| 672 | +static SENSOR_DEVICE_ATTR_RO(temp1_fault, alarm, 14); |
---|
| 673 | +static SENSOR_DEVICE_ATTR_RO(temp2_alarm, alarm, 5); |
---|
| 674 | +static SENSOR_DEVICE_ATTR_RO(temp3_alarm, alarm, 6); |
---|
| 675 | +static SENSOR_DEVICE_ATTR_RO(temp3_fault, alarm, 15); |
---|
| 676 | +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 10); |
---|
| 677 | +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 11); |
---|
| 678 | +static SENSOR_DEVICE_ATTR_RO(fan3_alarm, alarm, 12); |
---|
| 679 | +static SENSOR_DEVICE_ATTR_RO(fan4_alarm, alarm, 13); |
---|
688 | 680 | |
---|
689 | 681 | /* pwm */ |
---|
690 | 682 | |
---|
691 | | -static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, |
---|
692 | | - char *buf) |
---|
| 683 | +static ssize_t pwm_show(struct device *dev, struct device_attribute *attr, |
---|
| 684 | + char *buf) |
---|
693 | 685 | { |
---|
694 | 686 | int nr = to_sensor_dev_attr(attr)->index; |
---|
695 | 687 | struct lm85_data *data = lm85_update_device(dev); |
---|
696 | 688 | return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[nr])); |
---|
697 | 689 | } |
---|
698 | 690 | |
---|
699 | | -static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, |
---|
700 | | - const char *buf, size_t count) |
---|
| 691 | +static ssize_t pwm_store(struct device *dev, struct device_attribute *attr, |
---|
| 692 | + const char *buf, size_t count) |
---|
701 | 693 | { |
---|
702 | 694 | int nr = to_sensor_dev_attr(attr)->index; |
---|
703 | 695 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
716 | 708 | return count; |
---|
717 | 709 | } |
---|
718 | 710 | |
---|
719 | | -static ssize_t show_pwm_enable(struct device *dev, struct device_attribute |
---|
720 | | - *attr, char *buf) |
---|
| 711 | +static ssize_t pwm_enable_show(struct device *dev, |
---|
| 712 | + struct device_attribute *attr, char *buf) |
---|
721 | 713 | { |
---|
722 | 714 | int nr = to_sensor_dev_attr(attr)->index; |
---|
723 | 715 | struct lm85_data *data = lm85_update_device(dev); |
---|
.. | .. |
---|
738 | 730 | return sprintf(buf, "%d\n", enable); |
---|
739 | 731 | } |
---|
740 | 732 | |
---|
741 | | -static ssize_t set_pwm_enable(struct device *dev, struct device_attribute |
---|
742 | | - *attr, const char *buf, size_t count) |
---|
| 733 | +static ssize_t pwm_enable_store(struct device *dev, |
---|
| 734 | + struct device_attribute *attr, |
---|
| 735 | + const char *buf, size_t count) |
---|
743 | 736 | { |
---|
744 | 737 | int nr = to_sensor_dev_attr(attr)->index; |
---|
745 | 738 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
781 | 774 | return count; |
---|
782 | 775 | } |
---|
783 | 776 | |
---|
784 | | -static ssize_t show_pwm_freq(struct device *dev, |
---|
785 | | - struct device_attribute *attr, char *buf) |
---|
| 777 | +static ssize_t pwm_freq_show(struct device *dev, |
---|
| 778 | + struct device_attribute *attr, char *buf) |
---|
786 | 779 | { |
---|
787 | 780 | int nr = to_sensor_dev_attr(attr)->index; |
---|
788 | 781 | struct lm85_data *data = lm85_update_device(dev); |
---|
.. | .. |
---|
791 | 784 | if (IS_ADT7468_HFPWM(data)) |
---|
792 | 785 | freq = 22500; |
---|
793 | 786 | else |
---|
794 | | - freq = FREQ_FROM_REG(data->freq_map, data->pwm_freq[nr]); |
---|
| 787 | + freq = FREQ_FROM_REG(data->freq_map, data->freq_map_size, |
---|
| 788 | + data->pwm_freq[nr]); |
---|
795 | 789 | |
---|
796 | 790 | return sprintf(buf, "%d\n", freq); |
---|
797 | 791 | } |
---|
798 | 792 | |
---|
799 | | -static ssize_t set_pwm_freq(struct device *dev, |
---|
800 | | - struct device_attribute *attr, const char *buf, size_t count) |
---|
| 793 | +static ssize_t pwm_freq_store(struct device *dev, |
---|
| 794 | + struct device_attribute *attr, const char *buf, |
---|
| 795 | + size_t count) |
---|
801 | 796 | { |
---|
802 | 797 | int nr = to_sensor_dev_attr(attr)->index; |
---|
803 | 798 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
820 | 815 | lm85_write_value(client, ADT7468_REG_CFG5, data->cfg5); |
---|
821 | 816 | } else { /* Low freq. mode */ |
---|
822 | 817 | data->pwm_freq[nr] = FREQ_TO_REG(data->freq_map, |
---|
823 | | - FREQ_MAP_LEN, val); |
---|
| 818 | + data->freq_map_size, val); |
---|
824 | 819 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
---|
825 | 820 | (data->zone[nr].range << 4) |
---|
826 | 821 | | data->pwm_freq[nr]); |
---|
.. | .. |
---|
833 | 828 | return count; |
---|
834 | 829 | } |
---|
835 | 830 | |
---|
836 | | -#define show_pwm_reg(offset) \ |
---|
837 | | -static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \ |
---|
838 | | - show_pwm, set_pwm, offset - 1); \ |
---|
839 | | -static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \ |
---|
840 | | - show_pwm_enable, set_pwm_enable, offset - 1); \ |
---|
841 | | -static SENSOR_DEVICE_ATTR(pwm##offset##_freq, S_IRUGO | S_IWUSR, \ |
---|
842 | | - show_pwm_freq, set_pwm_freq, offset - 1) |
---|
843 | | - |
---|
844 | | -show_pwm_reg(1); |
---|
845 | | -show_pwm_reg(2); |
---|
846 | | -show_pwm_reg(3); |
---|
| 831 | +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); |
---|
| 832 | +static SENSOR_DEVICE_ATTR_RW(pwm1_enable, pwm_enable, 0); |
---|
| 833 | +static SENSOR_DEVICE_ATTR_RW(pwm1_freq, pwm_freq, 0); |
---|
| 834 | +static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1); |
---|
| 835 | +static SENSOR_DEVICE_ATTR_RW(pwm2_enable, pwm_enable, 1); |
---|
| 836 | +static SENSOR_DEVICE_ATTR_RW(pwm2_freq, pwm_freq, 1); |
---|
| 837 | +static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, 2); |
---|
| 838 | +static SENSOR_DEVICE_ATTR_RW(pwm3_enable, pwm_enable, 2); |
---|
| 839 | +static SENSOR_DEVICE_ATTR_RW(pwm3_freq, pwm_freq, 2); |
---|
847 | 840 | |
---|
848 | 841 | /* Voltages */ |
---|
849 | 842 | |
---|
850 | | -static ssize_t show_in(struct device *dev, struct device_attribute *attr, |
---|
851 | | - char *buf) |
---|
| 843 | +static ssize_t in_show(struct device *dev, struct device_attribute *attr, |
---|
| 844 | + char *buf) |
---|
852 | 845 | { |
---|
853 | 846 | int nr = to_sensor_dev_attr(attr)->index; |
---|
854 | 847 | struct lm85_data *data = lm85_update_device(dev); |
---|
.. | .. |
---|
856 | 849 | data->in_ext[nr])); |
---|
857 | 850 | } |
---|
858 | 851 | |
---|
859 | | -static ssize_t show_in_min(struct device *dev, struct device_attribute *attr, |
---|
860 | | - char *buf) |
---|
| 852 | +static ssize_t in_min_show(struct device *dev, struct device_attribute *attr, |
---|
| 853 | + char *buf) |
---|
861 | 854 | { |
---|
862 | 855 | int nr = to_sensor_dev_attr(attr)->index; |
---|
863 | 856 | struct lm85_data *data = lm85_update_device(dev); |
---|
864 | 857 | return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_min[nr])); |
---|
865 | 858 | } |
---|
866 | 859 | |
---|
867 | | -static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, |
---|
868 | | - const char *buf, size_t count) |
---|
| 860 | +static ssize_t in_min_store(struct device *dev, struct device_attribute *attr, |
---|
| 861 | + const char *buf, size_t count) |
---|
869 | 862 | { |
---|
870 | 863 | int nr = to_sensor_dev_attr(attr)->index; |
---|
871 | 864 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
884 | 877 | return count; |
---|
885 | 878 | } |
---|
886 | 879 | |
---|
887 | | -static ssize_t show_in_max(struct device *dev, struct device_attribute *attr, |
---|
888 | | - char *buf) |
---|
| 880 | +static ssize_t in_max_show(struct device *dev, struct device_attribute *attr, |
---|
| 881 | + char *buf) |
---|
889 | 882 | { |
---|
890 | 883 | int nr = to_sensor_dev_attr(attr)->index; |
---|
891 | 884 | struct lm85_data *data = lm85_update_device(dev); |
---|
892 | 885 | return sprintf(buf, "%d\n", INS_FROM_REG(nr, data->in_max[nr])); |
---|
893 | 886 | } |
---|
894 | 887 | |
---|
895 | | -static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, |
---|
896 | | - const char *buf, size_t count) |
---|
| 888 | +static ssize_t in_max_store(struct device *dev, struct device_attribute *attr, |
---|
| 889 | + const char *buf, size_t count) |
---|
897 | 890 | { |
---|
898 | 891 | int nr = to_sensor_dev_attr(attr)->index; |
---|
899 | 892 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
912 | 905 | return count; |
---|
913 | 906 | } |
---|
914 | 907 | |
---|
915 | | -#define show_in_reg(offset) \ |
---|
916 | | -static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \ |
---|
917 | | - show_in, NULL, offset); \ |
---|
918 | | -static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \ |
---|
919 | | - show_in_min, set_in_min, offset); \ |
---|
920 | | -static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \ |
---|
921 | | - show_in_max, set_in_max, offset) |
---|
922 | | - |
---|
923 | | -show_in_reg(0); |
---|
924 | | -show_in_reg(1); |
---|
925 | | -show_in_reg(2); |
---|
926 | | -show_in_reg(3); |
---|
927 | | -show_in_reg(4); |
---|
928 | | -show_in_reg(5); |
---|
929 | | -show_in_reg(6); |
---|
930 | | -show_in_reg(7); |
---|
| 908 | +static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0); |
---|
| 909 | +static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0); |
---|
| 910 | +static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0); |
---|
| 911 | +static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1); |
---|
| 912 | +static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1); |
---|
| 913 | +static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1); |
---|
| 914 | +static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2); |
---|
| 915 | +static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2); |
---|
| 916 | +static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2); |
---|
| 917 | +static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3); |
---|
| 918 | +static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3); |
---|
| 919 | +static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3); |
---|
| 920 | +static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4); |
---|
| 921 | +static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4); |
---|
| 922 | +static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4); |
---|
| 923 | +static SENSOR_DEVICE_ATTR_RO(in5_input, in, 5); |
---|
| 924 | +static SENSOR_DEVICE_ATTR_RW(in5_min, in_min, 5); |
---|
| 925 | +static SENSOR_DEVICE_ATTR_RW(in5_max, in_max, 5); |
---|
| 926 | +static SENSOR_DEVICE_ATTR_RO(in6_input, in, 6); |
---|
| 927 | +static SENSOR_DEVICE_ATTR_RW(in6_min, in_min, 6); |
---|
| 928 | +static SENSOR_DEVICE_ATTR_RW(in6_max, in_max, 6); |
---|
| 929 | +static SENSOR_DEVICE_ATTR_RO(in7_input, in, 7); |
---|
| 930 | +static SENSOR_DEVICE_ATTR_RW(in7_min, in_min, 7); |
---|
| 931 | +static SENSOR_DEVICE_ATTR_RW(in7_max, in_max, 7); |
---|
931 | 932 | |
---|
932 | 933 | /* Temps */ |
---|
933 | 934 | |
---|
934 | | -static ssize_t show_temp(struct device *dev, struct device_attribute *attr, |
---|
935 | | - char *buf) |
---|
| 935 | +static ssize_t temp_show(struct device *dev, struct device_attribute *attr, |
---|
| 936 | + char *buf) |
---|
936 | 937 | { |
---|
937 | 938 | int nr = to_sensor_dev_attr(attr)->index; |
---|
938 | 939 | struct lm85_data *data = lm85_update_device(dev); |
---|
.. | .. |
---|
940 | 941 | data->temp_ext[nr])); |
---|
941 | 942 | } |
---|
942 | 943 | |
---|
943 | | -static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr, |
---|
944 | | - char *buf) |
---|
| 944 | +static ssize_t temp_min_show(struct device *dev, |
---|
| 945 | + struct device_attribute *attr, char *buf) |
---|
945 | 946 | { |
---|
946 | 947 | int nr = to_sensor_dev_attr(attr)->index; |
---|
947 | 948 | struct lm85_data *data = lm85_update_device(dev); |
---|
948 | 949 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_min[nr])); |
---|
949 | 950 | } |
---|
950 | 951 | |
---|
951 | | -static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, |
---|
952 | | - const char *buf, size_t count) |
---|
| 952 | +static ssize_t temp_min_store(struct device *dev, |
---|
| 953 | + struct device_attribute *attr, const char *buf, |
---|
| 954 | + size_t count) |
---|
953 | 955 | { |
---|
954 | 956 | int nr = to_sensor_dev_attr(attr)->index; |
---|
955 | 957 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
971 | 973 | return count; |
---|
972 | 974 | } |
---|
973 | 975 | |
---|
974 | | -static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr, |
---|
975 | | - char *buf) |
---|
| 976 | +static ssize_t temp_max_show(struct device *dev, |
---|
| 977 | + struct device_attribute *attr, char *buf) |
---|
976 | 978 | { |
---|
977 | 979 | int nr = to_sensor_dev_attr(attr)->index; |
---|
978 | 980 | struct lm85_data *data = lm85_update_device(dev); |
---|
979 | 981 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp_max[nr])); |
---|
980 | 982 | } |
---|
981 | 983 | |
---|
982 | | -static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, |
---|
983 | | - const char *buf, size_t count) |
---|
| 984 | +static ssize_t temp_max_store(struct device *dev, |
---|
| 985 | + struct device_attribute *attr, const char *buf, |
---|
| 986 | + size_t count) |
---|
984 | 987 | { |
---|
985 | 988 | int nr = to_sensor_dev_attr(attr)->index; |
---|
986 | 989 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
1002 | 1005 | return count; |
---|
1003 | 1006 | } |
---|
1004 | 1007 | |
---|
1005 | | -#define show_temp_reg(offset) \ |
---|
1006 | | -static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \ |
---|
1007 | | - show_temp, NULL, offset - 1); \ |
---|
1008 | | -static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \ |
---|
1009 | | - show_temp_min, set_temp_min, offset - 1); \ |
---|
1010 | | -static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \ |
---|
1011 | | - show_temp_max, set_temp_max, offset - 1); |
---|
1012 | | - |
---|
1013 | | -show_temp_reg(1); |
---|
1014 | | -show_temp_reg(2); |
---|
1015 | | -show_temp_reg(3); |
---|
1016 | | - |
---|
| 1008 | +static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); |
---|
| 1009 | +static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); |
---|
| 1010 | +static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); |
---|
| 1011 | +static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); |
---|
| 1012 | +static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); |
---|
| 1013 | +static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); |
---|
| 1014 | +static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2); |
---|
| 1015 | +static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2); |
---|
| 1016 | +static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2); |
---|
1017 | 1017 | |
---|
1018 | 1018 | /* Automatic PWM control */ |
---|
1019 | 1019 | |
---|
1020 | | -static ssize_t show_pwm_auto_channels(struct device *dev, |
---|
1021 | | - struct device_attribute *attr, char *buf) |
---|
| 1020 | +static ssize_t pwm_auto_channels_show(struct device *dev, |
---|
| 1021 | + struct device_attribute *attr, |
---|
| 1022 | + char *buf) |
---|
1022 | 1023 | { |
---|
1023 | 1024 | int nr = to_sensor_dev_attr(attr)->index; |
---|
1024 | 1025 | struct lm85_data *data = lm85_update_device(dev); |
---|
1025 | 1026 | return sprintf(buf, "%d\n", ZONE_FROM_REG(data->autofan[nr].config)); |
---|
1026 | 1027 | } |
---|
1027 | 1028 | |
---|
1028 | | -static ssize_t set_pwm_auto_channels(struct device *dev, |
---|
1029 | | - struct device_attribute *attr, const char *buf, size_t count) |
---|
| 1029 | +static ssize_t pwm_auto_channels_store(struct device *dev, |
---|
| 1030 | + struct device_attribute *attr, |
---|
| 1031 | + const char *buf, size_t count) |
---|
1030 | 1032 | { |
---|
1031 | 1033 | int nr = to_sensor_dev_attr(attr)->index; |
---|
1032 | 1034 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
1047 | 1049 | return count; |
---|
1048 | 1050 | } |
---|
1049 | 1051 | |
---|
1050 | | -static ssize_t show_pwm_auto_pwm_min(struct device *dev, |
---|
1051 | | - struct device_attribute *attr, char *buf) |
---|
| 1052 | +static ssize_t pwm_auto_pwm_min_show(struct device *dev, |
---|
| 1053 | + struct device_attribute *attr, char *buf) |
---|
1052 | 1054 | { |
---|
1053 | 1055 | int nr = to_sensor_dev_attr(attr)->index; |
---|
1054 | 1056 | struct lm85_data *data = lm85_update_device(dev); |
---|
1055 | 1057 | return sprintf(buf, "%d\n", PWM_FROM_REG(data->autofan[nr].min_pwm)); |
---|
1056 | 1058 | } |
---|
1057 | 1059 | |
---|
1058 | | -static ssize_t set_pwm_auto_pwm_min(struct device *dev, |
---|
1059 | | - struct device_attribute *attr, const char *buf, size_t count) |
---|
| 1060 | +static ssize_t pwm_auto_pwm_min_store(struct device *dev, |
---|
| 1061 | + struct device_attribute *attr, |
---|
| 1062 | + const char *buf, size_t count) |
---|
1060 | 1063 | { |
---|
1061 | 1064 | int nr = to_sensor_dev_attr(attr)->index; |
---|
1062 | 1065 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
1076 | 1079 | return count; |
---|
1077 | 1080 | } |
---|
1078 | 1081 | |
---|
1079 | | -static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, |
---|
1080 | | - struct device_attribute *attr, char *buf) |
---|
| 1082 | +static ssize_t pwm_auto_pwm_minctl_show(struct device *dev, |
---|
| 1083 | + struct device_attribute *attr, |
---|
| 1084 | + char *buf) |
---|
1081 | 1085 | { |
---|
1082 | 1086 | int nr = to_sensor_dev_attr(attr)->index; |
---|
1083 | 1087 | struct lm85_data *data = lm85_update_device(dev); |
---|
1084 | 1088 | return sprintf(buf, "%d\n", data->autofan[nr].min_off); |
---|
1085 | 1089 | } |
---|
1086 | 1090 | |
---|
1087 | | -static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, |
---|
1088 | | - struct device_attribute *attr, const char *buf, size_t count) |
---|
| 1091 | +static ssize_t pwm_auto_pwm_minctl_store(struct device *dev, |
---|
| 1092 | + struct device_attribute *attr, |
---|
| 1093 | + const char *buf, size_t count) |
---|
1089 | 1094 | { |
---|
1090 | 1095 | int nr = to_sensor_dev_attr(attr)->index; |
---|
1091 | 1096 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
1109 | 1114 | return count; |
---|
1110 | 1115 | } |
---|
1111 | 1116 | |
---|
1112 | | -#define pwm_auto(offset) \ |
---|
1113 | | -static SENSOR_DEVICE_ATTR(pwm##offset##_auto_channels, \ |
---|
1114 | | - S_IRUGO | S_IWUSR, show_pwm_auto_channels, \ |
---|
1115 | | - set_pwm_auto_channels, offset - 1); \ |
---|
1116 | | -static SENSOR_DEVICE_ATTR(pwm##offset##_auto_pwm_min, \ |
---|
1117 | | - S_IRUGO | S_IWUSR, show_pwm_auto_pwm_min, \ |
---|
1118 | | - set_pwm_auto_pwm_min, offset - 1); \ |
---|
1119 | | -static SENSOR_DEVICE_ATTR(pwm##offset##_auto_pwm_minctl, \ |
---|
1120 | | - S_IRUGO | S_IWUSR, show_pwm_auto_pwm_minctl, \ |
---|
1121 | | - set_pwm_auto_pwm_minctl, offset - 1) |
---|
1122 | | - |
---|
1123 | | -pwm_auto(1); |
---|
1124 | | -pwm_auto(2); |
---|
1125 | | -pwm_auto(3); |
---|
| 1117 | +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_channels, pwm_auto_channels, 0); |
---|
| 1118 | +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_pwm_min, pwm_auto_pwm_min, 0); |
---|
| 1119 | +static SENSOR_DEVICE_ATTR_RW(pwm1_auto_pwm_minctl, pwm_auto_pwm_minctl, 0); |
---|
| 1120 | +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_channels, pwm_auto_channels, 1); |
---|
| 1121 | +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_pwm_min, pwm_auto_pwm_min, 1); |
---|
| 1122 | +static SENSOR_DEVICE_ATTR_RW(pwm2_auto_pwm_minctl, pwm_auto_pwm_minctl, 1); |
---|
| 1123 | +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_channels, pwm_auto_channels, 2); |
---|
| 1124 | +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_pwm_min, pwm_auto_pwm_min, 2); |
---|
| 1125 | +static SENSOR_DEVICE_ATTR_RW(pwm3_auto_pwm_minctl, pwm_auto_pwm_minctl, 2); |
---|
1126 | 1126 | |
---|
1127 | 1127 | /* Temperature settings for automatic PWM control */ |
---|
1128 | 1128 | |
---|
1129 | | -static ssize_t show_temp_auto_temp_off(struct device *dev, |
---|
1130 | | - struct device_attribute *attr, char *buf) |
---|
| 1129 | +static ssize_t temp_auto_temp_off_show(struct device *dev, |
---|
| 1130 | + struct device_attribute *attr, |
---|
| 1131 | + char *buf) |
---|
1131 | 1132 | { |
---|
1132 | 1133 | int nr = to_sensor_dev_attr(attr)->index; |
---|
1133 | 1134 | struct lm85_data *data = lm85_update_device(dev); |
---|
.. | .. |
---|
1135 | 1136 | HYST_FROM_REG(data->zone[nr].hyst)); |
---|
1136 | 1137 | } |
---|
1137 | 1138 | |
---|
1138 | | -static ssize_t set_temp_auto_temp_off(struct device *dev, |
---|
1139 | | - struct device_attribute *attr, const char *buf, size_t count) |
---|
| 1139 | +static ssize_t temp_auto_temp_off_store(struct device *dev, |
---|
| 1140 | + struct device_attribute *attr, |
---|
| 1141 | + const char *buf, size_t count) |
---|
1140 | 1142 | { |
---|
1141 | 1143 | int nr = to_sensor_dev_attr(attr)->index; |
---|
1142 | 1144 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
1164 | 1166 | return count; |
---|
1165 | 1167 | } |
---|
1166 | 1168 | |
---|
1167 | | -static ssize_t show_temp_auto_temp_min(struct device *dev, |
---|
1168 | | - struct device_attribute *attr, char *buf) |
---|
| 1169 | +static ssize_t temp_auto_temp_min_show(struct device *dev, |
---|
| 1170 | + struct device_attribute *attr, |
---|
| 1171 | + char *buf) |
---|
1169 | 1172 | { |
---|
1170 | 1173 | int nr = to_sensor_dev_attr(attr)->index; |
---|
1171 | 1174 | struct lm85_data *data = lm85_update_device(dev); |
---|
1172 | 1175 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].limit)); |
---|
1173 | 1176 | } |
---|
1174 | 1177 | |
---|
1175 | | -static ssize_t set_temp_auto_temp_min(struct device *dev, |
---|
1176 | | - struct device_attribute *attr, const char *buf, size_t count) |
---|
| 1178 | +static ssize_t temp_auto_temp_min_store(struct device *dev, |
---|
| 1179 | + struct device_attribute *attr, |
---|
| 1180 | + const char *buf, size_t count) |
---|
1177 | 1181 | { |
---|
1178 | 1182 | int nr = to_sensor_dev_attr(attr)->index; |
---|
1179 | 1183 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
1196 | 1200 | TEMP_FROM_REG(data->zone[nr].limit)); |
---|
1197 | 1201 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
---|
1198 | 1202 | ((data->zone[nr].range & 0x0f) << 4) |
---|
1199 | | - | (data->pwm_freq[nr] & 0x07)); |
---|
| 1203 | + | data->pwm_freq[nr]); |
---|
1200 | 1204 | |
---|
1201 | 1205 | mutex_unlock(&data->update_lock); |
---|
1202 | 1206 | return count; |
---|
1203 | 1207 | } |
---|
1204 | 1208 | |
---|
1205 | | -static ssize_t show_temp_auto_temp_max(struct device *dev, |
---|
1206 | | - struct device_attribute *attr, char *buf) |
---|
| 1209 | +static ssize_t temp_auto_temp_max_show(struct device *dev, |
---|
| 1210 | + struct device_attribute *attr, |
---|
| 1211 | + char *buf) |
---|
1207 | 1212 | { |
---|
1208 | 1213 | int nr = to_sensor_dev_attr(attr)->index; |
---|
1209 | 1214 | struct lm85_data *data = lm85_update_device(dev); |
---|
.. | .. |
---|
1211 | 1216 | RANGE_FROM_REG(data->zone[nr].range)); |
---|
1212 | 1217 | } |
---|
1213 | 1218 | |
---|
1214 | | -static ssize_t set_temp_auto_temp_max(struct device *dev, |
---|
1215 | | - struct device_attribute *attr, const char *buf, size_t count) |
---|
| 1219 | +static ssize_t temp_auto_temp_max_store(struct device *dev, |
---|
| 1220 | + struct device_attribute *attr, |
---|
| 1221 | + const char *buf, size_t count) |
---|
1216 | 1222 | { |
---|
1217 | 1223 | int nr = to_sensor_dev_attr(attr)->index; |
---|
1218 | 1224 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
1232 | 1238 | val - min); |
---|
1233 | 1239 | lm85_write_value(client, LM85_REG_AFAN_RANGE(nr), |
---|
1234 | 1240 | ((data->zone[nr].range & 0x0f) << 4) |
---|
1235 | | - | (data->pwm_freq[nr] & 0x07)); |
---|
| 1241 | + | data->pwm_freq[nr]); |
---|
1236 | 1242 | mutex_unlock(&data->update_lock); |
---|
1237 | 1243 | return count; |
---|
1238 | 1244 | } |
---|
1239 | 1245 | |
---|
1240 | | -static ssize_t show_temp_auto_temp_crit(struct device *dev, |
---|
1241 | | - struct device_attribute *attr, char *buf) |
---|
| 1246 | +static ssize_t temp_auto_temp_crit_show(struct device *dev, |
---|
| 1247 | + struct device_attribute *attr, |
---|
| 1248 | + char *buf) |
---|
1242 | 1249 | { |
---|
1243 | 1250 | int nr = to_sensor_dev_attr(attr)->index; |
---|
1244 | 1251 | struct lm85_data *data = lm85_update_device(dev); |
---|
1245 | 1252 | return sprintf(buf, "%d\n", TEMP_FROM_REG(data->zone[nr].critical)); |
---|
1246 | 1253 | } |
---|
1247 | 1254 | |
---|
1248 | | -static ssize_t set_temp_auto_temp_crit(struct device *dev, |
---|
1249 | | - struct device_attribute *attr, const char *buf, size_t count) |
---|
| 1255 | +static ssize_t temp_auto_temp_crit_store(struct device *dev, |
---|
| 1256 | + struct device_attribute *attr, |
---|
| 1257 | + const char *buf, size_t count) |
---|
1250 | 1258 | { |
---|
1251 | 1259 | int nr = to_sensor_dev_attr(attr)->index; |
---|
1252 | 1260 | struct lm85_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
1266 | 1274 | return count; |
---|
1267 | 1275 | } |
---|
1268 | 1276 | |
---|
1269 | | -#define temp_auto(offset) \ |
---|
1270 | | -static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_off, \ |
---|
1271 | | - S_IRUGO | S_IWUSR, show_temp_auto_temp_off, \ |
---|
1272 | | - set_temp_auto_temp_off, offset - 1); \ |
---|
1273 | | -static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_min, \ |
---|
1274 | | - S_IRUGO | S_IWUSR, show_temp_auto_temp_min, \ |
---|
1275 | | - set_temp_auto_temp_min, offset - 1); \ |
---|
1276 | | -static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_max, \ |
---|
1277 | | - S_IRUGO | S_IWUSR, show_temp_auto_temp_max, \ |
---|
1278 | | - set_temp_auto_temp_max, offset - 1); \ |
---|
1279 | | -static SENSOR_DEVICE_ATTR(temp##offset##_auto_temp_crit, \ |
---|
1280 | | - S_IRUGO | S_IWUSR, show_temp_auto_temp_crit, \ |
---|
1281 | | - set_temp_auto_temp_crit, offset - 1); |
---|
1282 | | - |
---|
1283 | | -temp_auto(1); |
---|
1284 | | -temp_auto(2); |
---|
1285 | | -temp_auto(3); |
---|
| 1277 | +static SENSOR_DEVICE_ATTR_RW(temp1_auto_temp_off, temp_auto_temp_off, 0); |
---|
| 1278 | +static SENSOR_DEVICE_ATTR_RW(temp1_auto_temp_min, temp_auto_temp_min, 0); |
---|
| 1279 | +static SENSOR_DEVICE_ATTR_RW(temp1_auto_temp_max, temp_auto_temp_max, 0); |
---|
| 1280 | +static SENSOR_DEVICE_ATTR_RW(temp1_auto_temp_crit, temp_auto_temp_crit, 0); |
---|
| 1281 | +static SENSOR_DEVICE_ATTR_RW(temp2_auto_temp_off, temp_auto_temp_off, 1); |
---|
| 1282 | +static SENSOR_DEVICE_ATTR_RW(temp2_auto_temp_min, temp_auto_temp_min, 1); |
---|
| 1283 | +static SENSOR_DEVICE_ATTR_RW(temp2_auto_temp_max, temp_auto_temp_max, 1); |
---|
| 1284 | +static SENSOR_DEVICE_ATTR_RW(temp2_auto_temp_crit, temp_auto_temp_crit, 1); |
---|
| 1285 | +static SENSOR_DEVICE_ATTR_RW(temp3_auto_temp_off, temp_auto_temp_off, 2); |
---|
| 1286 | +static SENSOR_DEVICE_ATTR_RW(temp3_auto_temp_min, temp_auto_temp_min, 2); |
---|
| 1287 | +static SENSOR_DEVICE_ATTR_RW(temp3_auto_temp_max, temp_auto_temp_max, 2); |
---|
| 1288 | +static SENSOR_DEVICE_ATTR_RW(temp3_auto_temp_crit, temp_auto_temp_crit, 2); |
---|
1286 | 1289 | |
---|
1287 | 1290 | static struct attribute *lm85_attributes[] = { |
---|
1288 | 1291 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
---|
.. | .. |
---|
1496 | 1499 | "Found Winbond WPCD377I, ignoring\n"); |
---|
1497 | 1500 | return -ENODEV; |
---|
1498 | 1501 | } |
---|
1499 | | - type_name = "lm85"; |
---|
| 1502 | + type_name = "lm96000"; |
---|
1500 | 1503 | break; |
---|
1501 | 1504 | } |
---|
1502 | 1505 | } else if (company == LM85_COMPANY_ANALOG_DEV) { |
---|
.. | .. |
---|
1541 | 1544 | return 0; |
---|
1542 | 1545 | } |
---|
1543 | 1546 | |
---|
1544 | | -static int lm85_probe(struct i2c_client *client, const struct i2c_device_id *id) |
---|
| 1547 | +static const struct i2c_device_id lm85_id[]; |
---|
| 1548 | + |
---|
| 1549 | +static int lm85_probe(struct i2c_client *client) |
---|
1545 | 1550 | { |
---|
1546 | 1551 | struct device *dev = &client->dev; |
---|
1547 | 1552 | struct device *hwmon_dev; |
---|
.. | .. |
---|
1556 | 1561 | if (client->dev.of_node) |
---|
1557 | 1562 | data->type = (enum chips)of_device_get_match_data(&client->dev); |
---|
1558 | 1563 | else |
---|
1559 | | - data->type = id->driver_data; |
---|
| 1564 | + data->type = i2c_match_id(lm85_id, client)->driver_data; |
---|
1560 | 1565 | mutex_init(&data->update_lock); |
---|
1561 | 1566 | |
---|
1562 | 1567 | /* Fill in the chip specific driver values */ |
---|
.. | .. |
---|
1569 | 1574 | case emc6d103: |
---|
1570 | 1575 | case emc6d103s: |
---|
1571 | 1576 | data->freq_map = adm1027_freq_map; |
---|
| 1577 | + data->freq_map_size = ARRAY_SIZE(adm1027_freq_map); |
---|
| 1578 | + break; |
---|
| 1579 | + case lm96000: |
---|
| 1580 | + data->freq_map = lm96000_freq_map; |
---|
| 1581 | + data->freq_map_size = ARRAY_SIZE(lm96000_freq_map); |
---|
1572 | 1582 | break; |
---|
1573 | 1583 | default: |
---|
1574 | 1584 | data->freq_map = lm85_freq_map; |
---|
| 1585 | + data->freq_map_size = ARRAY_SIZE(lm85_freq_map); |
---|
1575 | 1586 | } |
---|
1576 | 1587 | |
---|
1577 | 1588 | /* Set the VRM version */ |
---|
.. | .. |
---|
1618 | 1629 | { "lm85", lm85 }, |
---|
1619 | 1630 | { "lm85b", lm85 }, |
---|
1620 | 1631 | { "lm85c", lm85 }, |
---|
| 1632 | + { "lm96000", lm96000 }, |
---|
1621 | 1633 | { "emc6d100", emc6d100 }, |
---|
1622 | 1634 | { "emc6d101", emc6d100 }, |
---|
1623 | 1635 | { "emc6d102", emc6d102 }, |
---|
.. | .. |
---|
1627 | 1639 | }; |
---|
1628 | 1640 | MODULE_DEVICE_TABLE(i2c, lm85_id); |
---|
1629 | 1641 | |
---|
1630 | | -static const struct of_device_id lm85_of_match[] = { |
---|
| 1642 | +static const struct of_device_id __maybe_unused lm85_of_match[] = { |
---|
1631 | 1643 | { |
---|
1632 | 1644 | .compatible = "adi,adm1027", |
---|
1633 | 1645 | .data = (void *)adm1027 |
---|
.. | .. |
---|
1651 | 1663 | { |
---|
1652 | 1664 | .compatible = "national,lm85c", |
---|
1653 | 1665 | .data = (void *)lm85 |
---|
| 1666 | + }, |
---|
| 1667 | + { |
---|
| 1668 | + .compatible = "ti,lm96000", |
---|
| 1669 | + .data = (void *)lm96000 |
---|
1654 | 1670 | }, |
---|
1655 | 1671 | { |
---|
1656 | 1672 | .compatible = "smsc,emc6d100", |
---|
.. | .. |
---|
1682 | 1698 | .name = "lm85", |
---|
1683 | 1699 | .of_match_table = of_match_ptr(lm85_of_match), |
---|
1684 | 1700 | }, |
---|
1685 | | - .probe = lm85_probe, |
---|
| 1701 | + .probe_new = lm85_probe, |
---|
1686 | 1702 | .id_table = lm85_id, |
---|
1687 | 1703 | .detect = lm85_detect, |
---|
1688 | 1704 | .address_list = normal_i2c, |
---|