AU: fix bug in GPIO handler that caused failed discovery to be ignored
This solves two issues:
* The GPIO handler will attempt to use GPIO devices even when discovery
via udev has failed. Not any more.
* GPIO discovery would return success even when it failed on a previous
attempt. Now it'll reflect the actual result of the discovery attempt.
* Reporting of file descriptor open errors is obscured due to
intermittent operations that reset errno, now fixed.
* Added test case to ensure that repeat GPIO discovery is not attempted,
and that test mode check will automatically fail if a previous
initialization/discovery had failed.
BUG=None
TEST=Passes unit tests
TEST=All symptoms gone on real update attempt w/ x86-alex
Change-Id: I01a7b1e316dbb5b94487a5aad1560d994feae9ff
Reviewed-on: https://gerrit.chromium.org/gerrit/40946
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/gpio_handler.h b/gpio_handler.h
index c71043a..d1db7c2 100644
--- a/gpio_handler.h
+++ b/gpio_handler.h
@@ -216,7 +216,7 @@
void ResetTestModeSignalingFlags();
// Attempt GPIO discovery, at most once. Returns true if discovery process was
- // successfully completed or already attempted, false otherwise.
+ // successfully completed, false otherwise.
bool DiscoverGpios();
// Assigns a copy of the device name of GPIO |id| to |dev_path_p|. Assumes
@@ -290,8 +290,10 @@
// cached, or reestablished on each query.
const bool is_cache_test_mode_;
- // Indicates whether GPIO discovery was performed.
+ // Indicates whether GPIO discovery was performed, and whether it's been
+ // successful.
bool is_discovery_attempted_;
+ bool is_discovery_successful_;
// Persistent state of the test mode check.
bool is_first_check_;