usb: ehci-s5p: Use devm for requesting ehci_vbus_gpio
authorDoug Anderson <dianders@chromium.org>
Fri, 15 Mar 2013 03:15:37 +0000 (20:15 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 18 Mar 2013 23:10:12 +0000 (16:10 -0700)
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: Jingoo Han <jg1.han@samsung.com>
Tested-by: Vivek Gautam <gautam.vivek@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/ehci-s5p.c

index 20ebf6a8b7f4736c9cd448a9653de41b9d88c48a..738490e6d4298f9046bc4296d231b2f9bfbfd45d 100644 (file)
@@ -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);