Skip to contentSkip to conversation

Input: Use devm_platform_ioremap_resource()

PATCH Applied Mukesh Ojha 2 participants 11 messages Apr 4, 2019 – Jul 16, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Input: Use devm_platform_ioremap_resource()

Hi All,

This is just a minor change to promote using of this api devm_platform_ioremap_resource() and nothing else functional change it does.

Also, there are patches where only ioremap is used without requesting the mem region so this devm_platform_ioremap_resource() take cares all of that in single call.

Mukesh Ojha (5):
Input: fsl-imx25-tcq: Use devm_platform_ioremap_resource()
Input: mxs-lradc-ts.c: Use devm_platform_ioremap_resource()
Input: s3c2410_ts: Use devm_platform_ioremap_resource()
Input: sun4i-ts: Use devm_platform_ioremap_resource()
Input: ts4800-ts: Use devm_platform_ioremap_resource()

 drivers/input/touchscreen/fsl-imx25-tcq.c |  4 +---
 drivers/input/touchscreen/mxs-lradc-ts.c  |  6 +-----
 drivers/input/touchscreen/s3c2410_ts.c    | 10 +---------
 drivers/input/touchscreen/sun4i-ts.c      |  3 +--
 drivers/input/touchscreen/ts4800-ts.c     |  4 +---
 5 files changed, 5 insertions(+), 22 deletions(-)
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
#1 lore raw

PATCH 1/5 Input: fsl-imx25-tcq: Use devm_platform_ioremap_resource()

devm_platform_ioremap_resource() internally have platform_get_resource() and devm_ioremap_resource() in it. So instead of calling them separately use devm_platform_ioremap_resource() directly.

---
 drivers/input/touchscreen/fsl-imx25-tcq.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/touchscreen/fsl-imx25-tcq.c +1 -3
index 1d6c8f4..b66df8a 100644
@@ -503,7 +503,6 @@ static int mx25_tcq_probe(struct platform_device *pdev)
 	struct input_dev *idev;
 	struct mx25_tcq_priv *priv;
 	struct mx25_tsadc *tsadc = dev_get_drvdata(dev->parent);
-	struct resource *res;
 	void __iomem *mem;
 	int error;
 
@@ -512,8 +511,7 @@ static int mx25_tcq_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	priv->dev = dev;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	mem = devm_ioremap_resource(dev, res);
+	mem = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(mem))
 		return PTR_ERR(mem);
 
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
maintainer Applied
#2 lore raw

Re: [PATCH 1/5] Input: fsl-imx25-tcq: Use devm_platform_ioremap_resource()

Quoted 5 lines · Mukesh Ojha

devm_platform_ioremap_resource() internally have platform_get_resource() and devm_ioremap_resource() in it. So instead of calling them separately use devm_platform_ioremap_resource() directly.

Applied, thank you.

Quoted 30 lines
---
 drivers/input/touchscreen/fsl-imx25-tcq.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/touchscreen/fsl-imx25-tcq.c +1 -3
index 1d6c8f4..b66df8a 100644
@@ -503,7 +503,6 @@ static int mx25_tcq_probe(struct platform_device *pdev)
 	struct input_dev *idev;
 	struct mx25_tcq_priv *priv;
 	struct mx25_tsadc *tsadc = dev_get_drvdata(dev->parent);
-	struct resource *res;
 	void __iomem *mem;
 	int error;
 
@@ -512,8 +511,7 @@ static int mx25_tcq_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	priv->dev = dev;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	mem = devm_ioremap_resource(dev, res);
+	mem = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(mem))
 		return PTR_ERR(mem);
 
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Signature · 1 line
Dmitry
#3 lore raw

PATCH 2/5 Input: mxs-lradc-ts.c: Use devm_platform_ioremap_resource()

In reply to Mukesh Ojha

devm_platform_ioremap_resource() internally have platform_get_resource() and devm_ioremap_resource() in it. So instead of calling them separately use devm_platform_ioremap_resource() directly.

---
 drivers/input/touchscreen/mxs-lradc-ts.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/input/touchscreen/mxs-lradc-ts.c +1 -5
index c850b51..af047fa 100644
@@ -615,7 +615,6 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
 	struct device_node *node = dev->parent->of_node;
 	struct mxs_lradc *lradc = dev_get_drvdata(dev->parent);
 	struct mxs_lradc_ts *ts;
-	struct resource *iores;
 	int ret, irq, virq, i;
 	u32 ts_wires = 0, adapt;
 
@@ -629,10 +628,7 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
 	ts->dev = dev;
 	spin_lock_init(&ts->lock);
 
