]> git.sur5r.net Git - u-boot/commitdiff
gpio: check request result
authorMike Frysinger <vapier@gentoo.org>
Tue, 12 Apr 2011 07:02:11 +0000 (03:02 -0400)
committerMike Frysinger <vapier@gentoo.org>
Wed, 13 Apr 2011 19:57:00 +0000 (15:57 -0400)
Make sure the pin request passed before attempting to use it later on.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
common/cmd_gpio.c

index 9c9de28e4a6764f5a2671fb37be31d3fa8d72317..9cc790aba8ab923dd53d3f471575f52d46098d79 100644 (file)
@@ -57,7 +57,10 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                goto show_usage;
 
        /* grab the pin before we tweak it */
-       gpio_request(gpio, "cmd_gpio");
+       if (gpio_request(gpio, "cmd_gpio")) {
+               printf("gpio: requesting pin %u failed\n", gpio);
+               return -1;
+       }
 
        /* finally, let's do it: set direction and exec command */
        if (sub_cmd == GPIO_INPUT) {