diff mbox

[2/2] ARM: mx5/mx51_babbage: Use gpio_request_one when possible

Message ID 1303951472-22234-2-git-send-email-festevam@gmail.com
State Superseded
Headers show

Commit Message

Fabio Estevam April 28, 2011, 12:44 a.m. UTC
Instead of using gpio_request followed by gpio_direction_output use gpio_request_one.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 arch/arm/mach-mx5/board-mx51_babbage.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

Comments

Uwe Kleine-König April 28, 2011, 7:55 a.m. UTC | #1
Hello,

ah, this patch makes my review comment to your patch 1 nil.

On Wed, Apr 27, 2011 at 09:44:32PM -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>
> ---
>  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);
This cannot go into the global list of pins to mux?

> -	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);
Why is the sleep between set_value(1) and free? I would have expected it
between request_one(INIT_LOW) and set_value(1)?

>  	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);
>  	return 0;
>  }
>  
> -- 
> 1.6.0.4
> 
>
Fabio Estevam April 28, 2011, 4:03 p.m. UTC | #2
Hi Uwe,

On 4/28/2011 4:55 AM, Uwe Kleine-König wrote:
...
  
>>  	/* Set USBH1_STP to GPIO and toggle it */
>>  	mxc_iomux_v3_setup_pad(usbh1stp_gpio);
> This cannot go into the global list of pins to mux?

This pin alternates its mode(GPIO and USB STP), so I think we can leave it defined here.
> 
>> -	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);
> Why is the sleep between set_value(1) and free? I would have expected it
> between request_one(INIT_LOW) and set_value(1)?

Agreed. I haven´t changed the logic on this patch. Will send a third patch for fixing this.

Thanks,

Fabio Estevam
diff mbox

Patch

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);
 	return 0;
 }