linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/3] ARM: mx5/mx51_babbage: Use gpio_request_one when possible
Date: Mon, 2 May 2011 10:49:16 +0200	[thread overview]
Message-ID: <20110502084916.GX14770@pengutronix.de> (raw)
In-Reply-To: <1304037804-4411-2-git-send-email-festevam@gmail.com>

Hi Fabio,

On Thu, Apr 28, 2011 at 09:43:23PM -0300, Fabio Estevam wrote:
> Instead of using gpio_request followed by gpio_direction_output use gpio_request_one.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> No changes since v1. Only added a third patch to the series
> 
>  arch/arm/mach-mx5/board-mx51_babbage.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c
> index 7b919bc..00203fb 100644
> --- a/arch/arm/mach-mx5/board-mx51_babbage.c
> +++ b/arch/arm/mach-mx5/board-mx51_babbage.c
> @@ -179,25 +179,25 @@ static int gpio_usbh1_active(void)
>  
>  	/* Set USBH1_STP to GPIO and toggle it */
>  	mxc_iomux_v3_setup_pad(usbh1stp_gpio);
> -	ret = gpio_request(BABBAGE_USBH1_STP, "usbh1_stp");
> +	ret = gpio_request_one(BABBAGE_USBH1_STP,
> +					GPIOF_OUT_INIT_LOW, "usbh1_stp");
>  
>  	if (ret) {
>  		pr_debug("failed to get MX51_PAD_USBH1_STP__GPIO_1_27: %d\n", ret);
>  		return ret;
>  	}
> -	gpio_direction_output(BABBAGE_USBH1_STP, 0);
>  	gpio_set_value(BABBAGE_USBH1_STP, 1);
>  	msleep(100);
>  	gpio_free(BABBAGE_USBH1_STP);
>  
>  	/* De-assert USB PHY RESETB */
> -	ret = gpio_request(BABBAGE_USB_PHY_RESET, "phy_reset");
> +	ret = gpio_request_one(BABBAGE_USB_PHY_RESET,
> +					GPIOF_OUT_INIT_HIGH, "phy_reset");
>  
>  	if (ret) {
>  		pr_debug("failed to get MX51_PAD_EIM_D21__GPIO_2_5: %d\n", ret);
>  		return ret;
>  	}
> -	gpio_direction_output(BABBAGE_USB_PHY_RESET, 1);

This can be done better. Why not move all babbage gpios into a

/* initial gpio settings */
static struct gpio[] = {
	{ .gpio = BABBAGE_USBH1_STP, .flags = GPIOF_OUT_INIT_LOW },
	{ .gpio = BABBAGE_PHY_RESET, .flags = GPIOF_OUT_INIT_LOW },
	{ .gpio = BABBAGE_USB_HUB_RESET, flags = GPIOF_OUT_INIT_LOW },
	{ .gpio = BABBAGE_FEC_PHY_RESET, .flags = GPIOF_OUT_INIT_LOW },
};

and use gpio_request_array on this. Then we have solved this for all
board specific gpios. (I didn't care for correct output value in the
example above)

Furthermore we can move MX51_PAD_USBH1_STP__GPIO1_27,
MX51_PAD_EIM_D21__GPIO2_5 and _MX51_PAD_EIM_A27__GPIO2_21 to
mx51babbage_pads.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

      parent reply	other threads:[~2011-05-02  8:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-29  0:43 [PATCH v2 1/3] ARM: mx5/mx51_babbage: Move GPIO initialization for USB PHY Reset line to common place Fabio Estevam
2011-04-29  0:43 ` [PATCH v2 2/3] ARM: mx5/mx51_babbage: Use gpio_request_one when possible Fabio Estevam
2011-04-29  0:43   ` [PATCH v2 3/3] ARM: mx5/mx51_babbage: Fix the msleep placement Fabio Estevam
2011-05-02  8:49   ` Sascha Hauer [this message]

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=20110502084916.GX14770@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).