Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'hwmon-for-linus-v4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon fixes from Guenter Roeck:
"A couple of patches for the aspeed pwm fan driver"

* tag 'hwmon-for-linus-v4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
hwmon: (aspeed-pwm-tacho) make fan/pwm names start with index 1
hwmon: (aspeed-pwm-tacho) Call of_node_put() on a node not claimed
hwmon: (aspeed-pwm-tacho) On read failure return -ETIMEDOUT
hwmon: (aspeed-pwm-tacho) Select REGMAP

+36 -30
+1
drivers/hwmon/Kconfig
··· 343 343 344 344 config SENSORS_ASPEED 345 345 tristate "ASPEED AST2400/AST2500 PWM and Fan tach driver" 346 + select REGMAP 346 347 help 347 348 This driver provides support for ASPEED AST2400/AST2500 PWM 348 349 and Fan Tacho controllers.
+35 -30
drivers/hwmon/aspeed-pwm-tacho.c
··· 7 7 */ 8 8 9 9 #include <linux/clk.h> 10 + #include <linux/errno.h> 10 11 #include <linux/gpio/consumer.h> 11 12 #include <linux/delay.h> 12 13 #include <linux/hwmon.h> ··· 495 494 return clk / (clk_unit * div_h * div_l * tacho_div * tacho_unit); 496 495 } 497 496 498 - static u32 aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv, 497 + static int aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv, 499 498 u8 fan_tach_ch) 500 499 { 501 500 u32 raw_data, tach_div, clk_source, sec, val; ··· 511 510 msleep(sec); 512 511 513 512 regmap_read(priv->regmap, ASPEED_PTCR_RESULT, &val); 513 + if (!(val & RESULT_STATUS_MASK)) 514 + return -ETIMEDOUT; 515 + 514 516 raw_data = val & RESULT_VALUE_MASK; 515 517 tach_div = priv->type_fan_tach_clock_division[type]; 516 518 tach_div = 0x4 << (tach_div * 2); ··· 565 561 { 566 562 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 567 563 int index = sensor_attr->index; 568 - u32 rpm; 564 + int rpm; 569 565 struct aspeed_pwm_tacho_data *priv = dev_get_drvdata(dev); 570 566 571 567 rpm = aspeed_get_fan_tach_ch_rpm(priv, index); 568 + if (rpm < 0) 569 + return rpm; 572 570 573 - return sprintf(buf, "%u\n", rpm); 571 + return sprintf(buf, "%d\n", rpm); 574 572 } 575 573 576 574 static umode_t pwm_is_visible(struct kobject *kobj, ··· 597 591 return a->mode; 598 592 } 599 593 600 - static SENSOR_DEVICE_ATTR(pwm0, 0644, 601 - show_pwm, set_pwm, 0); 602 594 static SENSOR_DEVICE_ATTR(pwm1, 0644, 603 - show_pwm, set_pwm, 1); 595 + show_pwm, set_pwm, 0); 604 596 static SENSOR_DEVICE_ATTR(pwm2, 0644, 605 - show_pwm, set_pwm, 2); 597 + show_pwm, set_pwm, 1); 606 598 static SENSOR_DEVICE_ATTR(pwm3, 0644, 607 - show_pwm, set_pwm, 3); 599 + show_pwm, set_pwm, 2); 608 600 static SENSOR_DEVICE_ATTR(pwm4, 0644, 609 - show_pwm, set_pwm, 4); 601 + show_pwm, set_pwm, 3); 610 602 static SENSOR_DEVICE_ATTR(pwm5, 0644, 611 - show_pwm, set_pwm, 5); 603 + show_pwm, set_pwm, 4); 612 604 static SENSOR_DEVICE_ATTR(pwm6, 0644, 613 - show_pwm, set_pwm, 6); 605 + show_pwm, set_pwm, 5); 614 606 static SENSOR_DEVICE_ATTR(pwm7, 0644, 607 + show_pwm, set_pwm, 6); 608 + static SENSOR_DEVICE_ATTR(pwm8, 0644, 615 609 show_pwm, set_pwm, 7); 616 610 static struct attribute *pwm_dev_attrs[] = { 617 - &sensor_dev_attr_pwm0.dev_attr.attr, 618 611 &sensor_dev_attr_pwm1.dev_attr.attr, 619 612 &sensor_dev_attr_pwm2.dev_attr.attr, 620 613 &sensor_dev_attr_pwm3.dev_attr.attr, ··· 621 616 &sensor_dev_attr_pwm5.dev_attr.attr, 622 617 &sensor_dev_attr_pwm6.dev_attr.attr, 623 618 &sensor_dev_attr_pwm7.dev_attr.attr, 619 + &sensor_dev_attr_pwm8.dev_attr.attr, 624 620 NULL, 625 621 }; 626 622 ··· 630 624 .is_visible = pwm_is_visible, 631 625 }; 632 626 633 - static SENSOR_DEVICE_ATTR(fan0_input, 0444, 634 - show_rpm, NULL, 0); 635 627 static SENSOR_DEVICE_ATTR(fan1_input, 0444, 636 - show_rpm, NULL, 1); 628 + show_rpm, NULL, 0); 637 629 static SENSOR_DEVICE_ATTR(fan2_input, 0444, 638 - show_rpm, NULL, 2); 630 + show_rpm, NULL, 1); 639 631 static SENSOR_DEVICE_ATTR(fan3_input, 0444, 640 - show_rpm, NULL, 3); 632 + show_rpm, NULL, 2); 641 633 static SENSOR_DEVICE_ATTR(fan4_input, 0444, 642 - show_rpm, NULL, 4); 634 + show_rpm, NULL, 3); 643 635 static SENSOR_DEVICE_ATTR(fan5_input, 0444, 644 - show_rpm, NULL, 5); 636 + show_rpm, NULL, 4); 645 637 static SENSOR_DEVICE_ATTR(fan6_input, 0444, 646 - show_rpm, NULL, 6); 638 + show_rpm, NULL, 5); 647 639 static SENSOR_DEVICE_ATTR(fan7_input, 0444, 648 - show_rpm, NULL, 7); 640 + show_rpm, NULL, 6); 649 641 static SENSOR_DEVICE_ATTR(fan8_input, 0444, 650 - show_rpm, NULL, 8); 642 + show_rpm, NULL, 7); 651 643 static SENSOR_DEVICE_ATTR(fan9_input, 0444, 652 - show_rpm, NULL, 9); 644 + show_rpm, NULL, 8); 653 645 static SENSOR_DEVICE_ATTR(fan10_input, 0444, 654 - show_rpm, NULL, 10); 646 + show_rpm, NULL, 9); 655 647 static SENSOR_DEVICE_ATTR(fan11_input, 0444, 656 - show_rpm, NULL, 11); 648 + show_rpm, NULL, 10); 657 649 static SENSOR_DEVICE_ATTR(fan12_input, 0444, 658 - show_rpm, NULL, 12); 650 + show_rpm, NULL, 11); 659 651 static SENSOR_DEVICE_ATTR(fan13_input, 0444, 660 - show_rpm, NULL, 13); 652 + show_rpm, NULL, 12); 661 653 static SENSOR_DEVICE_ATTR(fan14_input, 0444, 662 - show_rpm, NULL, 14); 654 + show_rpm, NULL, 13); 663 655 static SENSOR_DEVICE_ATTR(fan15_input, 0444, 656 + show_rpm, NULL, 14); 657 + static SENSOR_DEVICE_ATTR(fan16_input, 0444, 664 658 show_rpm, NULL, 15); 665 659 static struct attribute *fan_dev_attrs[] = { 666 - &sensor_dev_attr_fan0_input.dev_attr.attr, 667 660 &sensor_dev_attr_fan1_input.dev_attr.attr, 668 661 &sensor_dev_attr_fan2_input.dev_attr.attr, 669 662 &sensor_dev_attr_fan3_input.dev_attr.attr, ··· 678 673 &sensor_dev_attr_fan13_input.dev_attr.attr, 679 674 &sensor_dev_attr_fan14_input.dev_attr.attr, 680 675 &sensor_dev_attr_fan15_input.dev_attr.attr, 676 + &sensor_dev_attr_fan16_input.dev_attr.attr, 681 677 NULL 682 678 }; 683 679 ··· 808 802 if (ret) 809 803 return ret; 810 804 } 811 - of_node_put(np); 812 805 813 806 priv->groups[0] = &pwm_dev_group; 814 807 priv->groups[1] = &fan_dev_group;