-	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!iores)
-		return -EINVAL;
-	ts->base = devm_ioremap(dev, iores->start, resource_size(iores));
+	ts->base = devm_platform_ioremap_resource(pdev, 0);
 	if (!ts->base)
 		return -ENOMEM;
 
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
maintainer
#4 lore raw

Re: [PATCH 2/5] Input: mxs-lradc-ts.c: Use devm_platform_ioremap_resource()

Quoted 22 lines · Mukesh Ojha

devm_platform_ioremap_resource() internally have platform_get_resource() and devm_ioremap_resource() in it. So instead of calling them separately use devm_platform_ioremap_resource() directly.

---
 drivers/input/touchscreen/mxs-lradc-ts.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/input/touchscreen/mxs-lradc-ts.c +0 -1
index c850b51..af047fa 100644
@@ -615,7 +615,6 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
 	struct device_node *node = dev->parent->of_node;
 	struct mxs_lradc *lradc = dev_get_drvdata(dev->parent);
 	struct mxs_lradc_ts *ts;
-	struct resource *iores;
 	int ret, irq, virq, i;
 	u32 ts_wires = 0, adapt;
 

drivers/input/touchscreen/mxs-lradc-ts.c static int mxs_lradc_ts_probe(struct platform_device *pdev) · line 633

Quoted 10 lines
drivers/input/touchscreen/mxs-lradc-ts.c +1 -4
@@ -629,10 +628,7 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
 	ts->dev = dev;
 	spin_lock_init(&ts->lock);
 
-	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!iores)
-		return -EINVAL;
-	ts->base = devm_ioremap(dev, iores->start, resource_size(iores));
+	ts->base = devm_platform_ioremap_resource(pdev, 0);
 	if (!ts->base)
 		return -ENOMEM;

This driver did not implement error handling properly (should have used IS_ERR()/PTR_ERR()), I adjusted and applied.

Thanks.

Signature · 1 line
Dmitry
#5 lore raw

PATCH 3/5 Input: s3c2410_ts: Use devm_platform_ioremap_resource()

In reply to Mukesh Ojha

devm_platform_ioremap_resource() internally have platform_get_resource() and devm_ioremap_resource() in it. So instead of calling them separately use devm_platform_ioremap_resource() directly.

---
 drivers/input/touchscreen/s3c2410_ts.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/input/touchscreen/s3c2410_ts.c +1 -9
index 1173890..e11cdae 100644
@@ -242,7 +242,6 @@ static int s3c2410ts_probe(struct platform_device *pdev)
 	struct s3c2410_ts_mach_info *info;
 	struct device *dev = &pdev->dev;
 	struct input_dev *input_dev;
-	struct resource *res;
 	int ret = -EINVAL;
 
 	/* Initialise input stuff */
@@ -277,14 +276,7 @@ static int s3c2410ts_probe(struct platform_device *pdev)
 		goto err_clk;
 	}
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(dev, "no resource for registers\n");
-		ret = -ENOENT;
-		goto err_clk;
-	}
-
-	ts.io = ioremap(res->start, resource_size(res));
+	ts.io = devm_platform_ioremap_resource(pdev, 0);
 	if (ts.io == NULL) {
 		dev_err(dev, "cannot map registers\n");
 		ret = -ENOMEM;
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
maintainer
#6 lore raw

Re: [PATCH 3/5] Input: s3c2410_ts: Use devm_platform_ioremap_resource()

Hi Mukesh,

Quoted 24 lines · Mukesh Ojha

devm_platform_ioremap_resource() internally have platform_get_resource() and devm_ioremap_resource() in it. So instead of calling them separately use devm_platform_ioremap_resource() directly.

---
 drivers/input/touchscreen/s3c2410_ts.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/input/touchscreen/s3c2410_ts.c +0 -1
index 1173890..e11cdae 100644
@@ -242,7 +242,6 @@ static int s3c2410ts_probe(struct platform_device *pdev)
 	struct s3c2410_ts_mach_info *info;
 	struct device *dev = &pdev->dev;
 	struct input_dev *input_dev;
-	struct resource *res;
 	int ret = -EINVAL;
 
 	/* Initialise input stuff */
@@ -277,14 +276,7 @@ static int s3c2410ts_probe(struct platform_device *pdev)
 		goto err_clk;
 	}

drivers/input/touchscreen/s3c2410_ts.c static int s3c2410ts_probe(struct platform_device *pdev) · line 279

