]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/cmd_gpio.c
cmd_gpio.c: adjust help message depending on gpio_status being compiled in or not
[karo-tx-uboot.git] / common / cmd_gpio.c
index 65d6df451c6d4f4c5dc9c26a94a02a536b42386e..93c53a867cba3786ce9e842160fd727fbd6befe8 100644 (file)
@@ -186,7 +186,7 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        ret = gpio_request(gpio, "cmd_gpio");
        if (ret && ret != -EBUSY) {
                printf("gpio: requesting pin %u failed\n", gpio);
-               return -1;
+               return CMD_RET_FAILURE;
        }
 
        /* finally, let's do it: set direction and exec command */
@@ -208,11 +208,17 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        if (ret != -EBUSY)
                gpio_free(gpio);
 
-       return value;
+       return (ret && ret != -EBUSY) ? CMD_RET_FAILURE : CMD_RET_SUCCESS;
 }
 
+#ifdef gpio_status
+#define gpio_status_help_msg "gpio status [-a] [<bank> | <pin>]  - show [all/claimed] GPIOs"
+#else
+#define gpio_status_help_msg ""
+#endif
+
 U_BOOT_CMD(gpio, 4, 0, do_gpio,
           "query and control gpio pins",
           "<input|set|clear|toggle> <pin>\n"
           "    - input/set/clear/toggle the specified pin\n"
-          "gpio status [-a] [<bank> | <pin>]  - show [all/claimed] GPIOs");
+          gpio_status_help_msg);