diff options
author | Patrick Venture <venture@google.com> | 2017-05-30 15:42:01 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2017-05-30 18:15:40 -0400 |
commit | 7ed1c5e5ddbb87aef9df7f8a8a714bcffe90f0eb (patch) | |
tree | 3c99738ca60c33f8cf559cafde0ccabcec4a4afe /drivers/hwmon/aspeed-pwm-tacho.c | |
parent | 08fd5e76c268b7a5353302825b6b63a6027ddd0a (diff) |
hwmon: (aspeed-pwm-tacho) On read failure return -ETIMEDOUT
When the controller fails to provide an RPM reading within the alloted
time; the driver returns -ETIMEDOUT and no file contents.
Signed-off-by: Patrick Venture <venture@google.com>
Fixes: 2d7a548a3eff ("drivers: hwmon: Support for ASPEED PWM/Fan tach")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/aspeed-pwm-tacho.c')
-rw-r--r-- | drivers/hwmon/aspeed-pwm-tacho.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c index 48403a2115be..12b716b70ead 100644 --- a/drivers/hwmon/aspeed-pwm-tacho.c +++ b/drivers/hwmon/aspeed-pwm-tacho.c | |||
@@ -7,6 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/clk.h> | 9 | #include <linux/clk.h> |
10 | #include <linux/errno.h> | ||
10 | #include <linux/gpio/consumer.h> | 11 | #include <linux/gpio/consumer.h> |
11 | #include <linux/delay.h> | 12 | #include <linux/delay.h> |
12 | #include <linux/hwmon.h> | 13 | #include <linux/hwmon.h> |
@@ -494,7 +495,7 @@ static u32 aspeed_get_fan_tach_ch_measure_period(struct aspeed_pwm_tacho_data | |||
494 | return clk / (clk_unit * div_h * div_l * tacho_div * tacho_unit); | 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 | u8 fan_tach_ch) | 499 | u8 fan_tach_ch) |
499 | { | 500 | { |
500 | u32 raw_data, tach_div, clk_source, sec, val; | 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, | |||
510 | msleep(sec); | 511 | msleep(sec); |
511 | 512 | ||
512 | regmap_read(priv->regmap, ASPEED_PTCR_RESULT, &val); | 513 | regmap_read(priv->regmap, ASPEED_PTCR_RESULT, &val); |
514 | if (!(val & RESULT_STATUS_MASK)) | ||
515 | return -ETIMEDOUT; | ||
516 | |||
513 | raw_data = val & RESULT_VALUE_MASK; | 517 | raw_data = val & RESULT_VALUE_MASK; |
514 | tach_div = priv->type_fan_tach_clock_division[type]; | 518 | tach_div = priv->type_fan_tach_clock_division[type]; |
515 | tach_div = 0x4 << (tach_div * 2); | 519 | tach_div = 0x4 << (tach_div * 2); |
@@ -561,12 +565,14 @@ static ssize_t show_rpm(struct device *dev, struct device_attribute *attr, | |||
561 | { | 565 | { |
562 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 566 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
563 | int index = sensor_attr->index; | 567 | int index = sensor_attr->index; |
564 | u32 rpm; | 568 | int rpm; |
565 | struct aspeed_pwm_tacho_data *priv = dev_get_drvdata(dev); | 569 | struct aspeed_pwm_tacho_data *priv = dev_get_drvdata(dev); |
566 | 570 | ||
567 | rpm = aspeed_get_fan_tach_ch_rpm(priv, index); | 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 | static umode_t pwm_is_visible(struct kobject *kobj, | 578 | static umode_t pwm_is_visible(struct kobject *kobj, |