usb: Convert to devm_ioremap_resource()
authorThierry Reding <thierry.reding@avionic-design.de>
Mon, 21 Jan 2013 10:09:22 +0000 (11:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 22 Jan 2013 19:41:58 +0000 (11:41 -0800)
Convert all uses of devm_request_and_ioremap() to the newly introduced
devm_ioremap_resource() which provides more consistent error handling.

devm_ioremap_resource() provides its own error messages so all explicit
error messages can be removed from the failure code paths.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22 files changed:
drivers/usb/chipidea/usbmisc_imx6q.c
drivers/usb/gadget/bcm63xx_udc.c
drivers/usb/gadget/s3c-hsotg.c
drivers/usb/gadget/s3c-hsudc.c
drivers/usb/host/ehci-atmel.c
drivers/usb/host/ehci-grlib.c
drivers/usb/host/ehci-mxc.c
drivers/usb/host/ehci-platform.c
drivers/usb/host/ehci-ppc-of.c
drivers/usb/host/ehci-sead3.c
drivers/usb/host/ehci-sh.c
drivers/usb/host/ehci-vt8500.c
drivers/usb/host/ehci-xilinx-of.c
drivers/usb/host/ohci-nxp.c
drivers/usb/host/ohci-platform.c
drivers/usb/host/ohci-s3c2410.c
drivers/usb/musb/musb_dsps.c
drivers/usb/musb/omap2430.c
drivers/usb/otg/mxs-phy.c
drivers/usb/phy/mv_u3d_phy.c
drivers/usb/phy/omap-usb2.c
drivers/usb/renesas_usbhs/common.c

index 845efe29e6b97b4cb3e9b67f85a025a9c380eada..a1bce391e8256dd9b8da3b9413000ec09cd3c97b 100644 (file)
@@ -98,9 +98,9 @@ static int usbmisc_imx6q_probe(struct platform_device *pdev)
        spin_lock_init(&data->lock);
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       data->base = devm_request_and_ioremap(&pdev->dev, res);
-       if (!data->base)
-               return -EADDRNOTAVAIL;
+       data->base = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(data->base))
+               return PTR_ERR(data->base);
 
        data->clk = devm_clk_get(&pdev->dev, NULL);
        if (IS_ERR(data->clk)) {
index 47a49931361eecd151fffdceb061d0987e712526..8cc8253f1100490fc65bf288042daaef57b62b1f 100644 (file)
@@ -2351,19 +2351,20 @@ static int bcm63xx_udc_probe(struct platform_device *pdev)
                dev_err(dev, "error finding USBD resource\n");
                return -ENXIO;
        }
-       udc->usbd_regs = devm_request_and_ioremap(dev, res);
+
+       udc->usbd_regs = devm_ioremap_resource(dev, res);
+       if (IS_ERR(udc->usbd_regs))
+               return PTR_ERR(udc->usbd_regs);
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
        if (!res) {
                dev_err(dev, "error finding IUDMA resource\n");
                return -ENXIO;
        }
-       udc->iudma_regs = devm_request_and_ioremap(dev, res);
 
-       if (!udc->usbd_regs || !udc->iudma_regs) {
-               dev_err(dev, "error requesting resources\n");
-               return -ENXIO;
-       }
+       udc->iudma_regs = devm_ioremap_resource(dev, res);
+       if (IS_ERR(udc->iudma_regs))
+               return PTR_ERR(udc->iudma_regs);
 
        spin_lock_init(&udc->lock);
        INIT_WORK(&udc->ep0_wq, bcm63xx_ep0_process);
index 439c3f972f8c28d18fb34c691ab9cf8b51559098..de80fa644b5a3f99082c1713282499f7961fdd01 100644 (file)
@@ -3525,10 +3525,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-       hsotg->regs = devm_request_and_ioremap(&pdev->dev, res);
-       if (!hsotg->regs) {
-               dev_err(dev, "cannot map registers\n");
-               ret = -ENXIO;
+       hsotg->regs = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(hsotg->regs)) {
+               ret = PTR_ERR(hsotg->regs);
                goto err_clk;
        }
 
index 52379b11f0807d61b5371ae6e2a3cf8d72434e35..94ca33bb990bf11d80ac71b50f37fc02a6fbb280 100644 (file)
@@ -1295,10 +1295,9 @@ static int s3c_hsudc_probe(struct platform_device *pdev)
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-       hsudc->regs = devm_request_and_ioremap(&pdev->dev, res);
-       if (!hsudc->regs) {
-               dev_err(dev, "error mapping device register area\n");
-               ret = -EBUSY;
+       hsudc->regs = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(hsudc->regs)) {
+               ret = PTR_ERR(hsudc->regs);
                goto err_res;
        }
 
