Add configure option for how read fails behave

Different platforms have different requirements for handling
hwmon sysfs access failures.

The default behavior is that a read failure leads to the daemon
exiting after some number of read failures.  This can be controlled
to then remove the object from the dbus on failure.  Now, it can
instead be controlled to return -errno on read failure.

This new behavior to set the value to -errno must be checked by
whatever mechanism is reporting the value.

Change-Id: I50b93aea56f22267da79c9571319f281e24a1e6f
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/configure.ac b/configure.ac
index 7c516f8..0878173 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,7 @@
     AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags])
 )
 
+# When a sensor access fails, just remove the sensor from dbus instead of exiting the daemon.
 AC_ARG_ENABLE([remove-from-dbus-on-fail],
     AS_HELP_STRING([--enable-remove-from-dbus-on-fail], [Remove properties from D-Bus on access failures])
 )
@@ -61,6 +62,19 @@
       AC_DEFINE_UNQUOTED([REMOVE_ON_FAIL], ["$REMOVE_ON_FAIL"], [Remove properties from D-Bus on access failures])
 )
 
+# When a sensor read fails, set the Value on dbus with -errno.
+# Incompatible with remove-from-dbus-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])
+)
+
+AC_ARG_VAR(NEGATIVE_ERRNO_ON_FAIL, [Set sensor value to -errno on read failures])
+
+AS_IF([test "x$enable_negative_errno_on_fail" == "xyes"],
+      [NEGATIVE_ERRNO_ON_FAIL="yes"]
+      AC_DEFINE_UNQUOTED([NEGATIVE_ERRNO_ON_FAIL], ["$NEGATIVE_ERRNO_ON_FAIL"], [Set sensor value to -errno on read failures])
+)
+
 AC_ARG_VAR(BUSNAME_PREFIX, [The DBus busname prefix.])
 AC_ARG_VAR(SENSOR_ROOT, [The DBus sensors namespace root.])
 AS_IF([test "x$BUSNAME_PREFIX" == "x"], [BUSNAME_PREFIX="xyz.openbmc_project.Hwmon"])