linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: ehci-s5p: Use devm for requesting ehci_vbus_gpio
@ 2013-03-14 23:59 Doug Anderson
  2013-03-15  3:15 ` [PATCH v2] " Doug Anderson
  0 siblings, 1 reply; 5+ messages in thread
From: Doug Anderson @ 2013-03-14 23:59 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Alexander Graf, Vivek Gautam, Jingoo Han, Alan Stern, Kukjin Kim,
	Greg Kroah-Hartman, Thomas Abraham, Doug Anderson, linux-usb,
	linux-kernel

The ehci_vbus_gpio is requested but never freed.  This can cause
problems with deferred probes and would cause problems if
s5p_ehci_remove was ever called.  Use devm to fix this.

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
 drivers/usb/host/ehci-s5p.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index 20ebf6a..a464197 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -92,6 +92,7 @@ static void s5p_ehci_phy_disable(struct s5p_ehci_hcd *s5p_ehci)
 
 static void s5p_setup_vbus_gpio(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	int err;
 	int gpio;
 
@@ -103,7 +104,8 @@ static void s5p_setup_vbus_gpio(struct platform_device *pdev)
 	if (!gpio_is_valid(gpio))
 		return;
 
-	err = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "ehci_vbus_gpio");
+	err = devm_gpio_request_one(dev, gpio, GPIOF_OUT_INIT_HIGH,
+				    "ehci_vbus_gpio");
 	if (err)
 		dev_err(&pdev->dev, "can't request ehci vbus gpio %d", gpio);
 }
-- 
1.8.1.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2] usb: ehci-s5p: Use devm for requesting ehci_vbus_gpio
  2013-03-14 23:59 [PATCH] usb: ehci-s5p: Use devm for requesting ehci_vbus_gpio Doug Anderson
@ 2013-03-15  3:15 ` Doug Anderson
  2013-03-25  9:29   ` Kukjin Kim
  0 siblings, 1 reply; 5+ messages in thread
From: Doug Anderson @ 2013-03-15  3:15 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Alexander Graf, Vivek Gautam, Jingoo Han, Alan Stern, Kukjin Kim,
	Greg Kroah-Hartman, Thomas Abraham, Doug Anderson, linux-usb,
	linux-kernel

The ehci_vbus_gpio is requested but never freed.  This can cause
problems with deferred probes and would cause problems if
s5p_ehci_remove was ever called.  Use devm to fix this.

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
Changes in v2:
- &pdev->dev => dev elsewhere in s5p_setup_vbus_gpio()

 drivers/usb/host/ehci-s5p.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
index 20ebf6a..738490e 100644
--- a/drivers/usb/host/ehci-s5p.c
+++ b/drivers/usb/host/ehci-s5p.c
@@ -92,20 +92,21 @@ static void s5p_ehci_phy_disable(struct s5p_ehci_hcd *s5p_ehci)
 
 static void s5p_setup_vbus_gpio(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	int err;
 	int gpio;
 
-	if (!pdev->dev.of_node)
+	if (!dev->of_node)
 		return;
 
-	gpio = of_get_named_gpio(pdev->dev.of_node,
-			"samsung,vbus-gpio", 0);
+	gpio = of_get_named_gpio(dev->of_node, "samsung,vbus-gpio", 0);
 	if (!gpio_is_valid(gpio))
 		return;
 
-	err = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "ehci_vbus_gpio");
+	err = devm_gpio_request_one(dev, gpio, GPIOF_OUT_INIT_HIGH,
+				    "ehci_vbus_gpio");
 	if (err)
-		dev_err(&pdev->dev, "can't request ehci vbus gpio %d", gpio);
+		dev_err(dev, "can't request ehci vbus gpio %d", gpio);
 }
 
 static u64 ehci_s5p_dma_mask = DMA_BIT_MASK(32);
-- 
1.8.1.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH v2] usb: ehci-s5p: Use devm for requesting ehci_vbus_gpio
  2013-03-15  3:15 ` [PATCH v2] " Doug Anderson
@ 2013-03-25  9:29   ` Kukjin Kim
  0 siblings, 0 replies; 5+ messages in thread
From: Kukjin Kim @ 2013-03-25  9:29 UTC (permalink / raw)
  To: 'Doug Anderson', 'Felipe Balbi'
  Cc: 'Alexander Graf', 'Vivek Gautam',
	'Jingoo Han', 'Alan Stern',
	'Greg Kroah-Hartman', 'Thomas Abraham',
	linux-usb, linux-kernel

Doug Anderson wrote:
> 
> The ehci_vbus_gpio is requested but never freed.  This can cause
> problems with deferred probes and would cause problems if
> s5p_ehci_remove was ever called.  Use devm to fix this.
> 
> Signed-off-by: Doug Anderson <dianders@chromium.org>

Acked-by: Kukjin Kim <kgene.kim@samsung.com>

Thanks.

- Kukjin

> ---
> Changes in v2:
> - &pdev->dev => dev elsewhere in s5p_setup_vbus_gpio()
> 
>  drivers/usb/host/ehci-s5p.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
> index 20ebf6a..738490e 100644
> --- a/drivers/usb/host/ehci-s5p.c
> +++ b/drivers/usb/host/ehci-s5p.c
> @@ -92,20 +92,21 @@ static void s5p_ehci_phy_disable(struct s5p_ehci_hcd
> *s5p_ehci)
> 
>  static void s5p_setup_vbus_gpio(struct platform_device *pdev)
>  {
> +	struct device *dev = &pdev->dev;
>  	int err;
>  	int gpio;
> 
> -	if (!pdev->dev.of_node)
> +	if (!dev->of_node)
>  		return;
> 
> -	gpio = of_get_named_gpio(pdev->dev.of_node,
> -			"samsung,vbus-gpio", 0);
> +	gpio = of_get_named_gpio(dev->of_node, "samsung,vbus-gpio", 0);
>  	if (!gpio_is_valid(gpio))
>  		return;
> 
> -	err = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "ehci_vbus_gpio");
> +	err = devm_gpio_request_one(dev, gpio, GPIOF_OUT_INIT_HIGH,
> +				    "ehci_vbus_gpio");
>  	if (err)
> -		dev_err(&pdev->dev, "can't request ehci vbus gpio %d",
gpio);
> +		dev_err(dev, "can't request ehci vbus gpio %d", gpio);
>  }
> 
>  static u64 ehci_s5p_dma_mask = DMA_BIT_MASK(32);
> --
> 1.8.1.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: ehci-s5p: Use devm for requesting ehci_vbus_gpio
  2013-03-15  0:30 [PATCH] " Jingoo Han
@ 2013-03-15  3:15 ` Doug Anderson
  0 siblings, 0 replies; 5+ messages in thread
