summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/gpio_commands.c27
-rw-r--r--include/gpio.h6
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