diff options
author | Keith Short <keithshort@chromium.org> | 2022-03-15 16:54:53 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-03-16 00:49:07 +0000 |
commit | 46106ca390e23b43e275599e7dba4fa369e8e301 (patch) | |
tree | 05f4f677ef28a7330f6a79d8d504664ac2c26eb9 | |
parent | 8840c71b910438ed90f5af7372bc6710d3cf07f7 (diff) | |
download | chrome-ec-46106ca390e23b43e275599e7dba4fa369e8e301.tar.gz |
gpio: Cleanup CONFIG_CMD_GPIO_EXTENDED
Cleanup the GPIO flag descriptios used by GPIO_CMD_GPIO_EXTENDED. This
doesn't save any code size, but simplifies the logic.
BUG=none
BRANCH=none
TEST=make buildall
TEST=zmake testall
Signed-off-by: Keith Short <keithshort@chromium.org>
Change-Id: I71f0db12a2b65bcc2e2bdf6dc48fb643c5cd6c6e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3526272
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r-- | common/gpio_commands.c | 27 | ||||
-rw-r--r-- | include/gpio.h | 6 |
2 files changed, 13 insertions, 20 deletions
diff --git a/common/gpio_commands.c b/common/gpio_commands.c index 2f6293dbf6..b044524797 100644 --- a/common/gpio_commands.c +++ b/common/gpio_commands.c @@ -82,47 +82,42 @@ struct gpio_flag_description { const char* name; }; -const struct gpio_flag_description gpio_descriptions[] = { +__maybe_unused static const struct gpio_flag_description gpio_descriptions[] = { {GPIO_INPUT, "I"}, {GPIO_OUTPUT, "O"}, {GPIO_LOW, "L"}, {GPIO_HIGH, "H"}, -#ifndef CONFIG_ZEPHYR - {GPIO_ANALOG, "A"}, -#endif {GPIO_OPEN_DRAIN, "ODR"}, {GPIO_PULL_UP, "PU"}, {GPIO_PULL_DOWN, "PD"}, -#ifndef CONFIG_ZEPHYR - {GPIO_ALTERNATE, "ALT"}, -#endif {GPIO_SEL_1P8V, "1P8"}, #ifndef CONFIG_ZEPHYR + {GPIO_ANALOG, "A"}, + {GPIO_ALTERNATE, "ALT"}, {GPIO_LOCKED, "LCK"} #endif }; static void print_gpio_info(int gpio) { - int changed, v, flags, i; + int changed, v, i; if (!gpio_is_implemented(gpio)) return; /* Skip unsupported signals */ v = gpio_get_level(gpio); -#ifdef CONFIG_CMD_GPIO_EXTENDED - flags = gpio_get_flags(gpio); -#else - flags = 0; -#endif changed = last_val_changed(gpio, v); /* Split the printf call into multiple calls to reduce the stack usage. */ ccprintf(" %d%c ", v, (changed ? '*' : ' ')); - for (i = 0; i < ARRAY_SIZE(gpio_descriptions); i++) { - if (flags & gpio_descriptions[i].bitfield) - ccprintf("%s ", gpio_descriptions[i].name); + if (IS_ENABLED(CONFIG_CMD_GPIO_EXTENDED)) { + int flags = gpio_get_flags(gpio); + + for (i = 0; i < ARRAY_SIZE(gpio_descriptions); i++) { + if (flags & gpio_descriptions[i].bitfield) + ccprintf("%s ", gpio_descriptions[i].name); + } } ccprintf("%s\n", gpio_get_name(gpio)); diff --git a/include/gpio.h b/include/gpio.h index e581021e09..d57d6417ab 100644 --- a/include/gpio.h +++ b/include/gpio.h @@ -285,9 +285,8 @@ void gpio_set_flags(enum gpio_signal signal, int flags); #define CONFIG_GPIO_GET_EXTENDED #endif -#ifdef CONFIG_GPIO_GET_EXTENDED /** - * Get the current flags for a signal. + * Get the current flags for a signal. Requires CONFIG_GPIO_GET_EXTENDED. * * @param signal Signal to get flags for * @returns The flags that are currently defined for this signal @@ -295,13 +294,12 @@ void gpio_set_flags(enum gpio_signal signal, int flags); int gpio_get_flags(enum gpio_signal signal); /** - * Get flags for GPIO by port and mask. + * Get flags for GPIO by port and mask. Requires CONFIG_GPIO_GET_EXTENDED. * * @param port GPIO port to set (GPIO_*) * @param mask Bitmask of pins on that port to check: one only. */ int gpio_get_flags_by_mask(uint32_t port, uint32_t mask); -#endif #ifdef CONFIG_ZEPHYR |