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
Unified · Split
| @@ -343,6 +343,7 @@ config SENSORS_ASB100 · 342 unmodified lines | ||
| 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. |
| @@ -7,6 +7,7 @@ · 6 unmodified lines | ||
| 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> |
| @@ -494,7 +495,7 @@ static u32 aspeed_get_fan_tach_ch_measure_period(struct aspeed_pwm_tacho_data · 481 unmodified lines | ||
| 494 | 495 | return clk / (clk_unit * div_h * div_l * tacho_div * tacho_unit); |
| 495 | 496 | } |
| 496 | 497 | |
| 497 | −static u32 aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv, | |
| 498 | +static int aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv, | |
| 498 | 499 | u8 fan_tach_ch) |
| 499 | 500 | { |
| 500 | 501 | u32 raw_data, tach_div, clk_source, sec, val; |
| @@ -510,6 +511,9 @@ static u32 aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv, · 9 unmodified lines | ||
| 510 | 511 | msleep(sec); |
| 511 | 512 | |
| 512 | 513 | regmap_read(priv->regmap, ASPEED_PTCR_RESULT, &val); |
| 514 | + if (!(val & RESULT_STATUS_MASK)) | |
| 515 | + return -ETIMEDOUT; | |
| 516 | + | |
| 513 | 517 | raw_data = val & RESULT_VALUE_MASK; |
| 514 | 518 | tach_div = priv->type_fan_tach_clock_division[type]; |
| 515 | 519 | tach_div = 0x4 << (tach_div * 2); |
| @@ -561,12 +565,14 @@ static ssize_t show_rpm(struct device *dev, struct device_attribute *attr, · 45 unmodified lines | ||
| 561 | 565 | { |
| 562 | 566 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
| 563 | 567 | int index = sensor_attr->index; |
| 564 | − u32 rpm; | |
| 568 | + int rpm; | |
| 565 | 569 | struct aspeed_pwm_tacho_data *priv = dev_get_drvdata(dev); |
| 566 | 570 | |
| 567 | 571 | rpm = aspeed_get_fan_tach_ch_rpm(priv, index); |
| 572 | + if (rpm < 0) | |
| 573 | + return rpm; | |
| 568 | 574 | |
| 569 | − return sprintf(buf, "%u\n", rpm); | |
| 575 | + return sprintf(buf, "%d\n", rpm); | |
| 570 | 576 | } |
| 571 | 577 | |
| 572 | 578 | static umode_t pwm_is_visible(struct kobject *kobj, |
| @@ -591,24 +597,23 @@ static umode_t fan_dev_is_visible(struct kobject *kobj, · 18 unmodified lines | ||
| 591 | 597 | return a->mode; |
| 592 | 598 | } |
| 593 | 599 | |
| 594 | −static SENSOR_DEVICE_ATTR(pwm0, 0644, | |
| 595 | − show_pwm, set_pwm, 0); | |
| 596 | 600 | static SENSOR_DEVICE_ATTR(pwm1, 0644, |
| 597 | − show_pwm, set_pwm, 1); | |
| 601 | + show_pwm, set_pwm, 0); | |
| 598 | 602 | static SENSOR_DEVICE_ATTR(pwm2, 0644, |
| 599 | − show_pwm, set_pwm, 2); | |
| 603 | + show_pwm, set_pwm, 1); | |
| 600 | 604 | static SENSOR_DEVICE_ATTR(pwm3, 0644, |
| 601 | − show_pwm, set_pwm, 3); | |
| 605 | + show_pwm, set_pwm, 2); | |
| 602 | 606 | static SENSOR_DEVICE_ATTR(pwm4, 0644, |
| 603 | − show_pwm, set_pwm, 4); | |
| 607 | + show_pwm, set_pwm, 3); | |
| 604 | 608 | static SENSOR_DEVICE_ATTR(pwm5, 0644, |
| 605 | − show_pwm, set_pwm, 5); | |
| 609 | + show_pwm, set_pwm, 4); | |
| 606 | 610 | static SENSOR_DEVICE_ATTR(pwm6, 0644, |
| 607 | − show_pwm, set_pwm, 6); | |
| 611 | + show_pwm, set_pwm, 5); | |
| 608 | 612 | static SENSOR_DEVICE_ATTR(pwm7, 0644, |
| 613 | + show_pwm, set_pwm, 6); | |
| 614 | +static SENSOR_DEVICE_ATTR(pwm8, 0644, | |
| 609 | 615 | show_pwm, set_pwm, 7); |
| 610 | 616 | static struct attribute *pwm_dev_attrs[] = { |
| 611 | − &sensor_dev_attr_pwm0.dev_attr.attr, | |
| 612 | 617 | &sensor_dev_attr_pwm1.dev_attr.attr, |
| 613 | 618 | &sensor_dev_attr_pwm2.dev_attr.attr, |
| 614 | 619 | &sensor_dev_attr_pwm3.dev_attr.attr, |
| @@ -616,6 +621,7 @@ static struct attribute *pwm_dev_attrs[] = { · 1 unmodified line | ||
| 616 | 621 | &sensor_dev_attr_pwm5.dev_attr.attr, |
| 617 | 622 | &sensor_dev_attr_pwm6.dev_attr.attr, |
| 618 | 623 | &sensor_dev_attr_pwm7.dev_attr.attr, |
| 624 | + &sensor_dev_attr_pwm8.dev_attr.attr, | |
| 619 | 625 | NULL, |
| 620 | 626 | }; |
| 621 | 627 | |
| @@ -624,40 +630,39 @@ static const struct attribute_group pwm_dev_group = { · 2 unmodified lines | ||
| 624 | 630 | .is_visible = pwm_is_visible, |
| 625 | 631 | }; |
| 626 | 632 | |
| 627 | −static SENSOR_DEVICE_ATTR(fan0_input, 0444, | |
| 628 | − show_rpm, NULL, 0); | |
| 629 | 633 | static SENSOR_DEVICE_ATTR(fan1_input, 0444, |
| 630 | − show_rpm, NULL, 1); | |
| 634 | + show_rpm, NULL, 0); | |
| 631 | 635 | static SENSOR_DEVICE_ATTR(fan2_input, 0444, |
| 632 | − show_rpm, NULL, 2); | |
| 636 | + show_rpm, NULL, 1); | |
| 633 | 637 | static SENSOR_DEVICE_ATTR(fan3_input, 0444, |
| 634 | − show_rpm, NULL, 3); | |
| 638 | + show_rpm, NULL, 2); | |
| 635 | 639 | static SENSOR_DEVICE_ATTR(fan4_input, 0444, |
| 636 | − show_rpm, NULL, 4); | |
| 640 | + show_rpm, NULL, 3); | |
| 637 | 641 | static SENSOR_DEVICE_ATTR(fan5_input, 0444, |
| 638 | − show_rpm, NULL, 5); | |
| 642 | + show_rpm, NULL, 4); | |
| 639 | 643 | static SENSOR_DEVICE_ATTR(fan6_input, 0444, |
| 640 | − show_rpm, NULL, 6); | |
| 644 | + show_rpm, NULL, 5); | |
| 641 | 645 | static SENSOR_DEVICE_ATTR(fan7_input, 0444, |
| 642 | − show_rpm, NULL, 7); | |
| 646 | + show_rpm, NULL, 6); | |
| 643 | 647 | static SENSOR_DEVICE_ATTR(fan8_input, 0444, |
| 644 | − show_rpm, NULL, 8); | |
| 648 | + show_rpm, NULL, 7); | |
| 645 | 649 | static SENSOR_DEVICE_ATTR(fan9_input, 0444, |
| 646 | − show_rpm, NULL, 9); | |
| 650 | + show_rpm, NULL, 8); | |
| 647 | 651 | static SENSOR_DEVICE_ATTR(fan10_input, 0444, |
| 648 | − show_rpm, NULL, 10); | |
| 652 | + show_rpm, NULL, 9); | |
| 649 | 653 | static SENSOR_DEVICE_ATTR(fan11_input, 0444, |
| 650 | − show_rpm, NULL, 11); | |
| 654 | + show_rpm, NULL, 10); | |
| 651 | 655 | static SENSOR_DEVICE_ATTR(fan12_input, 0444, |
| 652 | − show_rpm, NULL, 12); | |
| 656 | + show_rpm, NULL, 11); | |
| 653 | 657 | static SENSOR_DEVICE_ATTR(fan13_input, 0444, |
| 654 | − show_rpm, NULL, 13); | |
| 658 | + show_rpm, NULL, 12); | |
| 655 | 659 | static SENSOR_DEVICE_ATTR(fan14_input, 0444, |
| 656 | − show_rpm, NULL, 14); | |
| 660 | + show_rpm, NULL, 13); | |
| 657 | 661 | static SENSOR_DEVICE_ATTR(fan15_input, 0444, |
| 662 | + show_rpm, NULL, 14); | |
| 663 | +static SENSOR_DEVICE_ATTR(fan16_input, 0444, | |
| 658 | 664 | show_rpm, NULL, 15); |
| 659 | 665 | static struct attribute *fan_dev_attrs[] = { |
| 660 | − &sensor_dev_attr_fan0_input.dev_attr.attr, | |
| 661 | 666 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
| 662 | 667 | &sensor_dev_attr_fan2_input.dev_attr.attr, |
| 663 | 668 | &sensor_dev_attr_fan3_input.dev_attr.attr, |
| @@ -673,6 +678,7 @@ static struct attribute *fan_dev_attrs[] = { · 9 unmodified lines | ||
| 673 | 678 | &sensor_dev_attr_fan13_input.dev_attr.attr, |
| 674 | 679 | &sensor_dev_attr_fan14_input.dev_attr.attr, |
| 675 | 680 | &sensor_dev_attr_fan15_input.dev_attr.attr, |
| 681 | + &sensor_dev_attr_fan16_input.dev_attr.attr, | |
| 676 | 682 | NULL |
| 677 | 683 | }; |
| 678 | 684 | |
| @@ -802,7 +808,6 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev) · 123 unmodified lines | ||
| 802 | 808 | if (ret) |
| 803 | 809 | return ret; |
| 804 | 810 | } |
| 805 | − of_node_put(np); | |
| 806 | 811 | |
| 807 | 812 | priv->groups[0] = &pwm_dev_group; |
| 808 | 813 | priv->groups[1] = &fan_dev_group; |