From: Doug Anderson @ 2013-03-15  3:15 UTC (permalink / raw)
  To: jg1.han
  Cc: Felipe Balbi, Alexander Graf, Vivek Gautam, Alan Stern,
	Kukjin Kim, Greg Kroah-Hartman, Thomas Abraham, linux-usb,
	linux-kernel

Jingoo,

On Thu, Mar 14, 2013 at 5:30 PM, Jingoo Han <jg1.han@samsung.com> wrote:
> Would you replace other '&pdev->dev' with 'dev' in s5p_setup_vbus_gpio()
> as below? It seems to be better for readability.

Yes, of course.  That was silly of me not to add the "dev" local and
not update the other places...  Thanks for your review!

-Doug

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: ehci-s5p: Use devm for requesting ehci_vbus_gpio
@ 2013-03-15  0:30 Jingoo Han
  2013-03-15  3:15 ` Doug Anderson
  0 siblings, 1 reply; 5+ messages in thread
From: Jingoo Han @ 2013-03-15  0:30 UTC (permalink / raw)
  To: Doug Anderson, Felipe Balbi
  Cc: Alexander Graf, Vivek Gautam, Alan Stern, Kukjin Kim,
	Greg Kroah-Hartman, Thomas Abraham, linux-usb, linux-kernel,
	Jingoo Han

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=euc-kr, Size: 2102 bytes --]

On Wednesday, March 13, 2013 4:03 AM, Doug Anderson wrote:
> 
> The ehci_vbus_gpio is requested but never freed.  This can cause
> problems with deferred probes and would cause problems if
> s5p_ehci_remove was ever called.  Use devm to fix this.
> 
> Signed-off-by: Doug Anderson <dianders@chromium.org>
> ---
>  drivers/usb/host/ehci-s5p.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c
> index 20ebf6a..a464197 100644
> --- a/drivers/usb/host/ehci-s5p.c
> +++ b/drivers/usb/host/ehci-s5p.c
> @@ -92,6 +92,7 @@ static void s5p_ehci_phy_disable(struct s5p_ehci_hcd *s5p_ehci)
> 
>  static void s5p_setup_vbus_gpio(struct platform_device *pdev)
>  {
> +	struct device *dev = &pdev->dev;

Hi Doug Anderson,

Would you replace other '&pdev->dev' with 'dev' in s5p_setup_vbus_gpio()
as below? It seems to be better for readability.

-       gpio = of_get_named_gpio(pdev->dev.of_node,
+       gpio = of_get_named_gpio(dev->of_node,
                        "samsung,vbus-gpio", 0);
        if (!gpio_is_valid(gpio))
                return;

-       err = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "ehci_vbus_gpio");
+       err = devm_gpio_request_one(dev, gpio, GPIOF_OUT_INIT_HIGH,
+                               "ehci_vbus_gpio");
        if (err)
-               dev_err(&pdev->dev, "can't request ehci vbus gpio %d", gpio);
+               dev_err(dev, "can't request ehci vbus gpio %d", gpio);


Best regards,
Jingoo Han

>  	int err;
>  	int gpio;
> 
> @@ -103,7 +104,8 @@ static void s5p_setup_vbus_gpio(struct platform_device *pdev)
>  	if (!gpio_is_valid(gpio))
>  		return;
> 
> -	err = gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, "ehci_vbus_gpio");
> +	err = devm_gpio_request_one(dev, gpio, GPIOF_OUT_INIT_HIGH,
> +				    "ehci_vbus_gpio");
>  	if (err)
>  		dev_err(&pdev->dev, "can't request ehci vbus gpio %d", gpio);
>  }
> --
> 1.8.1.3
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-03-25  9:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-14 23:59 [PATCH] usb: ehci-s5p: Use devm for requesting ehci_vbus_gpio Doug Anderson
2013-03-15  3:15 ` [PATCH v2] " Doug Anderson
2013-03-25  9:29   ` Kukjin Kim
2013-03-15  0:30 [PATCH] " Jingoo Han
2013-03-15  3:15 ` Doug Anderson

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).