Patchwork [U-Boot] gpio: check request result

login
register
mail settings
Submitter Mike Frysinger
Date April 12, 2011, 7:03 a.m.
Message ID <1302591795-12024-1-git-send-email-vapier@gentoo.org>
Download mbox | patch
Permalink /patch/90726/
State Accepted
Commit 6801201ee72795dddb1e23aa6091c95866b19e0b
Delegated to: Wolfgang Denk
Headers show

Comments

Mike Frysinger - April 12, 2011, 7:03 a.m.
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 |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
Andreas Pretzsch - April 12, 2011, 1:14 p.m.
Am Dienstag, den 12.04.2011, 03:03 -0400 schrieb Mike Frysinger:
> Make sure the pin request passed before attempting to use it later on.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Tested-by: Andreas Pretzsch <apr@cn-eng.de>

Verified on Blackfin BF561 with full port range.

Patch

diff --git a/common/cmd_gpio.c b/common/cmd_gpio.c
index 9c9de28..9cc790a 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) {