blob: 67268b3ead7dacbd0ab663335a6271700e240e9a [file] [log] [blame]
Lei YUfe2db2b2017-11-24 15:30:54 +08001From 26989b5e7c85ac1d5715a5ef2667335061920e96 Mon Sep 17 00:00:00 2001
2From: Lei YU <mine260309@gmail.com>
3Date: Thu, 23 Nov 2017 16:14:51 +0800
4Subject: [PATCH] sysfs: Return -ETIMEDOUT instead of throw exception
5
6Aspeed fan tach gives ETIMEDOUT error when host is powered off, it
7causes phosphor-hwmon exit with read failure exception.
8Make it return -ETIMEDOUT so that it gives negative value for fan speed
9as workaround.
10
11Signed-off-by: Lei YU <mine260309@gmail.com>
12---
13 sysfs.cpp | 6 ++++++
14 1 file changed, 6 insertions(+)
15
16diff --git a/sysfs.cpp b/sysfs.cpp
17index 369d2e7..f390de6 100644
18--- a/sysfs.cpp
19+++ b/sysfs.cpp
20@@ -308,6 +308,12 @@ uint32_t HwmonIO::read(
21 throw std::system_error(rc, std::generic_category());
22 }
23
24+ if (rc == ETIMEDOUT)
25+ {
26+ // Workaround for AST fan tach driver
27+ // that returns -ETIMEDOUT when fan is not runnings
28+ return -rc;
29+ }
30 --retries;
31 std::this_thread::sleep_for(delay);
32 continue;
33--
341.9.1
35