Skip to contentSkip to conversation

usb: ehci-s5p: Use devm for requesting ehci_vbus_gpio

PATCH Jingoo Han 2 participants 2 messages Mar 15, 2013 – Mar 18, 2013

lore
Share & tools
lore

Jingoo Han

author Acked-by
#0 lore raw
Quoted 6 lines · Doug Anderson

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.

Best regards,
Jingoo Han

Quoted 39 lines

---
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(-)
drivers/usb/host/ehci-s5p.c +6 -6
index 20ebf6a..738490e 100644
@@ -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);
--
Quoted 1 line

1.8.1.3

�淸�{.n�+돴윯돪�+%듚�깁負쪐w��{.n�+돴쪐{깸G쳺��{ay����,j�f"톒쉹��묎�z_溫(�쉸듶줷"얎�m����G쳺�◀?솳鈺�&x�~뤳턨O뺞촾퇉v�^�m��� �띠�◀?뻀�

Tested-by
#1 lore raw

Hi,

Quoted 43 lines · Jingoo Han
Quoted 6 lines · Doug Anderson

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.

Best regards,
Jingoo Han

Quoted 29 lines

---
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(-)
drivers/usb/host/ehci-s5p.c +3 -3
index 20ebf6a..738490e 100644
@@ -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;
 
Quoted 8 lines

drivers/usb/host/ehci-s5p.c static void s5p_ehci_phy_disable(struct s5p_ehci_hcd *s5p_ehci) · line 111

Quoted 8 lines
drivers/usb/host/ehci-s5p.c +3 -2
-     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);
 }
 

tested this patch with smdk5250 h/w.

Without this patch get following kernel message (since ehci-s5p's probe was being deferred
due to unavailability of PHY and we were trying to request gpio once again) :

[    1.175000] s5p-ehci 12110000.usb: can't request ehci vbus gpio 177

which however goes away after applying this patch.

Signature · 2 lines
Thanks & Regards
Vivek