index 27639487f7ac430ae2f62010886c5da3485c9384..f3beac4d06b81fdb1fd90a61f0ff679dd77b2f4b 100644 (file)
@@ -143,10 +143,9 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)
        hcd->rsrc_start = res->start;
        hcd->rsrc_len = resource_size(res);
 
-       hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
-       if (hcd->regs == NULL) {
-               dev_dbg(&pdev->dev, "error mapping memory\n");
-               retval = -EFAULT;
+       hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(hcd->regs)) {
+               retval = PTR_ERR(hcd->regs);
                goto fail_request_resource;
        }
 
index 1fc89292f5d640edd215db510c4282c53332f7e8..5d75de9729b668e22afe4b7e57fe1050c3c320cc 100644 (file)
@@ -25,7 +25,7 @@
  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-
+#include <linux/err.h>
 #include <linux/signal.h>
 
 #include <linux/of_irq.h>
@@ -118,10 +118,9 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
                goto err_irq;
        }
 
-       hcd->regs = devm_request_and_ioremap(&op->dev, &res);
-       if (!hcd->regs) {
-               pr_err("%s: devm_request_and_ioremap failed\n", __FILE__);
-               rv = -ENOMEM;
+       hcd->regs = devm_ioremap_resource(&op->dev, &res);
+       if (IS_ERR(hcd->regs)) {
+               rv = PTR_ERR(hcd->regs);
                goto err_ioremap;
        }
 
index ec7f5d2c90de3464f66a000583fa151fde29946e..4f506af4c303c6b25b34fc54620741003b4d8638 100644 (file)
@@ -128,10 +128,9 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
        hcd->rsrc_start = res->start;
        hcd->rsrc_len = resource_size(res);
 
-       hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
-       if (!hcd->regs) {
-               dev_err(dev, "error mapping memory\n");
-               ret = -EFAULT;
+       hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(hcd->regs)) {
+               ret = PTR_ERR(hcd->regs);
                goto err_alloc;
        }
 
index 58fa0c90c7c7e3e95a0c2562e89dbff02b76e721..ca7506390542bf0e5c75232724477e4832f68f1c 100644 (file)
@@ -18,6 +18,7 @@
  *
  * Licensed under the GNU/GPL. See COPYING for details.
  */
+#include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/hrtimer.h>
 #include <linux/io.h>
@@ -104,9 +105,9 @@ static int ehci_platform_probe(struct platform_device *dev)
        hcd->rsrc_start = res_mem->start;
        hcd->rsrc_len = resource_size(res_mem);
 
-       hcd->regs = devm_request_and_ioremap(&dev->dev, res_mem);
-       if (!hcd->regs) {
-               err = -ENOMEM;
+       hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
+       if (IS_ERR(hcd->regs)) {
+               err = PTR_ERR(hcd->regs);
                goto err_put_hcd;
        }
        err = usb_add_hcd(hcd, irq, IRQF_SHARED);
index 45aceefd0c2b500ceb86ebea81369e9fa1fc7561..56dc732bf4511eef13af9af6a7b190df43795edc 100644 (file)
@@ -12,6 +12,7 @@
  * This file is licenced under the GPL.
  */
 
+#include <linux/err.h>
 #include <linux/signal.h>
 
 #include <linux/of.h>
@@ -121,10 +122,9 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
                goto err_irq;
        }
 
-       hcd->regs = devm_request_and_ioremap(&op->dev, &res);
-       if (!hcd->regs) {
-               pr_err("%s: devm_request_and_ioremap failed\n", __FILE__);
-               rv = -ENOMEM;
+       hcd->regs = devm_ioremap_resource(&op->dev, &res);
+       if (IS_ERR(hcd->regs)) {
+               rv = PTR_ERR(hcd->regs);
                goto err_ioremap;
        }
 
index efad02d947f2dff039e519f105cb4b85682e7ba1..f55477c5a1be005d27741e6f6720ac6365920008 100644 (file)
@@ -19,6 +19,7 @@
  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/err.h>
 #include <linux/platform_device.h>
 
 static int ehci_sead3_setup(struct usb_hcd *hcd)
@@ -112,10 +113,9 @@ static int ehci_hcd_sead3_drv_probe(struct platform_device *pdev)
        hcd->rsrc_start = res->start;
        hcd->rsrc_len = resource_size(res);
 
-       hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
-       if (!hcd->regs) {
-               pr_debug("ioremap failed");
-               ret = -ENOMEM;
+       hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(hcd->regs)) {
+               ret = PTR_ERR(hcd->regs);
                goto err1;
        }
 
index 0c90a24fa989286a36f76f54e41350cf26a65d3f..3565a300f401347315b968b0c09131df294e317f 100644 (file)
@@ -118,10 +118,9 @@ static int ehci_hcd_sh_probe(struct platform_device *pdev)
        hcd->rsrc_start = res->start;
        hcd->rsrc_len = resource_size(res);
 
-       hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
-       if (hcd->regs == NULL) {
-               dev_dbg(&pdev->dev, "error mapping memory\n");
-               ret = -ENXIO;
+       hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(hcd->regs)) {
+               ret = PTR_ERR(hcd->regs);
                goto fail_request_resource;
        }
 
index 11695d5b9d869aa840c5f840f54a3b6dfa989641..7ecf709610ba8eabe4ad66654c8550e9313dc041 100644 (file)
@@ -16,6 +16,7 @@
  *
  */
 
+#include <linux/err.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
 
@@ -96,10 +97,9 @@ static int vt8500_ehci_drv_probe(struct platform_device *pdev)
        hcd->rsrc_start = res->start;
        hcd->rsrc_len = resource_size(res);
 
-       hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
-       if (!hcd->regs) {
-               pr_debug("ioremap failed");
-               ret = -ENOMEM;
+       hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(hcd->regs)) {
+               ret = PTR_ERR(hcd->regs);
                goto err1;
        }
 
index 4f285e8e404a9c0a7a924c6a80cb0d963be856ae..d845e3bcfaffb14a1015f6a9174863228a1929f5 100644 (file)
@@ -25,6 +25,7 @@
  *
  */
 
+#include <linux/err.h>
 #include <linux/signal.h>
 
 #include <linux/of.h>
@@ -159,10 +160,9 @@ static int ehci_hcd_xilinx_of_probe(struct platform_device *op)
                goto err_irq;
        }
 
-       hcd->regs = devm_request_and_ioremap(&op->dev, &res);
-       if (!hcd->regs) {
-               pr_err("%s: devm_request_and_ioremap failed\n", __FILE__);
-               rv = -ENOMEM;
+       hcd->regs = devm_ioremap_resource(&op->dev, &res);
+       if (IS_ERR(hcd->regs)) {
+               rv = PTR_ERR(hcd->regs);
                goto err_irq;
        }
 
index 2344040c16d25c07e8ff616884b035f852705a25..f4988fbe78e79988c59390b216f75b8c0ff8c8f7 100644 (file)
@@ -306,10 +306,9 @@ static int usb_hcd_nxp_probe(struct platform_device *pdev)
                goto out8;
        }
 
-       hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
-       if (!hcd->regs) {
-               dev_err(&pdev->dev, "Failed to devm_request_and_ioremap\n");
-               ret =  -ENOMEM;
+       hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(hcd->regs)) {
+               ret = PTR_ERR(hcd->regs);
                goto out8;
        }
        hcd->rsrc_start = res->start;
index 084503b03fcfcd72d169f6df4bf50caf14f6bbc2..c3e7287f792170028f89cd65192fda0ac5a3d915 100644 (file)
@@ -13,6 +13,7 @@
  *
  * Licensed under the GNU/GPL. See COPYING for details.
  */
+#include <linux/err.h>
 #include <linux/platform_device.h>
 #include <linux/usb/ohci_pdriver.h>
 
@@ -127,9 +128,9 @@ static int ohci_platform_probe(struct platform_device *dev)
        hcd->rsrc_start = res_mem->start;
        hcd->rsrc_len = resource_size(res_mem);
 
-       hcd->regs = devm_request_and_ioremap(&dev->dev, res_mem);
-       if (!hcd->regs) {
-               err = -ENOMEM;
+       hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
+       if (IS_ERR(hcd->regs)) {
+               err = PTR_ERR(hcd->regs);
                goto err_put_hcd;
        }
        err = usb_add_hcd(hcd, irq, IRQF_SHARED);
index ad0f552696035f01917481d9d4f48f46662fcea8..e125770b893c391ae59a6ab456f7ef80d19c32a9 100644 (file)
@@ -351,10 +351,9 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver,
        hcd->rsrc_start = dev->resource[0].start;
        hcd->rsrc_len   = resource_size(&dev->resource[0]);
 
-       hcd->regs = devm_request_and_ioremap(&dev->dev, &dev->resource[0]);
-       if (!hcd->regs) {
-               dev_err(&dev->dev, "devm_request_and_ioremap failed\n");
-               retval = -ENOMEM;
+       hcd->regs = devm_ioremap_resource(&dev->dev, &dev->resource[0]);
+       if (IS_ERR(hcd->regs)) {
+               retval = PTR_ERR(hcd->regs);
                goto err_put;
        }
 
index f7d764de6fdab988bde6124a8a9cd8657a0ea0ff..99f470d26a38ebb48ee8ead6cb6a863264e7617f 100644 (file)
@@ -500,10 +500,9 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
        resources[0].end = resources[0].start + SZ_4 - 1;
        resources[0].flags = IORESOURCE_MEM;
 
-       glue->usb_ctrl[id] = devm_request_and_ioremap(&pdev->dev, resources);
-       if (glue->usb_ctrl[id] == NULL) {
-               dev_err(dev, "Failed to obtain usb_ctrl%d memory\n", id);
-               ret = -ENODEV;
+       glue->usb_ctrl[id] = devm_ioremap_resource(&pdev->dev, resources);
+       if (IS_ERR(glue->usb_ctrl[id])) {
+               ret = PTR_ERR(glue->usb_ctrl[id]);
                goto err0;
        }
 
index da00af46079469df59bc2babd1bf39f1a48b885a..acd5f9d71d034672640acbedb5b28cbc1721eb26 100644 (file)
@@ -523,9 +523,7 @@ static int omap2430_probe(struct platform_device *pdev)
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 
-       glue->control_otghs = devm_request_and_ioremap(&pdev->dev, res);
-       if (glue->control_otghs == NULL)
-               dev_dbg(&pdev->dev, "Failed to obtain control memory\n");
+       glue->control_otghs = devm_ioremap_resource(&pdev->dev, res);
 
        if (np) {
                pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
index 76302720055a9ca3235e2f91706fd055623733b6..60df28a294b70630b5046bf6d37be6cced4a3f3b 100644 (file)
@@ -115,9 +115,9 @@ static int mxs_phy_probe(struct platform_device *pdev)
                return -ENOENT;
        }
 
-       base = devm_request_and_ioremap(&pdev->dev, res);
-       if (!base)
-               return -EBUSY;
+       base = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(base))
+               return PTR_ERR(base);
 
        clk = devm_clk_get(&pdev->dev, NULL);
        if (IS_ERR(clk)) {
index eaddbe3d43045e8c6b9ee08ea677104b04545118..9d8599122aa9abb424d469747fb50c28d9893dbd 100644 (file)
@@ -283,11 +283,9 @@ static int mv_u3d_phy_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       phy_base = devm_request_and_ioremap(dev, res);
-       if (!phy_base) {
-               dev_err(dev, "%s: register mapping failed\n", __func__);
-               return -ENXIO;
-       }
+       phy_base = devm_ioremap_resource(dev, res);
+       if (IS_ERR(phy_base))
+               return PTR_ERR(phy_base);
 
        mv_u3d_phy = devm_kzalloc(dev, sizeof(*mv_u3d_phy), GFP_KERNEL);
        if (!mv_u3d_phy)
index 26ae8f49225c9b2803fe6624f1ec1bfa488d3018..2fdb8ede5f1cfe4f345e8d03b13349c7fcd0a76e 100644 (file)
@@ -168,11 +168,9 @@ static int omap_usb2_probe(struct platform_device *pdev)
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 
-       phy->control_dev = devm_request_and_ioremap(&pdev->dev, res);
-       if (phy->control_dev == NULL) {
-               dev_err(&pdev->dev, "Failed to obtain io memory\n");
-               return -ENXIO;
-       }
+       phy->control_dev = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(phy->control_dev))
+               return PTR_ERR(phy->control_dev);
 
        phy->is_suspended       = 1;
        omap_usb_phy_power(phy, 0);
index 38bce046f4d06580dbe5f618eba5a786f6e13dc6..cfd205036aba66303736baa5643f60e988eabb17 100644 (file)
@@ -14,6 +14,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
+#include <linux/err.h>
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/pm_runtime.h>
@@ -443,11 +444,9 @@ static int usbhs_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
-       priv->base = devm_request_and_ioremap(&pdev->dev, res);
-       if (!priv->base) {
-               dev_err(&pdev->dev, "ioremap error.\n");
-               return -ENOMEM;
-       }
+       priv->base = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(priv->base))
+               return PTR_ERR(priv->base);
 
        /*
         * care platform info