2019-04-04 07:18:32

by Mukesh Ojha

[permalink] [raw]
Subject: [PATCH 0/5] 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(-)

--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project


2019-04-04 07:19:05

by Mukesh Ojha

[permalink] [raw]
Subject: [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.

Signed-off-by: Mukesh Ojha <[email protected]>
---
drivers/input/touchscreen/fsl-imx25-tcq.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/fsl-imx25-tcq.c b/drivers/input/touchscreen/fsl-imx25-tcq.c
index 1d6c8f4..b66df8a 100644
--- a/drivers/input/touchscreen/fsl-imx25-tcq.c
+++ b/drivers/input/touchscreen/fsl-imx25-tcq.c
@@ -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);

--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

2019-04-04 07:19:17

by Mukesh Ojha

[permalink] [raw]
Subject: [PATCH 2/5] Input: mxs-lradc-ts.c: 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.

Signed-off-by: Mukesh Ojha <[email protected]>
---
drivers/input/touchscreen/mxs-lradc-ts.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/input/touchscreen/mxs-lradc-ts.c b/drivers/input/touchscreen/mxs-lradc-ts.c
index c850b51..af047fa 100644
--- a/drivers/input/touchscreen/mxs-lradc-ts.c
+++ b/drivers/input/touchscreen/mxs-lradc-ts.c
@@ -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;

--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

2019-04-04 07:19:44

by Mukesh Ojha

[permalink] [raw]
Subject: [PATCH 3/5] Input: s3c2410_ts: 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.

Signed-off-by: Mukesh Ojha <[email protected]>
---
drivers/input/touchscreen/s3c2410_ts.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c
index 1173890..e11cdae 100644
--- a/drivers/input/touchscreen/s3c2410_ts.c
+++ b/drivers/input/touchscreen/s3c2410_ts.c
@@ -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;
--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

2019-04-04 07:20:12

by Mukesh Ojha

[permalink] [raw]
Subject: [PATCH 5/5] Input: ts4800-ts: 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.

Signed-off-by: Mukesh Ojha <[email protected]>
---
drivers/input/touchscreen/ts4800-ts.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/ts4800-ts.c b/drivers/input/touchscreen/ts4800-ts.c
index fed73ee..5b4f536 100644
--- a/drivers/input/touchscreen/ts4800-ts.c
+++ b/drivers/input/touchscreen/ts4800-ts.c
@@ -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);

--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

2019-04-04 07:20:26

by Mukesh Ojha

[permalink] [raw]
Subject: [PATCH 4/5] Input: sun4i-ts: 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.

Signed-off-by: Mukesh Ojha <[email protected]>
---
drivers/input/touchscreen/sun4i-ts.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscreen/sun4i-ts.c
index d2e14d9..bbb0104 100644
--- a/drivers/input/touchscreen/sun4i-ts.c
+++ b/drivers/input/touchscreen/sun4i-ts.c
@@ -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);

--
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

2019-07-16 15:53:28

by Dmitry Torokhov

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

On Thu, Apr 04, 2019 at 12:47:19PM +0530, Mukesh Ojha wrote:
> 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.
>
> Signed-off-by: Mukesh Ojha <[email protected]>

Applied, thank you.

> ---
> drivers/input/touchscreen/fsl-imx25-tcq.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/input/touchscreen/fsl-imx25-tcq.c b/drivers/input/touchscreen/fsl-imx25-tcq.c
> index 1d6c8f4..b66df8a 100644
> --- a/drivers/input/touchscreen/fsl-imx25-tcq.c
> +++ b/drivers/input/touchscreen/fsl-imx25-tcq.c
> @@ -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);
>
> --
> Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
> Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
>

--
Dmitry

2019-07-16 15:53:36

by Dmitry Torokhov

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

On Thu, Apr 04, 2019 at 12:47:23PM +0530, Mukesh Ojha wrote:
> 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.
>
> Signed-off-by: Mukesh Ojha <[email protected]>

Applied, thank you.

> ---
> drivers/input/touchscreen/ts4800-ts.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ts4800-ts.c b/drivers/input/touchscreen/ts4800-ts.c
> index fed73ee..5b4f536 100644
> --- a/drivers/input/touchscreen/ts4800-ts.c
> +++ b/drivers/input/touchscreen/ts4800-ts.c
> @@ -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);
>
> --
> Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
> Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
>

--
Dmitry

2019-07-16 15:53:58

by Dmitry Torokhov

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

Hi Mukesh,

On Thu, Apr 04, 2019 at 12:47:21PM +0530, Mukesh Ojha wrote:
> 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.
>
> Signed-off-by: Mukesh Ojha <[email protected]>
> ---
> drivers/input/touchscreen/s3c2410_ts.c | 10 +---------
> 1 file changed, 1 insertion(+), 9 deletions(-)
>
> diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c
> index 1173890..e11cdae 100644
> --- a/drivers/input/touchscreen/s3c2410_ts.c
> +++ b/drivers/input/touchscreen/s3c2410_ts.c
> @@ -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);

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.

--
Dmitry

2019-07-16 15:54:11

by Dmitry Torokhov

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

On Thu, Apr 04, 2019 at 12:47:20PM +0530, Mukesh Ojha wrote:
> 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.
>
> Signed-off-by: Mukesh Ojha <[email protected]>
> ---
> drivers/input/touchscreen/mxs-lradc-ts.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/input/touchscreen/mxs-lradc-ts.c b/drivers/input/touchscreen/mxs-lradc-ts.c
> index c850b51..af047fa 100644
> --- a/drivers/input/touchscreen/mxs-lradc-ts.c
> +++ b/drivers/input/touchscreen/mxs-lradc-ts.c
> @@ -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;

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

Thanks.

--
Dmitry

2019-07-16 15:55:36

by Dmitry Torokhov

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

On Thu, Apr 04, 2019 at 12:47:22PM +0530, Mukesh Ojha wrote:
> 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.
>
> Signed-off-by: Mukesh Ojha <[email protected]>

Applied, thank you.

> ---
> drivers/input/touchscreen/sun4i-ts.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/input/touchscreen/sun4i-ts.c b/drivers/input/touchscreen/sun4i-ts.c
> index d2e14d9..bbb0104 100644
> --- a/drivers/input/touchscreen/sun4i-ts.c
> +++ b/drivers/input/touchscreen/sun4i-ts.c
> @@ -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);
>
> --
> Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
> Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
>

--
Dmitry