summaryrefslogtreecommitdiff
path: root/common/gpio_commands.c
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2022-03-15 16:54:53 -0600
committerCommit Bot <commit-bot@chromium.org>2022-03-16 00:49:07 +0000
commit46106ca390e23b43e275599e7dba4fa369e8e301 (patch)
tree05f4f677ef28a7330f6a79d8d504664ac2c26eb9 /common/gpio_commands.c
parent8840c71b910438ed90f5af7372bc6710d3cf07f7 (diff)
downloadchrome-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>
Diffstat (limited to 'common/gpio_commands.c')
-rw-r--r--common/gpio_commands.c27
1 files changed, 11 insertions, 16 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));