summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean Paul <seanpaul@chromium.org>2011-10-17 13:50:25 -0400
committerSean Paul <seanpaul@chromium.org>2011-10-17 12:31:10 -0700
commit78c42c6a7987169b67248efe27239d6389ca4c69 (patch)
treed3a0221ebe6d0f0b39ec2450a77507a2dc574415 /lib
parent644f14b121f76d55267e1fc6930a02c6cc10c26d (diff)
CHROMIUM: Clean up cros gpio code
This CL simplifies how cros gpios are handled by moving the required logic out of cros_gpio.c and into the application logic. This means that cros_gpio.c assumes that none of the gpios are required, and just returns an error when fetch is called. It's up to the caller of fetch to determine whether or not they should ignore the error or act upon it. BUG=chromium-os:21700 TEST=Tested on asymptote, ensured gpio access worked as expected. Change-Id: Ief3f1915026bfe981d345b9cc4709fef19edc7bf Signed-off-by: Sean Paul <seanpaul@chromium.org> Reviewed-on: http://gerrit.chromium.org/gerrit/10174 Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/vbexport/misc.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/vbexport/misc.c b/lib/vbexport/misc.c
index 6af3bb4b625..925d64d9413 100644
--- a/lib/vbexport/misc.c
+++ b/lib/vbexport/misc.c
@@ -21,24 +21,20 @@ uint32_t VbExIsShutdownRequested(void)
{
cros_gpio_t lidsw, pwrsw;
- if (cros_gpio_fetch(CROS_GPIO_LIDSW, &lidsw) ||
- cros_gpio_fetch(CROS_GPIO_PWRSW, &pwrsw)) {
- VBDEBUG(PREFIX "Failed to fetch GPIO!\n");
- /* still return 0, No-Shutdown-Requested */
- return 0;
- }
-
/* if lid is NOT OPEN */
- if (!lidsw.value) {
+ if (!cros_gpio_fetch(CROS_GPIO_LIDSW, &lidsw) && !lidsw.value) {
VBDEBUG(PREFIX "Lid-closed is detected.\n");
return 1;
}
-
- if (pwrsw.value) {
+ /* if power switch is pressed */
+ if (!cros_gpio_fetch(CROS_GPIO_PWRSW, &pwrsw) && pwrsw.value) {
VBDEBUG(PREFIX "Power-key-pressed is detected.\n");
return 1;
}
-
+ /*
+ * Either the gpios don't exist, or the lid is up and and power button
+ * is not pressed. No-Shutdown-Requested.
+ */
return 0;
}