USB: ohci-pxa27x:Use devm_*() functions
authorJingoo Han <jg1.han@samsung.com>
Wed, 11 Dec 2013 07:26:21 +0000 (16:26 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Dec 2013 00:35:10 +0000 (16:35 -0800)
Use devm_*() functions 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/ohci-pxa27x.c

index 9352a4d425637e4441366494081043b5c9c8743c..d21d5fefa76c7bce41c49ad71027f7a084cb503d 100644 (file)
@@ -388,37 +388,28 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device
                return -ENXIO;
        }
 
-       usb_clk = clk_get(&pdev->dev, NULL);
+       usb_clk = devm_clk_get(&pdev->dev, NULL);
        if (IS_ERR(usb_clk))
                return PTR_ERR(usb_clk);
 
        hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x");
-       if (!hcd) {
-               retval = -ENOMEM;
-               goto err0;
-       }
+       if (!hcd)
+               return -ENOMEM;
 
        r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!r) {
                pr_err("no resource of IORESOURCE_MEM");
                retval = -ENXIO;
-               goto err1;
+               goto err;
        }
 
        hcd->rsrc_start = r->start;
        hcd->rsrc_len = resource_size(r);
 
-       if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
-               pr_debug("request_mem_region failed");
-               retval = -EBUSY;
-               goto err1;
-       }
-
-       hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
-       if (!hcd->regs) {
-               pr_debug("ioremap failed");
-               retval = -ENOMEM;
-               goto err2;
+       hcd->regs = devm_ioremap_resource(&pdev->dev, r);
+       if (IS_ERR(hcd->regs)) {
+               retval = PTR_ERR(hcd->regs);
+               goto err;
        }
 
        /* initialize "struct pxa27x_ohci" */
@@ -429,7 +420,7 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device
        retval = pxa27x_start_hc(pxa_ohci, &pdev->dev);
        if (retval < 0) {
                pr_debug("pxa27x_start_hc failed");
-               goto err3;
+               goto err;
        }
 
        /* Select Power Management Mode */
@@ -449,14 +440,8 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device
        }
 
        pxa27x_stop_hc(pxa_ohci, &pdev->dev);
- err3:
-       iounmap(hcd->regs);
- err2:
-       release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
- err1:
+ err:
        usb_put_hcd(hcd);
- err0:
-       clk_put(usb_clk);
        return retval;
 }
 
@@ -480,9 +465,6 @@ void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev)
 
        usb_remove_hcd(hcd);
        pxa27x_stop_hc(pxa_ohci, &pdev->dev);
-       iounmap(hcd->regs);
-       release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
-       clk_put(pxa_ohci->clk);
        usb_put_hcd(hcd);
 }