sensor: Add UPDATE_FUNCTIONAL_ON_FAIL and its behavior
Add the build switch UPDATE_FUNCTIONAL_ON_FAIL. When enabled, sensor
read failures will not exit the mainloop. Instead, mainloop will update
the Functional property and skip the read of that sensor.
This will skip the "Remove RCs" check during value interface creation in
MainLoop::getObject. However, it will perform the "Remove RCs" checks
during MainLoop::read.
Tested: I was able to use busctl to read the Functional property of a
custom driver to test with UPDATE_FUNCTIONAL_ON_FAIL defined.
1. Negative values were reported, Functional was true
2. Sensor reporting errors had stale values, Functional was set to false
Resolves: openbmc/phosphor-hwmon#10
Signed-off-by: Brandon Kim <brandonkim@google.com>
Change-Id: I0984dad12250e9587ec36de2f9212de0b0e1cda6
diff --git a/configure.ac b/configure.ac
index c189114..289f34a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,8 +161,13 @@
)
# When a sensor read fails, set the Value on dbus with -errno.
+# It will also skip the "Remove RCs" check.
+# Incompatible with update-functional-on-fail.
AC_ARG_ENABLE([negative-errno-on-fail],
- AS_HELP_STRING([--enable-negative-errno-on-fail], [Set sensor value to -errno on read failures])
+ AS_HELP_STRING(
+ [--enable-negative-errno-on-fail],
+ [Set sensor value to -errno on read failures. Incompatible with update-functional-on-fail]
+ )
)
AC_ARG_VAR(NEGATIVE_ERRNO_ON_FAIL, [Set sensor value to -errno on read failures])
@@ -171,10 +176,40 @@
[NEGATIVE_ERRNO_ON_FAIL="yes"]
AC_DEFINE_UNQUOTED(
[NEGATIVE_ERRNO_ON_FAIL],
- ["$NEGATIVE_ERRNO_ON_FAIL"], [Set sensor value to -errno on read failures]
+ ["$NEGATIVE_ERRNO_ON_FAIL"],
+ [Set sensor value to -errno on read failures]
)
)
+# When a sensor read fails, update the OperationalState interface's Functional property.
+# This will mark the sensor as not functional and skip reading from that sensor.
+# It will skip the "Remove RCs" check during value interface creation in MainLoop::getObject.
+# However, it will perform the "Remove RCs" checks during MainLoop::read.
+# Incompatible with negative-errno-on-fail.
+AC_ARG_ENABLE([update-functional-on-fail],
+ AS_HELP_STRING(
+ [--enable-update-functional-on-fail],
+ [Update functional property on read failures. Incompatible with negative-errno-on-fail]
+ )
+)
+
+AC_ARG_VAR(UPDATE_FUNCTIONAL_ON_FAIL, [Update functional property on read failures])
+AS_IF(
+ [test "x$enable_update_functional_on_fail" == "xyes"],
+ [UPDATE_FUNCTIONAL_ON_FAIL="yes"]
+ AC_DEFINE_UNQUOTED(
+ [UPDATE_FUNCTIONAL_ON_FAIL],
+ ["$UPDATE_FUNCTIONAL_ON_FAIL"],
+ [Update functional property on sensor read failures]
+ )
+)
+
+AS_IF([test "x$enable_negative_errno_on_fail" == "xyes"], [
+ AS_IF([test "x$enable_update_functional_on_fail" == "xyes"], [
+ AC_MSG_ERROR([Invalid configuration enabling both negative-errno-on-fail and update-functional-on-fail.])
+ ])
+])
+
AC_ARG_VAR(BUSNAME_PREFIX, [The DBus busname prefix.])
AC_ARG_VAR(SENSOR_ROOT, [The DBus sensors namespace root.])
AS_IF(