Skip to contentSkip to conversation

pinctrl: pxa3xx: Use devm_request_and_ioremap

PATCH Applied Axel Lin 3 participants 7 messages Nov 12, 2012 – Nov 15, 2012 Pin control

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/2 pinctrl: pxa3xx: Use devm_request_and_ioremap

Use managed resources API to simplify the code. Also ensure we do request mem_region before ioremap.

---
 drivers/pinctrl/pinctrl-pxa3xx.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/pinctrl/pinctrl-pxa3xx.c +2 -8
index f14cd6b..43e3dd0 100644
@@ -173,7 +173,6 @@ int pxa3xx_pinctrl_register(struct platform_device *pdev,
 {
 	struct pinctrl_desc *desc;
 	struct resource *res;
-	int ret = 0;
 
 	if (!info || !info->cputype)
 		return -EINVAL;
@@ -190,21 +189,17 @@ int pxa3xx_pinctrl_register(struct platform_device *pdev,
 		return -ENOENT;
 	info->phy_base = res->start;
 	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)
 		return -ENOMEM;
 	info->pctrl = pinctrl_register(desc, &pdev->dev, info);
 	if (!info->pctrl) {
 		dev_err(&pdev->dev, "failed to register PXA pinmux driver\n");
-		ret = -EINVAL;
-		goto err;
+		return -EINVAL;
 	}
 	pinctrl_add_gpio_range(info->pctrl, &pxa3xx_pinctrl_gpio_range);
 	platform_set_drvdata(pdev, info);
 	return 0;
-err:
-	iounmap(info->virt_base);
-	return ret;
 }
 
 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);
 
 	pinctrl_unregister(info->pctrl);
-	iounmap(info->virt_base);
 	platform_set_drvdata(pdev, NULL);
 	return 0;
 }
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 2/2 pinctrl: pxa3xx: Remove phy_base and phy_size from struct pxa3xx_pinmux_info

They are not used, remove them.

---
 drivers/pinctrl/pinctrl-pxa3xx.c |    2 --
 drivers/pinctrl/pinctrl-pxa3xx.h |    2 --
 2 files changed, 4 deletions(-)
drivers/pinctrl/pinctrl-pxa3xx.c +0 -2
index 43e3dd0..51f8a38 100644
@@ -187,8 +187,6 @@ int pxa3xx_pinctrl_register(struct platform_device *pdev,
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res)
 		return -ENOENT;
-	info->phy_base = res->start;
-	info->phy_size = resource_size(res);
 	info->virt_base = devm_request_and_ioremap(&pdev->dev, res);
 	if (!info->virt_base)
 		return -ENOMEM;
drivers/pinctrl/pinctrl-pxa3xx.h +0 -2
index 8135744..92fad08 100644
@@ -60,8 +60,6 @@ struct pxa3xx_pinmux_info {
 	struct device *dev;
 	struct pinctrl_dev *pctrl;
 	enum pxa_cpu_type cputype;
-	unsigned int phy_base;
-	unsigned int phy_size;
 	void __iomem *virt_base;
 
 	struct pxa3xx_mfp_pin *mfp;
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH 2/2] pinctrl: pxa3xx: Remove phy_base and phy_size from struct pxa3xx_pinmux_info

Quoted 3 lines · Axel Lin

They are not used, remove them.

Applied, thanks!
Linus Walleij

#4 lore raw
Quoted 11 lines · Linus Walleij
Quoted 4 lines · Axel Lin

Use managed resources API to simplify the code. Also ensure we do request mem_region before ioremap.

Obviously correct, patch applied.

Yours,
Linus Walleij

If the patches on pinctrl-single driver are merged, it will be used as pinctrl driver for PXA/MMP.
And this pinctrl-pxa3xx driver would be deleted. So it's not recommend to update code on this
driver.

#5 lore raw
Quoted 11 lines · Haojian Zhuang
Quoted 9 lines · Linus Walleij
Quoted 4 lines · Axel Lin

Use managed resources API to simplify the code. Also ensure we do request mem_region before ioremap.

Obviously correct, patch applied.

Quoted 8 lines
Quoted 2 lines

Yours,
Linus Walleij

If the patches on pinctrl-single driver are merged, it will be used as pinctrl driver for PXA/MMP.
And this pinctrl-pxa3xx driver would be deleted. So it's not recommend to update code on this
driver.

I'll take care if it if there is a conflict, it will all be in the pinctrl tree anyway right?

Yours,
Linus Walleij

#6 lore raw
Quoted 22 lines · Linus Walleij
Quoted 11 lines · Haojian Zhuang
Quoted 9 lines · Linus Walleij
Quoted 4 lines · Axel Lin

Use managed resources API to simplify the code. Also ensure we do request mem_region before ioremap.

Obviously correct, patch applied.

Quoted 8 lines
Quoted 2 lines

Yours,
Linus Walleij

If the patches on pinctrl-single driver are merged, it will be used as pinctrl driver for PXA/MMP.
And this pinctrl-pxa3xx driver would be deleted. So it's not recommend to update code on this
driver.

Quoted 5 lines

I'll take care if it if there is a conflict, it will all be in the pinctrl tree anyway right?

Yours,
Linus Walleij

Thanks.