USB: ehci-fsl: Use devm_ioremap_resource()
authorJingoo Han <jg1.han@samsung.com>
Wed, 11 Dec 2013 07:18:53 +0000 (16:18 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Dec 2013 00:33:47 +0000 (16:33 -0800)
Use devm_ioremap_resource() to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/ehci-fsl.c

index 7cd23b6cff6a3bc47ba0567169d4534e582ccf8e..6f2c8d3899d2cfb00f14fe641341f68944943213 100644 (file)
@@ -102,19 +102,11 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
        }
        hcd->rsrc_start = res->start;
        hcd->rsrc_len = resource_size(res);
-       if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
-                               driver->description)) {
-               dev_dbg(&pdev->dev, "controller already in use\n");
-               retval = -EBUSY;
+       hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(hcd->regs)) {
+               retval = PTR_ERR(hcd->regs);
                goto err2;
        }
-       hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
-
-       if (hcd->regs == NULL) {
-               dev_dbg(&pdev->dev, "error mapping memory\n");
-               retval = -EFAULT;
-               goto err3;
-       }
 
        pdata->regs = hcd->regs;
 
@@ -126,7 +118,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
         */
        if (pdata->init && pdata->init(pdev)) {
                retval = -ENODEV;
-               goto err4;
+               goto err2;
        }
 
        /* Enable USB controller, 83xx or 8536 */
@@ -137,7 +129,7 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
 
        retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
        if (retval != 0)
-               goto err4;
+               goto err2;
        device_wakeup_enable(hcd->self.controller);
 
 #ifdef CONFIG_USB_OTG
@@ -153,21 +145,17 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
                                              &ehci_to_hcd(ehci)->self);
                        if (retval) {
                                usb_put_phy(hcd->phy);
-                               goto err4;
+                               goto err2;
                        }
                } else {
                        dev_err(&pdev->dev, "can't find phy\n");
                        retval = -ENODEV;
-                       goto err4;
+                       goto err2;
                }
        }
 #endif
        return retval;
 
-      err4:
-       iounmap(hcd->regs);
-      err3:
-       release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
       err2:
        usb_put_hcd(hcd);
       err1:
@@ -206,8 +194,6 @@ static void usb_hcd_fsl_remove(struct usb_hcd *hcd,
         */
        if (pdata->exit)
                pdata->exit(pdev);
-       iounmap(hcd->regs);
-       release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
        usb_put_hcd(hcd);
 }