diff mbox

input: touchscreen: mxs-lradc: Use devm_ioremap_resource()

Message ID 1498053804-11297-1-git-send-email-fabio.estevam@nxp.com (mailing list archive)
State New, archived
Headers show

Commit Message

Fabio Estevam June 21, 2017, 2:03 p.m. UTC
In case of error devm_ioremap() returns NULL pointer not ERR_PTR().

The iores NULL check is also missing.

Fix both problems by using devm_ioremap_resource() variant instead.

Fixes: d81ca730e3e4 ("input: touchscreen: mxs-lradc: Add support for touchscreen")
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
 drivers/input/touchscreen/mxs-lradc-ts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Fabio Estevam June 22, 2017, 2:44 a.m. UTC | #1
On Wed, Jun 21, 2017 at 11:03 AM, Fabio Estevam <fabio.estevam@nxp.com> wrote:
> In case of error devm_ioremap() returns NULL pointer not ERR_PTR().
>
> The iores NULL check is also missing.
>
> Fix both problems by using devm_ioremap_resource() variant instead.
>
> Fixes: d81ca730e3e4 ("input: touchscreen: mxs-lradc: Add support for touchscreen")
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
>  drivers/input/touchscreen/mxs-lradc-ts.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/input/touchscreen/mxs-lradc-ts.c b/drivers/input/touchscreen/mxs-lradc-ts.c
> index 58c016c..0f8c9e7 100644
> --- a/drivers/input/touchscreen/mxs-lradc-ts.c
> +++ b/drivers/input/touchscreen/mxs-lradc-ts.c
> @@ -630,7 +630,7 @@ static int mxs_lradc_ts_probe(struct platform_device *pdev)
>         spin_lock_init(&ts->lock);
>
>         iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -       ts->base = devm_ioremap(dev, iores->start, resource_size(iores));
> +       ts->base = devm_ioremap_resource(dev, iores);
>         if (IS_ERR(ts->base))
>                 return PTR_ERR(ts->base);

It seems we cannot use devm_ioremap_resource() in this case as it
shares the resources with the lradc driver:
http://www.spinics.net/lists/linux-iio/msg32864.html

I will send a v2 that does a NULL check on iores.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/input/touchscreen/mxs-lradc-ts.c b/drivers/input/touchscreen/mxs-lradc-ts.c
index 58c016c..0f8c9e7 100644
--- a/drivers/input/touchscreen/mxs-lradc-ts.c
+++ b/drivers/input/touchscreen/mxs-lradc-ts.c
@@ -630,7 +630,7 @@  static int mxs_lradc_ts_probe(struct platform_device *pdev)
 	spin_lock_init(&ts->lock);
 
 	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	ts->base = devm_ioremap(dev, iores->start, resource_size(iores));
+	ts->base = devm_ioremap_resource(dev, iores);
 	if (IS_ERR(ts->base))
 		return PTR_ERR(ts->base);