pinctrl: 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: Thierry Reding <thierry.reding@avionic-design.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Thierry Reding 2013-01-21 11:09:14 +01:00 committed by Greg Kroah-Hartman
parent 1684789f86
commit 9e0c1fb29a
12 changed files with 40 additions and 52 deletions

View File

@ -1503,10 +1503,9 @@ static int at91_gpio_probe(struct platform_device *pdev)
goto err; goto err;
} }
at91_chip->regbase = devm_request_and_ioremap(&pdev->dev, res); at91_chip->regbase = devm_ioremap_resource(&pdev->dev, res);
if (!at91_chip->regbase) { if (IS_ERR(at91_chip->regbase)) {
dev_err(&pdev->dev, "failed to map registers, ignoring.\n"); ret = PTR_ERR(at91_chip->regbase);
ret = -EBUSY;
goto err; goto err;
} }

View File

@ -959,9 +959,9 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
return err; return err;
} }
pc->base = devm_request_and_ioremap(dev, &iomem); pc->base = devm_ioremap_resource(dev, &iomem);
if (!pc->base) if (IS_ERR(pc->base))
return -EADDRNOTAVAIL; return PTR_ERR(pc->base);
pc->gpio_chip = bcm2835_gpio_chip; pc->gpio_chip = bcm2835_gpio_chip;
pc->gpio_chip.dev = dev; pc->gpio_chip.dev = dev;

View File

@ -715,11 +715,9 @@ static int __init u300_gpio_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
gpio->base = devm_request_and_ioremap(&pdev->dev, memres); gpio->base = devm_ioremap_resource(&pdev->dev, memres);
if (!gpio->base) { if (IS_ERR(gpio->base))
dev_err(gpio->dev, "could not get remap memory\n"); return PTR_ERR(gpio->base);
return -ENOMEM;
}
gpio->clk = devm_clk_get(gpio->dev, NULL); gpio->clk = devm_clk_get(gpio->dev, NULL);
if (IS_ERR(gpio->clk)) { if (IS_ERR(gpio->clk)) {

View File

@ -866,11 +866,9 @@ static int exynos5440_pinctrl_probe(struct platform_device *pdev)
return -ENOENT; return -ENOENT;
} }
priv->reg_base = devm_request_and_ioremap(&pdev->dev, res); priv->reg_base = devm_ioremap_resource(&pdev->dev, res);
if (!priv->reg_base) { if (IS_ERR(priv->reg_base))
dev_err(dev, "ioremap failed\n"); return PTR_ERR(priv->reg_base);
return -ENODEV;
}
ret = exynos5440_gpiolib_register(pdev, priv); ret = exynos5440_gpiolib_register(pdev, priv);
if (ret) if (ret)

View File

@ -411,14 +411,11 @@ static int pinctrl_falcon_probe(struct platform_device *pdev)
dev_err(&ppdev->dev, "failed to get clock\n"); dev_err(&ppdev->dev, "failed to get clock\n");
return PTR_ERR(falcon_info.clk[*bank]); return PTR_ERR(falcon_info.clk[*bank]);
} }
falcon_info.membase[*bank] = falcon_info.membase[*bank] = devm_ioremap_resource(&pdev->dev,
devm_request_and_ioremap(&pdev->dev, &res); &res);
if (!falcon_info.membase[*bank]) { if (IS_ERR(falcon_info.membase[*bank]))
dev_err(&pdev->dev, return PTR_ERR(falcon_info.membase[*bank]);
"Failed to remap memory for bank %d\n",
*bank);
return -ENOMEM;
}
avail = pad_r32(falcon_info.membase[*bank], avail = pad_r32(falcon_info.membase[*bank],
LTQ_PADC_AVAIL); LTQ_PADC_AVAIL);
pins = fls(avail); pins = fls(avail);

View File

