From 6a2f7452a635071a267d8a888a21038263efbca5 Mon Sep 17 00:00:00 2001 From: Raptor Engineering Development Team Date: Fri, 10 May 2019 05:28:43 +0000 Subject: hwmon/aspeed-pwm-tacho: Return 0 RPM if fan disconnected / failed Having a tachometer read return an -ETIMEDOUT error condition instead of 0 RPM due to a disconnected or failed fan is highly unexpected, and depending on higher level software can cause application failures. Return 0 RPM if tachometer cannot be read. This should trigger the same error paths in any sane fan control implementation without requiring special handling for the AST2x00 devices. Signed-off-by: Timothy Pearson --- drivers/hwmon/aspeed-pwm-tacho.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c index c4dd6301e7c8..a9bf01a46737 100644 --- a/drivers/hwmon/aspeed-pwm-tacho.c +++ b/drivers/hwmon/aspeed-pwm-tacho.c @@ -548,7 +548,11 @@ static int aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv, ASPEED_RPM_STATUS_SLEEP_USEC, usec); - /* return -ETIMEDOUT if we didn't get an answer. */ + /* if we got -ETIMEDOUT (no answer) return 0 RPM... */ + if (ret == -ETIMEDOUT) + return 0; + + /* ...otherwise return received error. */ if (ret) return ret; -- cgit v1.2.3