diff mbox series

[U-Boot,v2,03/19] gpio: Use more command-specific enums values

Message ID 20190121215336.74802-4-sjg@chromium.org
State Accepted
Delegated to: Philipp Tomsich
Headers show
Series rockchip: Add support for Bob Chromebook | expand

Commit Message

Simon Glass Jan. 21, 2019, 9:53 p.m. UTC
At present this file uses GPIO_OUTPUT and GPIO_INPUT as its sub-command
values. These are pretty generic names. Add a 'C' suffix to avoid possible
conflicts.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 cmd/gpio.c | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

Comments

Philipp Tomsich Jan. 31, 2019, 9:18 p.m. UTC | #1
> At present this file uses GPIO_OUTPUT and GPIO_INPUT as its sub-command
> values. These are pretty generic names. Add a 'C' suffix to avoid possible
> conflicts.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
> Changes in v2: None
> 
>  cmd/gpio.c | 37 +++++++++++++++++++++++--------------
>  1 file changed, 23 insertions(+), 14 deletions(-)
> 

Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Philipp Tomsich April 21, 2019, 4:56 p.m. UTC | #2
> At present this file uses GPIO_OUTPUT and GPIO_INPUT as its sub-command
> values. These are pretty generic names. Add a 'C' suffix to avoid possible
> conflicts.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> ---
> 
> Changes in v2: None
> 
>  cmd/gpio.c | 37 +++++++++++++++++++++++--------------
>  1 file changed, 23 insertions(+), 14 deletions(-)
> 

Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
diff mbox series

Patch

diff --git a/cmd/gpio.c b/cmd/gpio.c
index c60946bc06..4ac1f1e418 100644
--- a/cmd/gpio.c
+++ b/cmd/gpio.c
@@ -18,10 +18,10 @@  __weak int name_to_gpio(const char *name)
 }
 
 enum gpio_cmd {
-	GPIO_INPUT,
-	GPIO_SET,
-	GPIO_CLEAR,
-	GPIO_TOGGLE,
+	GPIOC_INPUT,
+	GPIOC_SET,
+	GPIOC_CLEAR,
+	GPIOC_TOGGLE,
 };
 
 #if defined(CONFIG_DM_GPIO) && !defined(gpio_status)
@@ -158,11 +158,20 @@  static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	/* parse the behavior */
 	switch (*str_cmd) {
-		case 'i': sub_cmd = GPIO_INPUT;  break;
-		case 's': sub_cmd = GPIO_SET;    break;
-		case 'c': sub_cmd = GPIO_CLEAR;  break;
-		case 't': sub_cmd = GPIO_TOGGLE; break;
-		default:  goto show_usage;
+	case 'i':
+		sub_cmd = GPIOC_INPUT;
+		break;
+	case 's':
+		sub_cmd = GPIOC_SET;
+		break;
+	case 'c':
+		sub_cmd = GPIOC_CLEAR;
+		break;
+	case 't':
+		sub_cmd = GPIOC_TOGGLE;
+		break;
+	default:
+		goto show_usage;
 	}
 
 #if defined(CONFIG_DM_GPIO)
@@ -192,18 +201,18 @@  static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	}
 
 	/* finally, let's do it: set direction and exec command */
-	if (sub_cmd == GPIO_INPUT) {
+	if (sub_cmd == GPIOC_INPUT) {
 		gpio_direction_input(gpio);
 		value = gpio_get_value(gpio);
 	} else {
 		switch (sub_cmd) {
-		case GPIO_SET:
+		case GPIOC_SET:
 			value = 1;
 			break;
-		case GPIO_CLEAR:
+		case GPIOC_CLEAR:
 			value = 0;
 			break;
-		case GPIO_TOGGLE:
+		case GPIOC_TOGGLE:
 			value = gpio_get_value(gpio);
 			if (!IS_ERR_VALUE(value))
 				value = !value;
@@ -218,7 +227,7 @@  static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		printf("unknown (ret=%d)\n", value);
 	else
 		printf("%d\n", value);
-	if (sub_cmd != GPIO_INPUT && !IS_ERR_VALUE(value)) {
+	if (sub_cmd != GPIOC_INPUT && !IS_ERR_VALUE(value)) {
 		int nval = gpio_get_value(gpio);
 
 		if (IS_ERR_VALUE(nval))