public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: In-Bae Jeong <kukyakya@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] BeagleBoard: match gpio_request() and gpio_free()
Date: Tue,  4 Oct 2011 16:59:19 +0900	[thread overview]
Message-ID: <1317715159-11367-1-git-send-email-kukyakya@gmail.com> (raw)

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

Signed-off-by: In-Bae Jeong <kukyakya@gmail.com>
---
 board/ti/beagle/beagle.c |   41 +++++++++++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
index aa5047c..7e6220a 100644
--- a/board/ti/beagle/beagle.c
+++ b/board/ti/beagle/beagle.c
@@ -115,24 +115,37 @@ 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, "")) {
+		error = 171;
+		goto GPIO_171_ERR;
+	}
+	if (gpio_request(172, "")) {
+		error = 172;
+		goto GPIO_172_ERR;
+	}
+	if (gpio_request(173, "")) {
+		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_NO_ERR:  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

             reply	other threads:[~2011-10-04  7:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-04  7:59 In-Bae Jeong [this message]
2011-10-04 14:53 ` [U-Boot] [PATCH] BeagleBoard: match gpio_request() and gpio_free() Mike Frysinger
2011-10-05 12:08 ` [U-Boot] [PATCH v2] " In-Bae Jeong
2011-10-21 19:14   ` Albert ARIBAUD
2011-11-08 21:53     ` Albert ARIBAUD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1317715159-11367-1-git-send-email-kukyakya@gmail.com \
    --to=kukyakya@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox