Lei YU | fe2db2b | 2017-11-24 15:30:54 +0800 | [diff] [blame] | 1 | From 26989b5e7c85ac1d5715a5ef2667335061920e96 Mon Sep 17 00:00:00 2001 |
| 2 | From: Lei YU <mine260309@gmail.com> |
| 3 | Date: Thu, 23 Nov 2017 16:14:51 +0800 |
| 4 | Subject: [PATCH] sysfs: Return -ETIMEDOUT instead of throw exception |
| 5 | |
| 6 | Aspeed fan tach gives ETIMEDOUT error when host is powered off, it |
| 7 | causes phosphor-hwmon exit with read failure exception. |
| 8 | Make it return -ETIMEDOUT so that it gives negative value for fan speed |
| 9 | as workaround. |
| 10 | |
| 11 | Signed-off-by: Lei YU <mine260309@gmail.com> |
| 12 | --- |
| 13 | sysfs.cpp | 6 ++++++ |
| 14 | 1 file changed, 6 insertions(+) |
| 15 | |
| 16 | diff --git a/sysfs.cpp b/sysfs.cpp |
| 17 | index 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 | -- |
| 34 | 1.9.1 |
| 35 | |