From 01ce9130d4ebdad11839e20b0706510b6f5e954b Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Wed, 11 Dec 2024 09:15:08 +0300 Subject: [PATCH] cmd: quiet mode for gpio (Maslov Nikita - ec45ae5e7c44a6f8ecf26750235fc404f4118c5f) --- cmd/gpio.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/gpio.c b/cmd/gpio.c index 7a43dc6ab18..fa31dae8597 100644 --- a/cmd/gpio.c +++ b/cmd/gpio.c @@ -138,6 +138,7 @@ static int do_gpio(struct cmd_tbl *cmdtp, int flag, int argc, unsigned int gpio; enum gpio_cmd sub_cmd; int value; + bool quiet = 0; const char *str_cmd, *str_gpio = NULL; #ifdef CONFIG_CMD_GPIO_READ const char *str_var = NULL; @@ -187,6 +188,11 @@ static int do_gpio(struct cmd_tbl *cmdtp, int flag, int argc, goto show_usage; /* parse the behavior */ + if (*str_cmd == 'q') { + quiet = true; + str_cmd++; + } + switch (*str_cmd) { case 'i': sub_cmd = GPIOC_INPUT; @@ -261,7 +267,8 @@ static int do_gpio(struct cmd_tbl *cmdtp, int flag, int argc, } gpio_direction_output(gpio, value); } - printf("gpio: pin %s (gpio %u) value is ", str_gpio, gpio); + if (!quiet) + printf("gpio: pin %s (gpio %u) value is ", str_gpio, gpio); if (IS_ERR_VALUE(value)) { printf("unknown (ret=%d)\n", value); @@ -308,8 +315,9 @@ static int do_gpio(struct cmd_tbl *cmdtp, int flag, int argc, U_BOOT_CMD(gpio, 4, 0, do_gpio, "query and control gpio pins", - " \n" + "[q] \n" " - input/set/clear/toggle the specified pin\n" + " first 'q' for quiet mode\n" #ifdef CONFIG_CMD_GPIO_READ "gpio read \n" " - set environment variable 'name' to the specified pin\n"