diff options
author | Andrew McRae <amcrae@google.com> | 2022-08-23 10:38:20 +1000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-08-23 01:55:24 +0000 |
commit | e519e9a65ce9024b7e9e987609cac5d944502955 (patch) | |
tree | 1b31157c692a4d747da5c3386b1ca5d5d320bb14 /zephyr/shim | |
parent | 698b3d82d7ff8470e6acd72c06772e3a219fd666 (diff) | |
download | chrome-ec-e519e9a65ce9024b7e9e987609cac5d944502955.tar.gz |
gpio: Use alternative if gpio_pin_get_config not supported
If gpio_pin_get_config is not supported for a GPIO device, use
the alternative method to return the pin value.
BUG=b:243309500
TEST=twister -T zephyr/test/{drivers,ap_power}
BRANCH=none
Signed-off-by: Andrew McRae <amcrae@google.com>
Change-Id: Ib2b8e6ebd4c910509e302e84ab862a09c2eb35ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3847002
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Diffstat (limited to 'zephyr/shim')
-rw-r--r-- | zephyr/shim/src/gpio.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/zephyr/shim/src/gpio.c b/zephyr/shim/src/gpio.c index de62be3e1c..e52667bf26 100644 --- a/zephyr/shim/src/gpio.c +++ b/zephyr/shim/src/gpio.c @@ -105,12 +105,18 @@ int gpio_get_level(enum gpio_signal signal) gpio_flags_t flags; rv = gpio_pin_get_config_dt(&configs[signal].spec, &flags); - if (rv != 0) { + if (rv == 0) { + return (flags & GPIO_OUTPUT_INIT_HIGH) ? 1 : 0; + } + /* + * -ENOSYS is returned when this API call is not supported, + * so drop into the default method of returning the pin value. + */ + if (rv != -ENOSYS) { LOG_ERR("Cannot get config for %s (%d)", configs[signal].name, rv); return 0; } - return (flags & GPIO_OUTPUT_INIT_HIGH) ? 1 : 0; } const int l = gpio_pin_get_raw(configs[signal].spec.port, |