[U-Boot] [PATCH v2] BeagleBoard: match gpio_request() and gpio_free()

In-Bae Jeong kukyakya at gmail.com
Wed Oct 5 14:08:27 CEST 2011


This patch adds code to match gpio_free() to the corresponding
gpio_request()

Signed-off-by: In-Bae Jeong <kukyakya at gmail.com>
---
Changes for v2:
   - added lables for gpio_request()
   - separated labels and statements
---
 board/ti/beagle/beagle.c |   43 +++++++++++++++++++++++++++++--------------
 1 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
index aa5047c..6859594 100644
--- a/board/ti/beagle/beagle.c
+++ b/board/ti/beagle/beagle.c
@@ -115,24 +115,39 @@ int board_init(void)
 int get_board_revision(void)
 {
 	int revision;
+	int error = 0;
 
-	if (!gpio_request(171, "") &&
-	    !gpio_request(172, "") &&
-	    !gpio_request(173, "")) {
+	if (gpio_request(171, "revision0")) {
+		error = 171;
+		goto gpio_171_err;
+	}
+	if (gpio_request(172, "revision1")) {
+		error = 172;
+		goto gpio_172_err;
+	}
+	if (gpio_request(173, "revision2")) {
+		error = 173;
+		goto gpio_173_err;
+	}
+
+	gpio_direction_input(171);
+	gpio_direction_input(172);
+	gpio_direction_input(173);
 
-		gpio_direction_input(171);
-		gpio_direction_input(172);
-		gpio_direction_input(173);
+	revision = gpio_get_value(173) << 2 |
+		   gpio_get_value(172) << 1 |
+		   gpio_get_value(171);
 
-		revision = gpio_get_value(173) << 2 |
-			   gpio_get_value(172) << 1 |
-			   gpio_get_value(171);
+	gpio_free(173);
+gpio_173_err:
+	gpio_free(172);
+gpio_172_err:
+	gpio_free(171);
+gpio_171_err:
 
-		gpio_free(171);
-		gpio_free(172);
-		gpio_free(173);
-	} else {
-		printf("Error: unable to acquire board revision GPIOs\n");
+	if (error) {
+		printf("Error: Unable to acquire board revision gpio %i\n",
+			error);
 		revision = -1;
 	}
 
-- 
1.7.3.4



More information about the U-Boot mailing list