提交 9387760d 编写于 作者: A Axel Lin 提交者: Linus Walleij

pinctrl: pxa3xx: Use devm_request_and_ioremap

Use managed resources API to simplify the code.
Also ensure we do request mem_region before ioremap.
Signed-off-by: NAxel Lin <axel.lin@ingics.com>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 507ccdbf
...@@ -173,7 +173,6 @@ int pxa3xx_pinctrl_register(struct platform_device *pdev, ...@@ -173,7 +173,6 @@ int pxa3xx_pinctrl_register(struct platform_device *pdev,
{ {
struct pinctrl_desc *desc; struct pinctrl_desc *desc;
struct resource *res; struct resource *res;
int ret = 0;
if (!info || !info->cputype) if (!info || !info->cputype)
return -EINVAL; return -EINVAL;
...@@ -190,21 +189,17 @@ int pxa3xx_pinctrl_register(struct platform_device *pdev, ...@@ -190,21 +189,17 @@ int pxa3xx_pinctrl_register(struct platform_device *pdev,
return -ENOENT; return -ENOENT;
info->phy_base = res->start; info->phy_base = res->start;
info->phy_size = resource_size(res); info->phy_size = resource_size(res);
info->virt_base = ioremap(info->phy_base, info->phy_size); info->virt_base = devm_request_and_ioremap(&pdev->dev, res);
if (!info->virt_base) if (!info->virt_base)
return -ENOMEM; return -ENOMEM;
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");
ret = -EINVAL; return -EINVAL;
goto err;
} }
pinctrl_add_gpio_range(info->pctrl, &pxa3xx_pinctrl_gpio_range); pinctrl_add_gpio_range(info->pctrl, &pxa3xx_pinctrl_gpio_range);
platform_set_drvdata(pdev, info); platform_set_drvdata(pdev, info);
return 0; return 0;
err:
iounmap(info->virt_base);
return ret;
} }
int pxa3xx_pinctrl_unregister(struct platform_device *pdev) int pxa3xx_pinctrl_unregister(struct platform_device *pdev)
...@@ -212,7 +207,6 @@ int pxa3xx_pinctrl_unregister(struct platform_device *pdev) ...@@ -212,7 +207,6 @@ int pxa3xx_pinctrl_unregister(struct platform_device *pdev)
struct pxa3xx_pinmux_info *info = platform_get_drvdata(pdev); struct pxa3xx_pinmux_info *info = platform_get_drvdata(pdev);
pinctrl_unregister(info->pctrl); pinctrl_unregister(info->pctrl);
iounmap(info->virt_base);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册