.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * w83627hf.c - Part of lm_sensors, Linux kernel modules for hardware |
---|
3 | 4 | * monitoring |
---|
.. | .. |
---|
6 | 7 | * and Mark Studebaker <mdsxyz123@yahoo.com> |
---|
7 | 8 | * Ported to 2.6 by Bernhard C. Schrenk <clemy@clemy.org> |
---|
8 | 9 | * 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. |
---|
23 | 10 | */ |
---|
24 | 11 | |
---|
25 | 12 | /* |
---|
.. | .. |
---|
402 | 389 | #endif |
---|
403 | 390 | }; |
---|
404 | 391 | |
---|
405 | | - |
---|
406 | 392 | static int w83627hf_probe(struct platform_device *pdev); |
---|
407 | 393 | static int w83627hf_remove(struct platform_device *pdev); |
---|
408 | 394 | |
---|
.. | .. |
---|
488 | 474 | }; |
---|
489 | 475 | |
---|
490 | 476 | 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) |
---|
492 | 478 | { |
---|
493 | 479 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
494 | 480 | struct w83627hf_data *data = w83627hf_update_device(dev); |
---|
495 | 481 | return sprintf(buf, "%ld\n", (long)IN_FROM_REG(data->in[nr])); |
---|
496 | 482 | } |
---|
497 | 483 | 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) |
---|
499 | 485 | { |
---|
500 | 486 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
501 | 487 | struct w83627hf_data *data = w83627hf_update_device(dev); |
---|
502 | 488 | return sprintf(buf, "%ld\n", (long)IN_FROM_REG(data->in_min[nr])); |
---|
503 | 489 | } |
---|
504 | 490 | 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) |
---|
506 | 492 | { |
---|
507 | 493 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
508 | 494 | struct w83627hf_data *data = w83627hf_update_device(dev); |
---|
509 | 495 | return sprintf(buf, "%ld\n", (long)IN_FROM_REG(data->in_max[nr])); |
---|
510 | 496 | } |
---|
511 | 497 | 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, |
---|
513 | 499 | const char *buf, size_t count) |
---|
514 | 500 | { |
---|
515 | 501 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
528 | 514 | return count; |
---|
529 | 515 | } |
---|
530 | 516 | 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, |
---|
532 | 518 | const char *buf, size_t count) |
---|
533 | 519 | { |
---|
534 | 520 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
546 | 532 | mutex_unlock(&data->update_lock); |
---|
547 | 533 | return count; |
---|
548 | 534 | } |
---|
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); |
---|
556 | 535 | |
---|
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); |
---|
565 | 560 | |
---|
566 | 561 | /* use a different set of functions for in0 */ |
---|
567 | 562 | static ssize_t show_in_0(struct w83627hf_data *data, char *buf, u8 reg) |
---|
.. | .. |
---|
667 | 662 | static DEVICE_ATTR_RW(in0_max); |
---|
668 | 663 | |
---|
669 | 664 | 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) |
---|
671 | 667 | { |
---|
672 | 668 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
673 | 669 | struct w83627hf_data *data = w83627hf_update_device(dev); |
---|
.. | .. |
---|
675 | 671 | (long)DIV_FROM_REG(data->fan_div[nr]))); |
---|
676 | 672 | } |
---|
677 | 673 | 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) |
---|
679 | 675 | { |
---|
680 | 676 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
681 | 677 | struct w83627hf_data *data = w83627hf_update_device(dev); |
---|
.. | .. |
---|
683 | 679 | (long)DIV_FROM_REG(data->fan_div[nr]))); |
---|
684 | 680 | } |
---|
685 | 681 | 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, |
---|
687 | 683 | const char *buf, size_t count) |
---|
688 | 684 | { |
---|
689 | 685 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
703 | 699 | mutex_unlock(&data->update_lock); |
---|
704 | 700 | return count; |
---|
705 | 701 | } |
---|
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); |
---|
711 | 702 | |
---|
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); |
---|
715 | 709 | |
---|
716 | 710 | 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) |
---|
718 | 712 | { |
---|
719 | 713 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
720 | 714 | struct w83627hf_data *data = w83627hf_update_device(dev); |
---|
.. | .. |
---|
725 | 719 | } |
---|
726 | 720 | |
---|
727 | 721 | 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) |
---|
730 | 723 | { |
---|
731 | 724 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
732 | 725 | struct w83627hf_data *data = w83627hf_update_device(dev); |
---|
.. | .. |
---|
737 | 730 | } |
---|
738 | 731 | |
---|
739 | 732 | 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, |
---|
741 | 734 | char *buf) |
---|
742 | 735 | { |
---|
743 | 736 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
749 | 742 | } |
---|
750 | 743 | |
---|
751 | 744 | 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, |
---|
753 | 746 | const char *buf, size_t count) |
---|
754 | 747 | { |
---|
755 | 748 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
771 | 764 | } |
---|
772 | 765 | |
---|
773 | 766 | 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, |
---|
775 | 768 | const char *buf, size_t count) |
---|
776 | 769 | { |
---|
777 | 770 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
792 | 785 | return count; |
---|
793 | 786 | } |
---|
794 | 787 | |
---|
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); |
---|
806 | 797 | |
---|
807 | 798 | static ssize_t |
---|
808 | 799 | cpu0_vid_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
.. | .. |
---|
847 | 838 | static DEVICE_ATTR_RO(alarms); |
---|
848 | 839 | |
---|
849 | 840 | 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) |
---|
851 | 842 | { |
---|
852 | 843 | struct w83627hf_data *data = w83627hf_update_device(dev); |
---|
853 | 844 | int bitnr = to_sensor_dev_attr(attr)->index; |
---|
854 | 845 | return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1); |
---|
855 | 846 | } |
---|
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); |
---|
871 | 862 | |
---|
872 | 863 | static ssize_t |
---|
873 | 864 | beep_mask_show(struct device *dev, struct device_attribute *attr, char *buf) |
---|
.. | .. |
---|
908 | 899 | static DEVICE_ATTR_RW(beep_mask); |
---|
909 | 900 | |
---|
910 | 901 | 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) |
---|
912 | 903 | { |
---|
913 | 904 | struct w83627hf_data *data = w83627hf_update_device(dev); |
---|
914 | 905 | int bitnr = to_sensor_dev_attr(attr)->index; |
---|
.. | .. |
---|
916 | 907 | } |
---|
917 | 908 | |
---|
918 | 909 | 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) |
---|
921 | 912 | { |
---|
922 | 913 | struct w83627hf_data *data = dev_get_drvdata(dev); |
---|
923 | 914 | int bitnr = to_sensor_dev_attr(attr)->index; |
---|
.. | .. |
---|
965 | 956 | return count; |
---|
966 | 957 | } |
---|
967 | 958 | |
---|
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); |
---|
1000 | 975 | |
---|
1001 | 976 | 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) |
---|
1003 | 978 | { |
---|
1004 | 979 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
1005 | 980 | struct w83627hf_data *data = w83627hf_update_device(dev); |
---|
.. | .. |
---|
1013 | 988 | * because the divisor changed. |
---|
1014 | 989 | */ |
---|
1015 | 990 | 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, |
---|
1017 | 992 | const char *buf, size_t count) |
---|
1018 | 993 | { |
---|
1019 | 994 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
1053 | 1028 | return count; |
---|
1054 | 1029 | } |
---|
1055 | 1030 | |
---|
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); |
---|
1062 | 1034 | |
---|
1063 | 1035 | 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) |
---|
1065 | 1037 | { |
---|
1066 | 1038 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
1067 | 1039 | struct w83627hf_data *data = w83627hf_update_device(dev); |
---|
.. | .. |
---|
1069 | 1041 | } |
---|
1070 | 1042 | |
---|
1071 | 1043 | static ssize_t |
---|
1072 | | -store_pwm(struct device *dev, struct device_attribute *devattr, |
---|
| 1044 | +pwm_store(struct device *dev, struct device_attribute *devattr, |
---|
1073 | 1045 | const char *buf, size_t count) |
---|
1074 | 1046 | { |
---|
1075 | 1047 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
1102 | 1074 | return count; |
---|
1103 | 1075 | } |
---|
1104 | 1076 | |
---|
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); |
---|
1108 | 1080 | |
---|
1109 | 1081 | 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) |
---|
1111 | 1084 | { |
---|
1112 | 1085 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
1113 | 1086 | struct w83627hf_data *data = w83627hf_update_device(dev); |
---|
.. | .. |
---|
1115 | 1088 | } |
---|
1116 | 1089 | |
---|
1117 | 1090 | 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) |
---|
1120 | 1093 | { |
---|
1121 | 1094 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
1122 | 1095 | struct w83627hf_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
1140 | 1113 | return count; |
---|
1141 | 1114 | } |
---|
1142 | 1115 | |
---|
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); |
---|
1149 | 1119 | |
---|
1150 | 1120 | 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) |
---|
1152 | 1122 | { |
---|
1153 | 1123 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
1154 | 1124 | struct w83627hf_data *data = w83627hf_update_device(dev); |
---|
.. | .. |
---|
1161 | 1131 | } |
---|
1162 | 1132 | |
---|
1163 | 1133 | 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, |
---|
1165 | 1135 | const char *buf, size_t count) |
---|
1166 | 1136 | { |
---|
1167 | 1137 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
1192 | 1162 | return count; |
---|
1193 | 1163 | } |
---|
1194 | 1164 | |
---|
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); |
---|
1201 | 1168 | |
---|
1202 | 1169 | 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, |
---|
1204 | 1171 | char *buf) |
---|
1205 | 1172 | { |
---|
1206 | 1173 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
1209 | 1176 | } |
---|
1210 | 1177 | |
---|
1211 | 1178 | 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, |
---|
1213 | 1180 | const char *buf, size_t count) |
---|
1214 | 1181 | { |
---|
1215 | 1182 | int nr = to_sensor_dev_attr(devattr)->index; |
---|
.. | .. |
---|
1246 | 1213 | case W83781D_DEFAULT_BETA: |
---|
1247 | 1214 | dev_warn(dev, "Sensor type %d is deprecated, please use 4 " |
---|
1248 | 1215 | "instead\n", W83781D_DEFAULT_BETA); |
---|
1249 | | - /* fall through */ |
---|
| 1216 | + fallthrough; |
---|
1250 | 1217 | case 4: /* thermistor */ |
---|
1251 | 1218 | tmp = w83627hf_read_value(data, W83781D_REG_SCFG1); |
---|
1252 | 1219 | w83627hf_write_value(data, W83781D_REG_SCFG1, |
---|
.. | .. |
---|
1264 | 1231 | return count; |
---|
1265 | 1232 | } |
---|
1266 | 1233 | |
---|
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); |
---|
1274 | 1237 | |
---|
1275 | 1238 | static ssize_t |
---|
1276 | 1239 | name_show(struct device *dev, struct device_attribute *devattr, char *buf) |
---|
.. | .. |
---|
1604 | 1567 | |
---|
1605 | 1568 | return 0; |
---|
1606 | 1569 | } |
---|
1607 | | - |
---|
1608 | 1570 | |
---|
1609 | 1571 | /* Registers 0x50-0x5f are banked */ |
---|
1610 | 1572 | static inline void w83627hf_set_bank(struct w83627hf_data *data, u16 reg) |
---|