From 6801201ee72795dddb1e23aa6091c95866b19e0b Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 12 Apr 2011 03:02:11 -0400 Subject: [PATCH] gpio: check request result Make sure the pin request passed before attempting to use it later on. Signed-off-by: Mike Frysinger --- common/cmd_gpio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/cmd_gpio.c b/common/cmd_gpio.c index 9c9de28e4a..9cc790aba8 100644 --- a/common/cmd_gpio.c +++ b/common/cmd_gpio.c @@ -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) { -- 2.39.5