提交 148e1134 编写于 作者: T Thierry Reding 提交者: Greg Kroah-Hartman

usb: Convert to devm_ioremap_resource()

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: NThierry Reding <thierry.reding@avionic-design.de>
Acked-by: NAlan Stern <stern@rowland.harvard.edu>
Acked-by: NFelipe Balbi <balbi@ti.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 eb612fa0
...@@ -98,9 +98,9 @@ static int usbmisc_imx6q_probe(struct platform_device *pdev) ...@@ -98,9 +98,9 @@ static int usbmisc_imx6q_probe(struct platform_device *pdev)
spin_lock_init(&data->lock); spin_lock_init(&data->lock);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
data->base = devm_request_and_ioremap(&pdev->dev, res); data->base = devm_ioremap_resource(&pdev->dev, res);
if (!data->base) if (IS_ERR(data->base))
return -EADDRNOTAVAIL; return PTR_ERR(data->base);
data->clk = devm_clk_get(&pdev->dev, NULL); data->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(data->clk)) { if (IS_ERR(data->clk)) {
......
...@@ -2351,19 +2351,20 @@ static int bcm63xx_udc_probe(struct platform_device *pdev) ...@@ -2351,19 +2351,20 @@ static int bcm63xx_udc_probe(struct platform_device *pdev)
dev_err(dev, "error finding USBD resource\n"); dev_err(dev, "error finding USBD resource\n");
return -ENXIO; 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); res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (!res) { if (!res) {
dev_err(dev, "error finding IUDMA resource\n"); dev_err(dev, "error finding IUDMA resource\n");
return -ENXIO; return -ENXIO;
} }
udc->iudma_regs = devm_request_and_ioremap(dev, res);
if (!udc->usbd_regs || !udc->iudma_regs) { udc->iudma_regs = devm_ioremap_resource(dev, res);
dev_err(dev, "error requesting resources\n"); if (IS_ERR(udc->iudma_regs))
return -ENXIO; return PTR_ERR(udc->iudma_regs);
}
spin_lock_init(&udc->lock); spin_lock_init(&udc->lock);
INIT_WORK(&udc->ep0_wq, bcm63xx_ep0_process); INIT_WORK(&udc->ep0_wq, bcm63xx_ep0_process);
......
...@@ -3525,10 +3525,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev) ...@@ -3525,10 +3525,9 @@ static int s3c_hsotg_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
hsotg->regs = devm_request_and_ioremap(&pdev->dev, res); hsotg->regs = devm_ioremap_resource(&pdev->dev, res);
if (!hsotg->regs) { if (IS_ERR(hsotg->regs)) {
dev_err(dev, "cannot map registers\n"); ret = PTR_ERR(hsotg->regs);
ret = -ENXIO;
goto err_clk; goto err_clk;
} }
......
...@@ -1295,10 +1295,9 @@ static int s3c_hsudc_probe(struct platform_device *pdev) ...@@ -1295,10 +1295,9 @@ static int s3c_hsudc_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
hsudc->regs = devm_request_and_ioremap(&pdev->dev, res); hsudc->regs = devm_ioremap_resource(&pdev->dev, res);
if (!hsudc->regs) { if (IS_ERR(hsudc->regs)) {
dev_err(dev, "error mapping device register area\n"); ret = PTR_ERR(hsudc->regs);
ret = -EBUSY;
goto err_res; goto err_res;
} }
......
...@@ -143,10 +143,9 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev) ...@@ -143,10 +143,9 @@ static int ehci_atmel_drv_probe(struct platform_device *pdev)
hcd->rsrc_start = res->start; hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res); hcd->rsrc_len = resource_size(res);
hcd->regs = devm_request_and_ioremap(&pdev->dev, res); hcd->regs = devm_ioremap_resource(&pdev->dev, res);
if (hcd->regs == NULL) { if (IS_ERR(hcd->regs)) {
dev_dbg(&pdev->dev, "error mapping memory\n"); retval = PTR_ERR(hcd->regs);
retval = -EFAULT;
goto fail_request_resource; goto fail_request_resource;
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <linux/err.h>
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
...@@ -118,10 +118,9 @@ static int ehci_hcd_grlib_probe(struct platform_device *op) ...@@ -118,10 +118,9 @@ static int ehci_hcd_grlib_probe(struct platform_device *op)
goto err_irq; goto err_irq;
} }
hcd->regs = devm_request_and_ioremap(&op->dev, &res); hcd->regs = devm_ioremap_resource(&op->dev, &res);
if (!hcd->regs) { if (IS_ERR(hcd->regs)) {
pr_err("%s: devm_request_and_ioremap failed\n", __FILE__); rv = PTR_ERR(hcd->regs);
rv = -ENOMEM;
goto err_ioremap; goto err_ioremap;
} }
......
...@@ -128,10 +128,9 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) ...@@ -128,10 +128,9 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
hcd->rsrc_start = res->start; hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res); hcd->rsrc_len = resource_size(res);
hcd->regs = devm_request_and_ioremap(&pdev->dev, res); hcd->regs = devm_ioremap_resource(&pdev->dev, res);
if (!hcd->regs) { if (IS_ERR(hcd->regs)) {
dev_err(dev, "error mapping memory\n"); ret = PTR_ERR(hcd->regs);
ret = -EFAULT;
goto err_alloc; goto err_alloc;
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
* *
* Licensed under the GNU/GPL. See COPYING for details. * Licensed under the GNU/GPL. See COPYING for details.
*/ */
#include <linux/err.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/hrtimer.h> #include <linux/hrtimer.h>
#include <linux/io.h> #include <linux/io.h>
...@@ -104,9 +105,9 @@ static int ehci_platform_probe(struct platform_device *dev) ...@@ -104,9 +105,9 @@ static int ehci_platform_probe(struct platform_device *dev)
hcd->rsrc_start = res_mem->start; hcd->rsrc_start = res_mem->start;
hcd->rsrc_len = resource_size(res_mem); hcd->rsrc_len = resource_size(res_mem);
hcd->regs = devm_request_and_ioremap(&dev->dev, res_mem); hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
if (!hcd->regs) { if (IS_ERR(hcd->regs)) {
err = -ENOMEM; err = PTR_ERR(hcd->regs);
goto err_put_hcd; goto err_put_hcd;
} }
err = usb_add_hcd(hcd, irq, IRQF_SHARED); err = usb_add_hcd(hcd, irq, IRQF_SHARED);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* This file is licenced under the GPL. * This file is licenced under the GPL.
*/ */
#include <linux/err.h>
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/of.h> #include <linux/of.h>
...@@ -121,10 +122,9 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op) ...@@ -121,10 +122,9 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
goto err_irq; goto err_irq;
} }
hcd->regs = devm_request_and_ioremap(&op->dev, &res); hcd->regs = devm_ioremap_resource(&op->dev, &res);
if (!hcd->regs) { if (IS_ERR(hcd->regs)) {
pr_err("%s: devm_request_and_ioremap failed\n", __FILE__); rv = PTR_ERR(hcd->regs);
rv = -ENOMEM;
goto err_ioremap; goto err_ioremap;
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
* Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <linux/err.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
static int ehci_sead3_setup(struct usb_hcd *hcd) static int ehci_sead3_setup(struct usb_hcd *hcd)
...@@ -112,10 +113,9 @@ static int ehci_hcd_sead3_drv_probe(struct platform_device *pdev) ...@@ -112,10 +113,9 @@ static int ehci_hcd_sead3_drv_probe(struct platform_device *pdev)
hcd->rsrc_start = res->start; hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res); hcd->rsrc_len = resource_size(res);
hcd->regs = devm_request_and_ioremap(&pdev->dev, res); hcd->regs = devm_ioremap_resource(&pdev->dev, res);
if (!hcd->regs) { if (IS_ERR(hcd->regs)) {
pr_debug("ioremap failed"); ret = PTR_ERR(hcd->regs);
ret = -ENOMEM;
goto err1; goto err1;
} }
......
...@@ -118,10 +118,9 @@ static int ehci_hcd_sh_probe(struct platform_device *pdev) ...@@ -118,10 +118,9 @@ static int ehci_hcd_sh_probe(struct platform_device *pdev)
hcd->rsrc_start = res->start; hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res); hcd->rsrc_len = resource_size(res);
hcd->regs = devm_request_and_ioremap(&pdev->dev, res); hcd->regs = devm_ioremap_resource(&pdev->dev, res);
if (hcd->regs == NULL) { if (IS_ERR(hcd->regs)) {
dev_dbg(&pdev->dev, "error mapping memory\n"); ret = PTR_ERR(hcd->regs);
ret = -ENXIO;
goto fail_request_resource; goto fail_request_resource;
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
* *
*/ */
#include <linux/err.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
...@@ -96,10 +97,9 @@ static int vt8500_ehci_drv_probe(struct platform_device *pdev) ...@@ -96,10 +97,9 @@ static int vt8500_ehci_drv_probe(struct platform_device *pdev)
hcd->rsrc_start = res->start; hcd->rsrc_start = res->start;
hcd->rsrc_len = resource_size(res); hcd->rsrc_len = resource_size(res);
hcd->regs = devm_request_and_ioremap(&pdev->dev, res); hcd->regs = devm_ioremap_resource(&pdev->dev, res);
if (!hcd->regs) { if (IS_ERR(hcd->regs)) {
pr_debug("ioremap failed"); ret = PTR_ERR(hcd->regs);
ret = -ENOMEM;
goto err1; goto err1;
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
* *
*/ */
#include <linux/err.h>
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/of.h> #include <linux/of.h>
...@@ -159,10 +160,9 @@ static int ehci_hcd_xilinx_of_probe(struct platform_device *op) ...@@ -159,10 +160,9 @@ static int ehci_hcd_xilinx_of_probe(struct platform_device *op)
goto err_irq; goto err_irq;
} }
hcd->regs = devm_request_and_ioremap(&op->dev, &res); hcd->regs = devm_ioremap_resource(&op->dev, &res);
if (!hcd->regs) { if (IS_ERR(hcd->regs)) {
pr_err("%s: devm_request_and_ioremap failed\n", __FILE__); rv = PTR_ERR(hcd->regs);
rv = -ENOMEM;
goto err_irq; goto err_irq;
} }
......
...@@ -306,10 +306,9 @@ static int usb_hcd_nxp_probe(struct platform_device *pdev) ...@@ -306,10 +306,9 @@ static int usb_hcd_nxp_probe(struct platform_device *pdev)
goto out8; goto out8;
} }
hcd->regs = devm_request_and_ioremap(&pdev->dev, res); hcd->regs = devm_ioremap_resource(&pdev->dev, res);
if (!hcd->regs) { if (IS_ERR(hcd->regs)) {
dev_err(&pdev->dev, "Failed to devm_request_and_ioremap\n"); ret = PTR_ERR(hcd->regs);
ret = -ENOMEM;
goto out8; goto out8;
} }
hcd->rsrc_start = res->start; hcd->rsrc_start = res->start;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* *
* Licensed under the GNU/GPL. See COPYING for details. * Licensed under the GNU/GPL. See COPYING for details.
*/ */
#include <linux/err.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/usb/ohci_pdriver.h> #include <linux/usb/ohci_pdriver.h>
...@@ -127,9 +128,9 @@ static int ohci_platform_probe(struct platform_device *dev) ...@@ -127,9 +128,9 @@ static int ohci_platform_probe(struct platform_device *dev)
hcd->rsrc_start = res_mem->start; hcd->rsrc_start = res_mem->start;
hcd->rsrc_len = resource_size(res_mem); hcd->rsrc_len = resource_size(res_mem);
hcd->regs = devm_request_and_ioremap(&dev->dev, res_mem); hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
if (!hcd->regs) { if (IS_ERR(hcd->regs)) {
err = -ENOMEM; err = PTR_ERR(hcd->regs);
goto err_put_hcd; goto err_put_hcd;
} }
err = usb_add_hcd(hcd, irq, IRQF_SHARED); err = usb_add_hcd(hcd, irq, IRQF_SHARED);
......
...@@ -351,10 +351,9 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver, ...@@ -351,10 +351,9 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver,
hcd->rsrc_start = dev->resource[0].start; hcd->rsrc_start = dev->resource[0].start;
hcd->rsrc_len = resource_size(&dev->resource[0]); hcd->rsrc_len = resource_size(&dev->resource[0]);
hcd->regs = devm_request_and_ioremap(&dev->dev, &dev->resource[0]); hcd->regs = devm_ioremap_resource(&dev->dev, &dev->resource[0]);
if (!hcd->regs) { if (IS_ERR(hcd->regs)) {
dev_err(&dev->dev, "devm_request_and_ioremap failed\n"); retval = PTR_ERR(hcd->regs);
retval = -ENOMEM;
goto err_put; goto err_put;
} }
......
...@@ -500,10 +500,9 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) ...@@ -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].end = resources[0].start + SZ_4 - 1;
resources[0].flags = IORESOURCE_MEM; resources[0].flags = IORESOURCE_MEM;
glue->usb_ctrl[id] = devm_request_and_ioremap(&pdev->dev, resources); glue->usb_ctrl[id] = devm_ioremap_resource(&pdev->dev, resources);
if (glue->usb_ctrl[id] == NULL) { if (IS_ERR(glue->usb_ctrl[id])) {
dev_err(dev, "Failed to obtain usb_ctrl%d memory\n", id); ret = PTR_ERR(glue->usb_ctrl[id]);
ret = -ENODEV;
goto err0; goto err0;
} }
......
...@@ -523,9 +523,7 @@ static int omap2430_probe(struct platform_device *pdev) ...@@ -523,9 +523,7 @@ static int omap2430_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 1); res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
glue->control_otghs = devm_request_and_ioremap(&pdev->dev, res); glue->control_otghs = devm_ioremap_resource(&pdev->dev, res);
if (glue->control_otghs == NULL)
dev_dbg(&pdev->dev, "Failed to obtain control memory\n");
if (np) { if (np) {
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
......
...@@ -115,9 +115,9 @@ static int mxs_phy_probe(struct platform_device *pdev) ...@@ -115,9 +115,9 @@ static int mxs_phy_probe(struct platform_device *pdev)
return -ENOENT; return -ENOENT;
} }
base = devm_request_and_ioremap(&pdev->dev, res); base = devm_ioremap_resource(&pdev->dev, res);
if (!base) if (IS_ERR(base))
return -EBUSY; return PTR_ERR(base);
clk = devm_clk_get(&pdev->dev, NULL); clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
......
...@@ -283,11 +283,9 @@ static int mv_u3d_phy_probe(struct platform_device *pdev) ...@@ -283,11 +283,9 @@ static int mv_u3d_phy_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
phy_base = devm_request_and_ioremap(dev, res); phy_base = devm_ioremap_resource(dev, res);
if (!phy_base) { if (IS_ERR(phy_base))
dev_err(dev, "%s: register mapping failed\n", __func__); return PTR_ERR(phy_base);
return -ENXIO;
}
mv_u3d_phy = devm_kzalloc(dev, sizeof(*mv_u3d_phy), GFP_KERNEL); mv_u3d_phy = devm_kzalloc(dev, sizeof(*mv_u3d_phy), GFP_KERNEL);
if (!mv_u3d_phy) if (!mv_u3d_phy)
......
...@@ -168,11 +168,9 @@ static int omap_usb2_probe(struct platform_device *pdev) ...@@ -168,11 +168,9 @@ static int omap_usb2_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 1); res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
phy->control_dev = devm_request_and_ioremap(&pdev->dev, res); phy->control_dev = devm_ioremap_resource(&pdev->dev, res);
if (phy->control_dev == NULL) { if (IS_ERR(phy->control_dev))
dev_err(&pdev->dev, "Failed to obtain io memory\n"); return PTR_ERR(phy->control_dev);
return -ENXIO;
}
phy->is_suspended = 1; phy->is_suspended = 1;
omap_usb_phy_power(phy, 0); omap_usb_phy_power(phy, 0);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ */
#include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
...@@ -443,11 +444,9 @@ static int usbhs_probe(struct platform_device *pdev) ...@@ -443,11 +444,9 @@ static int usbhs_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
priv->base = devm_request_and_ioremap(&pdev->dev, res); priv->base = devm_ioremap_resource(&pdev->dev, res);
if (!priv->base) { if (IS_ERR(priv->base))
dev_err(&pdev->dev, "ioremap error.\n"); return PTR_ERR(priv->base);
return -ENOMEM;
}
/* /*
* care platform info * care platform info
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册