Quoted 10 lines
drivers/input/touchscreen/s3c2410_ts.c +1 -8
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(dev, "no resource for registers\n");
-		ret = -ENOENT;
-		goto err_clk;
-	}
-
-	ts.io = ioremap(res->start, resource_size(res));
+	ts.io = devm_platform_ioremap_resource(pdev, 0);

This is not an equivalent transformation: the original code (rightly or wrongly) did not request the memory regions described by 'res' while new variant does.

Also you can't simply slap a single devm resource in a driver that does not use managed resources as it messes up the release order.

Signature · 1 line
Dmitry
#7 lore raw

PATCH 4/5 Input: sun4i-ts: Use devm_platform_ioremap_resource()

In reply to Mukesh Ojha

devm_platform_ioremap_resource() internally have platform_get_resource() and devm_ioremap_resource() in it. So instead of calling them separately use devm_platform_ioremap_resource() directly.

---
 drivers/input/touchscreen/sun4i-ts.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/input/touchscreen/sun4i-ts.c +1 -2
index d2e14d9..bbb0104 100644
@@ -309,8 +309,7 @@ static int sun4i_ts_probe(struct platform_device *pdev)
 		input_set_drvdata(ts->input, ts);
 	}
 
-	ts->base = devm_ioremap_resource(dev,
-			      platform_get_resource(pdev, IORESOURCE_MEM, 0));
+	ts->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(ts->base))
 		return PTR_ERR(ts->base);
 
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
maintainer Applied
#8 lore raw

Re: [PATCH 4/5] Input: sun4i-ts: Use devm_platform_ioremap_resource()

Quoted 5 lines · Mukesh Ojha

devm_platform_ioremap_resource() internally have platform_get_resource() and devm_ioremap_resource() in it. So instead of calling them separately use devm_platform_ioremap_resource() directly.

Applied, thank you.

Quoted 22 lines
---
 drivers/input/touchscreen/sun4i-ts.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/input/touchscreen/sun4i-ts.c +1 -2
index d2e14d9..bbb0104 100644
@@ -309,8 +309,7 @@ static int sun4i_ts_probe(struct platform_device *pdev)
 		input_set_drvdata(ts->input, ts);
 	}
 
-	ts->base = devm_ioremap_resource(dev,
-			      platform_get_resource(pdev, IORESOURCE_MEM, 0));
+	ts->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(ts->base))
 		return PTR_ERR(ts->base);
 
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Signature · 1 line
Dmitry
#9 lore raw

PATCH 5/5 Input: ts4800-ts: Use devm_platform_ioremap_resource()

In reply to Mukesh Ojha

devm_platform_ioremap_resource() internally have platform_get_resource() and devm_ioremap_resource() in it. So instead of calling them separately use devm_platform_ioremap_resource() directly.

---
 drivers/input/touchscreen/ts4800-ts.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/touchscreen/ts4800-ts.c +1 -3
index fed73ee..5b4f536 100644
@@ -148,7 +148,6 @@ static int ts4800_ts_probe(struct platform_device *pdev)
 {
 	struct input_polled_dev *poll_dev;
 	struct ts4800_ts *ts;
-	struct resource *res;
 	int error;
 
 	ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL);
@@ -159,8 +158,7 @@ static int ts4800_ts_probe(struct platform_device *pdev)
 	if (error)
 		return error;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	ts->base = devm_ioremap_resource(&pdev->dev, res);
+	ts->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(ts->base))
 		return PTR_ERR(ts->base);
 
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
maintainer Applied
#10 lore raw

Re: [PATCH 5/5] Input: ts4800-ts: Use devm_platform_ioremap_resource()

Quoted 5 lines · Mukesh Ojha

devm_platform_ioremap_resource() internally have platform_get_resource() and devm_ioremap_resource() in it. So instead of calling them separately use devm_platform_ioremap_resource() directly.

Applied, thank you.

Quoted 30 lines
---
 drivers/input/touchscreen/ts4800-ts.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/touchscreen/ts4800-ts.c +1 -3
index fed73ee..5b4f536 100644
@@ -148,7 +148,6 @@ static int ts4800_ts_probe(struct platform_device *pdev)
 {
 	struct input_polled_dev *poll_dev;
 	struct ts4800_ts *ts;
-	struct resource *res;
 	int error;
 
 	ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL);
@@ -159,8 +158,7 @@ static int ts4800_ts_probe(struct platform_device *pdev)
 	if (error)
 		return error;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	ts->base = devm_ioremap_resource(&pdev->dev, res);
+	ts->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(ts->base))
 		return PTR_ERR(ts->base);
 
Signature · 2 lines
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Signature · 1 line
Dmitry