@ -584,9 +584,9 @@ int imx_pinctrl_probe(struct platform_device *pdev,
if (!res) if (!res)
return -ENOENT; return -ENOENT;
ipctl->base = devm_request_and_ioremap(&pdev->dev, res); ipctl->base = devm_ioremap_resource(&pdev->dev, res);
if (!ipctl->base) if (IS_ERR(ipctl->base))
return -EBUSY; return PTR_ERR(ipctl->base);
imx_pinctrl_desc.name = dev_name(&pdev->dev); imx_pinctrl_desc.name = dev_name(&pdev->dev);
imx_pinctrl_desc.pins = info->pins; imx_pinctrl_desc.pins = info->pins;

View File

@ -1367,9 +1367,9 @@ static int nmk_gpio_probe(struct platform_device *dev)
goto out; goto out;
} }
base = devm_request_and_ioremap(&dev->dev, res); base = devm_ioremap_resource(&dev->dev, res);
if (!base) { if (IS_ERR(base)) {
ret = -ENOMEM; ret = PTR_ERR(base);
goto out; goto out;
} }

View File

@ -11,6 +11,7 @@
* *
*/ */
#include <linux/err.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/io.h> #include <linux/io.h>
@ -187,9 +188,9 @@ int pxa3xx_pinctrl_register(struct platform_device *pdev,
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) if (!res)
return -ENOENT; return -ENOENT;
info->virt_base = devm_request_and_ioremap(&pdev->dev, res); info->virt_base = devm_ioremap_resource(&pdev->dev, res);
if (!info->virt_base) if (IS_ERR(info->virt_base))
return -ENOMEM; return PTR_ERR(info->virt_base);
info->pctrl = pinctrl_register(desc, &pdev->dev, info); info->pctrl = pinctrl_register(desc, &pdev->dev, info);
if (!info->pctrl) { if (!info->pctrl) {
dev_err(&pdev->dev, "failed to register PXA pinmux driver\n"); dev_err(&pdev->dev, "failed to register PXA pinmux driver\n");

View File

@ -917,11 +917,9 @@ static int samsung_pinctrl_probe(struct platform_device *pdev)
return -ENOENT; return -ENOENT;
} }
drvdata->virt_base = devm_request_and_ioremap(&pdev->dev, res); drvdata->virt_base = devm_ioremap_resource(&pdev->dev, res);
if (!drvdata->virt_base) { if (IS_ERR(drvdata->virt_base))
dev_err(dev, "ioremap failed\n"); return PTR_ERR(drvdata->virt_base);
return -ENODEV;
}
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (res) if (res)

View File

@ -1078,9 +1078,9 @@ static int u300_pmx_probe(struct platform_device *pdev)
if (!res) if (!res)
return -ENOENT; return -ENOENT;
upmx->virtbase = devm_request_and_ioremap(&pdev->dev, res); upmx->virtbase = devm_ioremap_resource(&pdev->dev, res);
if (!upmx->virtbase) if (IS_ERR(upmx->virtbase))
return -ENOMEM; return PTR_ERR(upmx->virtbase);
upmx->pctl = pinctrl_register(&u300_pmx_desc, &pdev->dev, upmx); upmx->pctl = pinctrl_register(&u300_pmx_desc, &pdev->dev, upmx);
if (!upmx->pctl) { if (!upmx->pctl) {

View File

@ -9,6 +9,7 @@
* Copyright (C) 2012 John Crispin <blogic@openwrt.org> * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
*/ */
#include <linux/err.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
@ -687,11 +688,9 @@ static int pinmux_xway_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Failed to get resource\n"); dev_err(&pdev->dev, "Failed to get resource\n");
return -ENOENT; return -ENOENT;
} }
xway_info.membase[0] = devm_request_and_ioremap(&pdev->dev, res); xway_info.membase[0] = devm_ioremap_resource(&pdev->dev, res);
if (!xway_info.membase[0]) { if (IS_ERR(xway_info.membase[0]))
dev_err(&pdev->dev, "Failed to remap resource\n"); return PTR_ERR(xway_info.membase[0]);
return -ENOMEM;
}
match = of_match_device(xway_match, &pdev->dev); match = of_match_device(xway_match, &pdev->dev);
if (match) if (match)

View File

@ -540,11 +540,9 @@ static int plgpio_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
plgpio->base = devm_request_and_ioremap(&pdev->dev, res); plgpio->base = devm_ioremap_resource(&pdev->dev, res);
if (!plgpio->base) { if (IS_ERR(plgpio->base))
dev_err(&pdev->dev, "request and ioremap fail\n"); return PTR_ERR(plgpio->base);
return -ENOMEM;
}
ret = plgpio_probe_dt(pdev, plgpio); ret = plgpio_probe_dt(pdev, plgpio);
if (ret) { if (ret) {