diff options
Diffstat (limited to 'drivers/hwmon/w83792d.c')
-rw-r--r-- | drivers/hwmon/w83792d.c | 86 |
1 files changed, 54 insertions, 32 deletions
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 958602e28412..4ef884c216e2 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c | |||
@@ -250,8 +250,6 @@ FAN_TO_REG(long rpm, int div) | |||
250 | : (val)) / 1000, 0, 0xff)) | 250 | : (val)) / 1000, 0, 0xff)) |
251 | #define TEMP_ADD_TO_REG_LOW(val) ((val%1000) ? 0x80 : 0x00) | 251 | #define TEMP_ADD_TO_REG_LOW(val) ((val%1000) ? 0x80 : 0x00) |
252 | 252 | ||
253 | #define PWM_FROM_REG(val) (val) | ||
254 | #define PWM_TO_REG(val) (SENSORS_LIMIT((val),0,255)) | ||
255 | #define DIV_FROM_REG(val) (1 << (val)) | 253 | #define DIV_FROM_REG(val) (1 << (val)) |
256 | 254 | ||
257 | static inline u8 | 255 | static inline u8 |
@@ -291,7 +289,6 @@ struct w83792d_data { | |||
291 | u8 pwm[7]; /* We only consider the first 3 set of pwm, | 289 | u8 pwm[7]; /* We only consider the first 3 set of pwm, |
292 | although 792 chip has 7 set of pwm. */ | 290 | although 792 chip has 7 set of pwm. */ |
293 | u8 pwmenable[3]; | 291 | u8 pwmenable[3]; |
294 | u8 pwm_mode[7]; /* indicates PWM or DC mode: 1->PWM; 0->DC */ | ||
295 | u32 alarms; /* realtime status register encoding,combined */ | 292 | u32 alarms; /* realtime status register encoding,combined */ |
296 | u8 chassis; /* Chassis status */ | 293 | u8 chassis; /* Chassis status */ |
297 | u8 chassis_clear; /* CLR_CHS, clear chassis intrusion detection */ | 294 | u8 chassis_clear; /* CLR_CHS, clear chassis intrusion detection */ |
@@ -375,8 +372,10 @@ static ssize_t store_in_##reg (struct device *dev, \ | |||
375 | u32 val; \ | 372 | u32 val; \ |
376 | \ | 373 | \ |
377 | val = simple_strtoul(buf, NULL, 10); \ | 374 | val = simple_strtoul(buf, NULL, 10); \ |
375 | mutex_lock(&data->update_lock); \ | ||
378 | data->in_##reg[nr] = SENSORS_LIMIT(IN_TO_REG(nr, val)/4, 0, 255); \ | 376 | data->in_##reg[nr] = SENSORS_LIMIT(IN_TO_REG(nr, val)/4, 0, 255); \ |
379 | w83792d_write_value(client, W83792D_REG_IN_##REG[nr], data->in_##reg[nr]); \ | 377 | w83792d_write_value(client, W83792D_REG_IN_##REG[nr], data->in_##reg[nr]); \ |
378 | mutex_unlock(&data->update_lock); \ | ||
380 | \ | 379 | \ |
381 | return count; \ | 380 | return count; \ |
382 | } | 381 | } |
@@ -443,9 +442,11 @@ store_fan_min(struct device *dev, struct device_attribute *attr, | |||
443 | u32 val; | 442 | u32 val; |
444 | 443 | ||
445 | val = simple_strtoul(buf, NULL, 10); | 444 | val = simple_strtoul(buf, NULL, 10); |
445 | mutex_lock(&data->update_lock); | ||
446 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 446 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
447 | w83792d_write_value(client, W83792D_REG_FAN_MIN[nr], | 447 | w83792d_write_value(client, W83792D_REG_FAN_MIN[nr], |
448 | data->fan_min[nr]); | 448 | data->fan_min[nr]); |
449 | mutex_unlock(&data->update_lock); | ||
449 | 450 | ||
450 | return count; | 451 | return count; |
451 | } | 452 | } |
@@ -478,6 +479,7 @@ store_fan_div(struct device *dev, struct device_attribute *attr, | |||
478 | u8 tmp_fan_div; | 479 | u8 tmp_fan_div; |
479 | 480 | ||
480 | /* Save fan_min */ | 481 | /* Save fan_min */ |
482 | mutex_lock(&data->update_lock); | ||
481 | min = FAN_FROM_REG(data->fan_min[nr], | 483 | min = FAN_FROM_REG(data->fan_min[nr], |
482 | DIV_FROM_REG(data->fan_div[nr])); | 484 | DIV_FROM_REG(data->fan_div[nr])); |
483 | 485 | ||
@@ -493,6 +495,7 @@ store_fan_div(struct device *dev, struct device_attribute *attr, | |||
493 | /* Restore fan_min */ | 495 | /* Restore fan_min */ |
494 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); | 496 | data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr])); |
495 | w83792d_write_value(client, W83792D_REG_FAN_MIN[nr], data->fan_min[nr]); | 497 | w83792d_write_value(client, W83792D_REG_FAN_MIN[nr], data->fan_min[nr]); |
498 | mutex_unlock(&data->update_lock); | ||
496 | 499 | ||
497 | return count; | 500 | return count; |
498 | } | 501 | } |
@@ -547,10 +550,11 @@ static ssize_t store_temp1(struct device *dev, struct device_attribute *attr, | |||
547 | s32 val; | 550 | s32 val; |
548 | 551 | ||
549 | val = simple_strtol(buf, NULL, 10); | 552 | val = simple_strtol(buf, NULL, 10); |
550 | 553 | mutex_lock(&data->update_lock); | |
551 | data->temp1[nr] = TEMP1_TO_REG(val); | 554 | data->temp1[nr] = TEMP1_TO_REG(val); |
552 | w83792d_write_value(client, W83792D_REG_TEMP1[nr], | 555 | w83792d_write_value(client, W83792D_REG_TEMP1[nr], |
553 | data->temp1[nr]); | 556 | data->temp1[nr]); |
557 | mutex_unlock(&data->update_lock); | ||
554 | 558 | ||
555 | return count; | 559 | return count; |
556 | } | 560 | } |
@@ -580,13 +584,14 @@ static ssize_t store_temp23(struct device *dev, struct device_attribute *attr, | |||
580 | s32 val; | 584 | s32 val; |
581 | 585 | ||
582 | val = simple_strtol(buf, NULL, 10); | 586 | val = simple_strtol(buf, NULL, 10); |
583 | 587 | mutex_lock(&data->update_lock); | |
584 | data->temp_add[nr][index] = TEMP_ADD_TO_REG_HIGH(val); | 588 | data->temp_add[nr][index] = TEMP_ADD_TO_REG_HIGH(val); |
585 | data->temp_add[nr][index+1] = TEMP_ADD_TO_REG_LOW(val); | 589 | data->temp_add[nr][index+1] = TEMP_ADD_TO_REG_LOW(val); |
586 | w83792d_write_value(client, W83792D_REG_TEMP_ADD[nr][index], | 590 | w83792d_write_value(client, W83792D_REG_TEMP_ADD[nr][index], |
587 | data->temp_add[nr][index]); | 591 | data->temp_add[nr][index]); |
588 | w83792d_write_value(client, W83792D_REG_TEMP_ADD[nr][index+1], | 592 | w83792d_write_value(client, W83792D_REG_TEMP_ADD[nr][index+1], |
589 | data->temp_add[nr][index+1]); | 593 | data->temp_add[nr][index+1]); |
594 | mutex_unlock(&data->update_lock); | ||
590 | 595 | ||
591 | return count; | 596 | return count; |
592 | } | 597 | } |
@@ -627,7 +632,7 @@ show_pwm(struct device *dev, struct device_attribute *attr, | |||
627 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 632 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
628 | int nr = sensor_attr->index; | 633 | int nr = sensor_attr->index; |
629 | struct w83792d_data *data = w83792d_update_device(dev); | 634 | struct w83792d_data *data = w83792d_update_device(dev); |
630 | return sprintf(buf, "%ld\n", (long) PWM_FROM_REG(data->pwm[nr-1])); | 635 | return sprintf(buf, "%d\n", (data->pwm[nr] & 0x0f) << 4); |
631 | } | 636 | } |
632 | 637 | ||
633 | static ssize_t | 638 | static ssize_t |
@@ -659,14 +664,16 @@ store_pwm(struct device *dev, struct device_attribute *attr, | |||
659 | const char *buf, size_t count) | 664 | const char *buf, size_t count) |
660 | { | 665 | { |
661 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 666 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
662 | int nr = sensor_attr->index - 1; | 667 | int nr = sensor_attr->index; |
663 | struct i2c_client *client = to_i2c_client(dev); | 668 | struct i2c_client *client = to_i2c_client(dev); |
664 | struct w83792d_data *data = i2c_get_clientdata(client); | 669 | struct w83792d_data *data = i2c_get_clientdata(client); |
665 | u32 val; | 670 | u8 val = SENSORS_LIMIT(simple_strtoul(buf, NULL, 10), 0, 255) >> 4; |
666 | 671 | ||
667 | val = simple_strtoul(buf, NULL, 10); | 672 | mutex_lock(&data->update_lock); |
668 | data->pwm[nr] = PWM_TO_REG(val); | 673 | val |= w83792d_read_value(client, W83792D_REG_PWM[nr]) & 0xf0; |
674 | data->pwm[nr] = val; | ||
669 | w83792d_write_value(client, W83792D_REG_PWM[nr], data->pwm[nr]); | 675 | w83792d_write_value(client, W83792D_REG_PWM[nr], data->pwm[nr]); |
676 | mutex_unlock(&data->update_lock); | ||
670 | 677 | ||
671 | return count; | 678 | return count; |
672 | } | 679 | } |
@@ -683,6 +690,10 @@ store_pwmenable(struct device *dev, struct device_attribute *attr, | |||
683 | u8 fan_cfg_tmp, cfg1_tmp, cfg2_tmp, cfg3_tmp, cfg4_tmp; | 690 | u8 fan_cfg_tmp, cfg1_tmp, cfg2_tmp, cfg3_tmp, cfg4_tmp; |
684 | 691 | ||
685 | val = simple_strtoul(buf, NULL, 10); | 692 | val = simple_strtoul(buf, NULL, 10); |
693 | if (val < 1 || val > 3) | ||
694 | return -EINVAL; | ||
695 | |||
696 | mutex_lock(&data->update_lock); | ||
686 | switch (val) { | 697 | switch (val) { |
687 | case 1: | 698 | case 1: |
688 | data->pwmenable[nr] = 0; /* manual mode */ | 699 | data->pwmenable[nr] = 0; /* manual mode */ |
@@ -693,8 +704,6 @@ store_pwmenable(struct device *dev, struct device_attribute *attr, | |||
693 | case 3: | 704 | case 3: |
694 | data->pwmenable[nr] = 1; /* thermal cruise/Smart Fan I */ | 705 | data->pwmenable[nr] = 1; /* thermal cruise/Smart Fan I */ |
695 | break; | 706 | break; |
696 | default: | ||
697 | return -EINVAL; | ||
698 | } | 707 | } |
699 | cfg1_tmp = data->pwmenable[0]; | 708 | cfg1_tmp = data->pwmenable[0]; |
700 | cfg2_tmp = (data->pwmenable[1]) << 2; | 709 | cfg2_tmp = (data->pwmenable[1]) << 2; |
@@ -702,14 +711,15 @@ store_pwmenable(struct device *dev, struct device_attribute *attr, | |||
702 | cfg4_tmp = w83792d_read_value(client,W83792D_REG_FAN_CFG) & 0xc0; | 711 | cfg4_tmp = w83792d_read_value(client,W83792D_REG_FAN_CFG) & 0xc0; |
703 | fan_cfg_tmp = ((cfg4_tmp | cfg3_tmp) | cfg2_tmp) | cfg1_tmp; | 712 | fan_cfg_tmp = ((cfg4_tmp | cfg3_tmp) | cfg2_tmp) | cfg1_tmp; |
704 | w83792d_write_value(client, W83792D_REG_FAN_CFG, fan_cfg_tmp); | 713 | w83792d_write_value(client, W83792D_REG_FAN_CFG, fan_cfg_tmp); |
714 | mutex_unlock(&data->update_lock); | ||
705 | 715 | ||
706 | return count; | 716 | return count; |
707 | } | 717 | } |
708 | 718 | ||
709 | static struct sensor_device_attribute sda_pwm[] = { | 719 | static struct sensor_device_attribute sda_pwm[] = { |
710 | SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1), | 720 | SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 0), |
711 | SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2), | 721 | SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1), |
712 | SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 3), | 722 | SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2), |
713 | }; | 723 | }; |
714 | static struct sensor_device_attribute sda_pwm_enable[] = { | 724 | static struct sensor_device_attribute sda_pwm_enable[] = { |
715 | SENSOR_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, | 725 | SENSOR_ATTR(pwm1_enable, S_IWUSR | S_IRUGO, |
@@ -728,7 +738,7 @@ show_pwm_mode(struct device *dev, struct device_attribute *attr, | |||
728 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 738 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
729 | int nr = sensor_attr->index; | 739 | int nr = sensor_attr->index; |
730 | struct w83792d_data *data = w83792d_update_device(dev); | 740 | struct w83792d_data *data = w83792d_update_device(dev); |
731 | return sprintf(buf, "%d\n", data->pwm_mode[nr-1]); | 741 | return sprintf(buf, "%d\n", data->pwm[nr] >> 7); |
732 | } | 742 | } |
733 | 743 | ||
734 | static ssize_t | 744 | static ssize_t |
@@ -736,29 +746,35 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr, | |||
736 | const char *buf, size_t count) | 746 | const char *buf, size_t count) |
737 | { | 747 | { |
738 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 748 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
739 | int nr = sensor_attr->index - 1; | 749 | int nr = sensor_attr->index; |
740 | struct i2c_client *client = to_i2c_client(dev); | 750 | struct i2c_client *client = to_i2c_client(dev); |
741 | struct w83792d_data *data = i2c_get_clientdata(client); | 751 | struct w83792d_data *data = i2c_get_clientdata(client); |
742 | u32 val; | 752 | u32 val; |
743 | u8 pwm_mode_mask = 0; | ||
744 | 753 | ||
745 | val = simple_strtoul(buf, NULL, 10); | 754 | val = simple_strtoul(buf, NULL, 10); |
746 | data->pwm_mode[nr] = SENSORS_LIMIT(val, 0, 1); | 755 | if (val != 0 && val != 1) |
747 | pwm_mode_mask = w83792d_read_value(client, | 756 | return -EINVAL; |
748 | W83792D_REG_PWM[nr]) & 0x7f; | 757 | |
749 | w83792d_write_value(client, W83792D_REG_PWM[nr], | 758 | mutex_lock(&data->update_lock); |
750 | ((data->pwm_mode[nr]) << 7) | pwm_mode_mask); | 759 | data->pwm[nr] = w83792d_read_value(client, W83792D_REG_PWM[nr]); |
760 | if (val) { /* PWM mode */ | ||
761 | data->pwm[nr] |= 0x80; | ||
762 | } else { /* DC mode */ | ||
763 | data->pwm[nr] &= 0x7f; | ||
764 | } | ||
765 | w83792d_write_value(client, W83792D_REG_PWM[nr], data->pwm[nr]); | ||
766 | mutex_unlock(&data->update_lock); | ||
751 | 767 | ||
752 | return count; | 768 | return count; |
753 | } | 769 | } |
754 | 770 | ||
755 | static struct sensor_device_attribute sda_pwm_mode[] = { | 771 | static struct sensor_device_attribute sda_pwm_mode[] = { |
756 | SENSOR_ATTR(pwm1_mode, S_IWUSR | S_IRUGO, | 772 | SENSOR_ATTR(pwm1_mode, S_IWUSR | S_IRUGO, |
757 | show_pwm_mode, store_pwm_mode, 1), | 773 | show_pwm_mode, store_pwm_mode, 0), |
758 | SENSOR_ATTR(pwm2_mode, S_IWUSR | S_IRUGO, | 774 | SENSOR_ATTR(pwm2_mode, S_IWUSR | S_IRUGO, |
759 | show_pwm_mode, store_pwm_mode, 2), | 775 | show_pwm_mode, store_pwm_mode, 1), |
760 | SENSOR_ATTR(pwm3_mode, S_IWUSR | S_IRUGO, | 776 | SENSOR_ATTR(pwm3_mode, S_IWUSR | S_IRUGO, |
761 | show_pwm_mode, store_pwm_mode, 3), | 777 | show_pwm_mode, store_pwm_mode, 2), |
762 | }; | 778 | }; |
763 | 779 | ||
764 | 780 | ||
@@ -789,12 +805,13 @@ store_chassis_clear(struct device *dev, struct device_attribute *attr, | |||
789 | u8 temp1 = 0, temp2 = 0; | 805 | u8 temp1 = 0, temp2 = 0; |
790 | 806 | ||
791 | val = simple_strtoul(buf, NULL, 10); | 807 | val = simple_strtoul(buf, NULL, 10); |
792 | 808 | mutex_lock(&data->update_lock); | |
793 | data->chassis_clear = SENSORS_LIMIT(val, 0 ,1); | 809 | data->chassis_clear = SENSORS_LIMIT(val, 0 ,1); |
794 | temp1 = ((data->chassis_clear) << 7) & 0x80; | 810 | temp1 = ((data->chassis_clear) << 7) & 0x80; |
795 | temp2 = w83792d_read_value(client, | 811 | temp2 = w83792d_read_value(client, |
796 | W83792D_REG_CHASSIS_CLR) & 0x7f; | 812 | W83792D_REG_CHASSIS_CLR) & 0x7f; |
797 | w83792d_write_value(client, W83792D_REG_CHASSIS_CLR, temp1 | temp2); | 813 | w83792d_write_value(client, W83792D_REG_CHASSIS_CLR, temp1 | temp2); |
814 | mutex_unlock(&data->update_lock); | ||
798 | 815 | ||
799 | return count; | 816 | return count; |
800 | } | 817 | } |
@@ -827,10 +844,12 @@ store_thermal_cruise(struct device *dev, struct device_attribute *attr, | |||
827 | val = simple_strtoul(buf, NULL, 10); | 844 | val = simple_strtoul(buf, NULL, 10); |
828 | target_tmp = val; | 845 | target_tmp = val; |
829 | target_tmp = target_tmp & 0x7f; | 846 | target_tmp = target_tmp & 0x7f; |
847 | mutex_lock(&data->update_lock); | ||
830 | target_mask = w83792d_read_value(client, W83792D_REG_THERMAL[nr]) & 0x80; | 848 | target_mask = w83792d_read_value(client, W83792D_REG_THERMAL[nr]) & 0x80; |
831 | data->thermal_cruise[nr] = SENSORS_LIMIT(target_tmp, 0, 255); | 849 | data->thermal_cruise[nr] = SENSORS_LIMIT(target_tmp, 0, 255); |
832 | w83792d_write_value(client, W83792D_REG_THERMAL[nr], | 850 | w83792d_write_value(client, W83792D_REG_THERMAL[nr], |
833 | (data->thermal_cruise[nr]) | target_mask); | 851 | (data->thermal_cruise[nr]) | target_mask); |
852 | mutex_unlock(&data->update_lock); | ||
834 | 853 | ||
835 | return count; | 854 | return count; |
836 | } | 855 | } |
@@ -867,6 +886,7 @@ store_tolerance(struct device *dev, struct device_attribute *attr, | |||
867 | u8 tol_tmp, tol_mask; | 886 | u8 tol_tmp, tol_mask; |
868 | 887 | ||
869 | val = simple_strtoul(buf, NULL, 10); | 888 | val = simple_strtoul(buf, NULL, 10); |
889 | mutex_lock(&data->update_lock); | ||
870 | tol_mask = w83792d_read_value(client, | 890 | tol_mask = w83792d_read_value(client, |
871 | W83792D_REG_TOLERANCE[nr]) & ((nr == 1) ? 0x0f : 0xf0); | 891 | W83792D_REG_TOLERANCE[nr]) & ((nr == 1) ? 0x0f : 0xf0); |
872 | tol_tmp = SENSORS_LIMIT(val, 0, 15); | 892 | tol_tmp = SENSORS_LIMIT(val, 0, 15); |
@@ -877,6 +897,7 @@ store_tolerance(struct device *dev, struct device_attribute *attr, | |||
877 | } | 897 | } |
878 | w83792d_write_value(client, W83792D_REG_TOLERANCE[nr], | 898 | w83792d_write_value(client, W83792D_REG_TOLERANCE[nr], |
879 | tol_mask | tol_tmp); | 899 | tol_mask | tol_tmp); |
900 | mutex_unlock(&data->update_lock); | ||
880 | 901 | ||
881 | return count; | 902 | return count; |
882 | } | 903 | } |
@@ -915,11 +936,13 @@ store_sf2_point(struct device *dev, struct device_attribute *attr, | |||
915 | u8 mask_tmp = 0; | 936 | u8 mask_tmp = 0; |
916 | 937 | ||
917 | val = simple_strtoul(buf, NULL, 10); | 938 | val = simple_strtoul(buf, NULL, 10); |
939 | mutex_lock(&data->update_lock); | ||
918 | data->sf2_points[index][nr] = SENSORS_LIMIT(val, 0, 127); | 940 | data->sf2_points[index][nr] = SENSORS_LIMIT(val, 0, 127); |
919 | mask_tmp = w83792d_read_value(client, | 941 | mask_tmp = w83792d_read_value(client, |
920 | W83792D_REG_POINTS[index][nr]) & 0x80; | 942 | W83792D_REG_POINTS[index][nr]) & 0x80; |
921 | w83792d_write_value(client, W83792D_REG_POINTS[index][nr], | 943 | w83792d_write_value(client, W83792D_REG_POINTS[index][nr], |
922 | mask_tmp|data->sf2_points[index][nr]); | 944 | mask_tmp|data->sf2_points[index][nr]); |
945 | mutex_unlock(&data->update_lock); | ||
923 | 946 | ||
924 | return count; | 947 | return count; |
925 | } | 948 | } |
@@ -979,6 +1002,7 @@ store_sf2_level(struct device *dev, struct device_attribute *attr, | |||
979 | u8 mask_tmp=0, level_tmp=0; | 1002 | u8 mask_tmp=0, level_tmp=0; |
980 | 1003 | ||
981 | val = simple_strtoul(buf, NULL, 10); | 1004 | val = simple_strtoul(buf, NULL, 10); |
1005 | mutex_lock(&data->update_lock); | ||
982 | data->sf2_levels[index][nr] = SENSORS_LIMIT((val * 15) / 100, 0, 15); | 1006 | data->sf2_levels[index][nr] = SENSORS_LIMIT((val * 15) / 100, 0, 15); |
983 | mask_tmp = w83792d_read_value(client, W83792D_REG_LEVELS[index][nr]) | 1007 | mask_tmp = w83792d_read_value(client, W83792D_REG_LEVELS[index][nr]) |
984 | & ((nr==3) ? 0xf0 : 0x0f); | 1008 | & ((nr==3) ? 0xf0 : 0x0f); |
@@ -988,6 +1012,7 @@ store_sf2_level(struct device *dev, struct device_attribute *attr, | |||
988 | level_tmp = data->sf2_levels[index][nr] << 4; | 1012 | level_tmp = data->sf2_levels[index][nr] << 4; |
989 | } | 1013 | } |
990 | w83792d_write_value(client, W83792D_REG_LEVELS[index][nr], level_tmp | mask_tmp); | 1014 | w83792d_write_value(client, W83792D_REG_LEVELS[index][nr], level_tmp | mask_tmp); |
1015 | mutex_unlock(&data->update_lock); | ||
991 | 1016 | ||
992 | return count; | 1017 | return count; |
993 | } | 1018 | } |
@@ -1373,7 +1398,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) | |||
1373 | struct i2c_client *client = to_i2c_client(dev); | 1398 | struct i2c_client *client = to_i2c_client(dev); |
1374 | struct w83792d_data *data = i2c_get_clientdata(client); | 1399 | struct w83792d_data *data = i2c_get_clientdata(client); |
1375 | int i, j; | 1400 | int i, j; |
1376 | u8 reg_array_tmp[4], pwm_array_tmp[7], reg_tmp; | 1401 | u8 reg_array_tmp[4], reg_tmp; |
1377 | 1402 | ||
1378 | mutex_lock(&data->update_lock); | 1403 | mutex_lock(&data->update_lock); |
1379 | 1404 | ||
@@ -1402,10 +1427,8 @@ static struct w83792d_data *w83792d_update_device(struct device *dev) | |||
1402 | data->fan_min[i] = w83792d_read_value(client, | 1427 | data->fan_min[i] = w83792d_read_value(client, |
1403 | W83792D_REG_FAN_MIN[i]); | 1428 | W83792D_REG_FAN_MIN[i]); |
1404 | /* Update the PWM/DC Value and PWM/DC flag */ | 1429 | /* Update the PWM/DC Value and PWM/DC flag */ |
1405 | pwm_array_tmp[i] = w83792d_read_value(client, | 1430 | data->pwm[i] = w83792d_read_value(client, |
1406 | W83792D_REG_PWM[i]); | 1431 | W83792D_REG_PWM[i]); |
1407 | data->pwm[i] = pwm_array_tmp[i] & 0x0f; | ||
1408 | data->pwm_mode[i] = pwm_array_tmp[i] >> 7; | ||
1409 | } | 1432 | } |
1410 | 1433 | ||
1411 | reg_tmp = w83792d_read_value(client, W83792D_REG_FAN_CFG); | 1434 | reg_tmp = w83792d_read_value(client, W83792D_REG_FAN_CFG); |
@@ -1513,7 +1536,6 @@ static void w83792d_print_debug(struct w83792d_data *data, struct device *dev) | |||
1513 | dev_dbg(dev, "fan[%d] is: 0x%x\n", i, data->fan[i]); | 1536 | dev_dbg(dev, "fan[%d] is: 0x%x\n", i, data->fan[i]); |
1514 | dev_dbg(dev, "fan[%d] min is: 0x%x\n", i, data->fan_min[i]); | 1537 | dev_dbg(dev, "fan[%d] min is: 0x%x\n", i, data->fan_min[i]); |
1515 | dev_dbg(dev, "pwm[%d] is: 0x%x\n", i, data->pwm[i]); | 1538 | dev_dbg(dev, "pwm[%d] is: 0x%x\n", i, data->pwm[i]); |
1516 | dev_dbg(dev, "pwm_mode[%d] is: 0x%x\n", i, data->pwm_mode[i]); | ||
1517 | } | 1539 | } |
1518 | dev_dbg(dev, "3 set of Temperatures: =====>\n"); | 1540 | dev_dbg(dev, "3 set of Temperatures: =====>\n"); |
1519 | for (i=0; i<3; i++) { | 1541 | for (i=0; i<3; i++) { |