public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] BeagleBoard: match gpio_request() and gpio_free()
Date: Fri, 21 Oct 2011 21:14:40 +0200	[thread overview]
Message-ID: <4EA1C4A0.7050005@aribaud.net> (raw)
In-Reply-To: <1317816507-5566-1-git-send-email-kukyakya@gmail.com>

Hi In-Bae Jeong,

Le 05/10/2011 14:08, In-Bae Jeong a ?crit :
> This patch adds code to match gpio_free() to the corresponding
> gpio_request()
>
> Signed-off-by: In-Bae Jeong<kukyakya@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",

Nitpick: i and d format specifiers are indeed interchangeable, but d is 
far more common -- to the point that I had to go and check wether i 
differed in any from d. Can you resubmit using d as the specifier?

> +			error);
>   		revision = -1;
>   	}

Amicalement,
-- 
Albert.

  reply	other threads:[~2011-10-21 19:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-04  7:59 [U-Boot] [PATCH] BeagleBoard: match gpio_request() and gpio_free() In-Bae Jeong
2011-10-04 14:53 ` Mike Frysinger
2011-10-05 12:08 ` [U-Boot] [PATCH v2] " In-Bae Jeong
2011-10-21 19:14   ` Albert ARIBAUD [this message]
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=4EA1C4A0.7050005@aribaud.net \
    --to=albert.u.boot@aribaud.net \
    --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