diff options
author | Che-Liang Chiou <clchiou@chromium.org> | 2012-07-12 12:02:44 +0800 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-07-12 02:09:45 -0700 |
commit | 7ec9f717173ae08571c457bd39a067dd0ce2c471 (patch) | |
tree | f9bbe4e01d6f20868f9c7c59f5db92fe18c2d0f2 | |
parent | 88d9375f50726fb26f1d4fcb909aa15256e24a17 (diff) | |
download | vboot-7ec9f717173ae08571c457bd39a067dd0ce2c471.tar.gz |
crossystem: Return error when trying to read GPIO port zero
For the record, zero is a valid GPIO port number. Unfortunately
firmware uses port zero to denote that a GPIO port is not exist.
So crossystem should not attempt to read GPIO port zero, but
return error instead.
Signed-off-by: Che-Liang Chiou <clchiou@chromium.org>
BUG=chrome-os-partner:11296
TEST=On Snow, run crossystem and see devsw_cur and recoverysw_cur
are "(error)"
Change-Id: I70b15824f613df1e46bf152515ad4e9362c9f066
Reviewed-on: https://gerrit.chromium.org/gerrit/27251
Commit-Ready: Che-Liang Chiou <clchiou@chromium.org>
Tested-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
-rw-r--r-- | host/arch/arm/lib/crossystem_arch.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/host/arch/arm/lib/crossystem_arch.c b/host/arch/arm/lib/crossystem_arch.c index d1030c89..1e5ecbad 100644 --- a/host/arch/arm/lib/crossystem_arch.c +++ b/host/arch/arm/lib/crossystem_arch.c @@ -238,7 +238,16 @@ static int VbGetVarGpio(const char* name) { gpio_num = ntohl(prop[1]); polarity = ntohl(prop[2]); - ret = VbGetGpioStatus(gpio_num) ^ polarity ^ 1; + /* + * TODO(chrome-os-partner:11296): Use gpio_num == 0 to denote non-exist + * GPIO for now, at the risk that one day we might actually want to read + * from a GPIO port 0. We should figure out how to represent "non-exist" + * properly. + */ + if (gpio_num) + ret = VbGetGpioStatus(gpio_num) ^ polarity ^ 1; + else + ret = -1; out: if (pp) free(pp); |