pinctrl:Convert the composition of devm_request_mem_region and devm_ioremap to a single call
diff mbox

Message ID 1446191478-22714-1-git-send-email-sanjeev_sharma@mentor.com
State New
Headers show

Commit Message

Sanjeev Sharma Oct. 30, 2015, 7:51 a.m. UTC
Use devm_ioremap_resource() in order to make the code simpler,
and remove redundant return value check of platform_get_resource()
because this value is alreadytaken care by devm_ioremap_resource()

Signed-off-by: Sanjeev Sharma <sanjeev_sharma@mentor.com>
---
 drivers/pinctrl/pinctrl-single.c | 21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

Comments

Linus Walleij Oct. 30, 2015, 7:53 p.m. UTC | #1
Please run posts like this by the maintainers. Tony Lindgren is one
user, Haojian is another.

Your top-poster,
Linus Walleij

On Fri, Oct 30, 2015 at 8:51 AM, Sanjeev Sharma
<sanjeev_sharma@mentor.com> wrote:
> Use devm_ioremap_resource() in order to make the code simpler,
> and remove redundant return value check of platform_get_resource()
> because this value is alreadytaken care by devm_ioremap_resource()
>
> Signed-off-by: Sanjeev Sharma <sanjeev_sharma@mentor.com>
> ---
>  drivers/pinctrl/pinctrl-single.c | 21 +++------------------
>  1 file changed, 3 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index ef04b96..905cc0a 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -1865,24 +1865,9 @@ static int pcs_probe(struct platform_device *pdev)
>                                                   "pinctrl-single,bit-per-mux");
>
>         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -       if (!res) {
> -               dev_err(pcs->dev, "could not get resource\n");
> -               return -ENODEV;
> -       }
> -
> -       pcs->res = devm_request_mem_region(pcs->dev, res->start,
> -                       resource_size(res), DRIVER_NAME);
> -       if (!pcs->res) {
> -               dev_err(pcs->dev, "could not get mem_region\n");
> -               return -EBUSY;
> -       }
> -
> -       pcs->size = resource_size(pcs->res);
> -       pcs->base = devm_ioremap(pcs->dev, pcs->res->start, pcs->size);
> -       if (!pcs->base) {
> -               dev_err(pcs->dev, "could not ioremap\n");
> -               return -ENODEV;
> -       }
> +       pcs->base = devm_ioremap_resource(pcs->dev, res);
> +       if (IS_ERR(pcs->base))
> +               return PTR_ERR(pcs->base);
>
>         INIT_RADIX_TREE(&pcs->pgtree, GFP_KERNEL);
>         INIT_RADIX_TREE(&pcs->ftree, GFP_KERNEL);
> --
> 1.7.11.7
>
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tony Lindgren Dec. 3, 2015, 9:44 p.m. UTC | #2
* Linus Walleij <linus.walleij@linaro.org> [151030 12:54]:
> Please run posts like this by the maintainers. Tony Lindgren is one
> user, Haojian is another.

I think we need to add ourselves to MAINTAINERS for this driver,
otherwise we'll keep on missing emails.

> On Fri, Oct 30, 2015 at 8:51 AM, Sanjeev Sharma
> <sanjeev_sharma@mentor.com> wrote:
> > Use devm_ioremap_resource() in order to make the code simpler,
> > and remove redundant return value check of platform_get_resource()
> > because this value is alreadytaken care by devm_ioremap_resource()
> >
> > Signed-off-by: Sanjeev Sharma <sanjeev_sharma@mentor.com>
> > ---
> >  drivers/pinctrl/pinctrl-single.c | 21 +++------------------
> >  1 file changed, 3 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> > index ef04b96..905cc0a 100644
> > --- a/drivers/pinctrl/pinctrl-single.c
> > +++ b/drivers/pinctrl/pinctrl-single.c
> > @@ -1865,24 +1865,9 @@ static int pcs_probe(struct platform_device *pdev)
> >                                                   "pinctrl-single,bit-per-mux");
> >
> >         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > -       if (!res) {
> > -               dev_err(pcs->dev, "could not get resource\n");
> > -               return -ENODEV;
> > -       }
> > -
> > -       pcs->res = devm_request_mem_region(pcs->dev, res->start,
> > -                       resource_size(res), DRIVER_NAME);
> > -       if (!pcs->res) {
> > -               dev_err(pcs->dev, "could not get mem_region\n");
> > -               return -EBUSY;
> > -       }
> > -
> > -       pcs->size = resource_size(pcs->res);
> > -       pcs->base = devm_ioremap(pcs->dev, pcs->res->start, pcs->size);
> > -       if (!pcs->base) {
> > -               dev_err(pcs->dev, "could not ioremap\n");
> > -               return -ENODEV;
> > -       }
> > +       pcs->base = devm_ioremap_resource(pcs->dev, res);
> > +       if (IS_ERR(pcs->base))
> > +               return PTR_ERR(pcs->base);
> >
> >         INIT_RADIX_TREE(&pcs->pgtree, GFP_KERNEL);
> >         INIT_RADIX_TREE(&pcs->ftree, GFP_KERNEL);

This won't work, we're using the physical address from pcs->res in the
code at least in pcs_add_pin.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij Dec. 10, 2015, 6:17 p.m. UTC | #3
On Thu, Dec 3, 2015 at 10:44 PM, Tony Lindgren <tony@atomide.com> wrote:
> * Linus Walleij <linus.walleij@linaro.org> [151030 12:54]:
>> Please run posts like this by the maintainers. Tony Lindgren is one
>> user, Haojian is another.
>
> I think we need to add ourselves to MAINTAINERS for this driver,
> otherwise we'll keep on missing emails.

Good idea! Patches accepted.

> This won't work, we're using the physical address from pcs->res in the
> code at least in pcs_add_pin.

Dropping this patch for now.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index ef04b96..905cc0a 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1865,24 +1865,9 @@  static int pcs_probe(struct platform_device *pdev)
 						  "pinctrl-single,bit-per-mux");
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(pcs->dev, "could not get resource\n");
-		return -ENODEV;
-	}
-
-	pcs->res = devm_request_mem_region(pcs->dev, res->start,
-			resource_size(res), DRIVER_NAME);
-	if (!pcs->res) {
-		dev_err(pcs->dev, "could not get mem_region\n");
-		return -EBUSY;
-	}
-
-	pcs->size = resource_size(pcs->res);
-	pcs->base = devm_ioremap(pcs->dev, pcs->res->start, pcs->size);
-	if (!pcs->base) {
-		dev_err(pcs->dev, "could not ioremap\n");
-		return -ENODEV;
-	}
+	pcs->base = devm_ioremap_resource(pcs->dev, res);
+	if (IS_ERR(pcs->base))
+		return PTR_ERR(pcs->base);
 
 	INIT_RADIX_TREE(&pcs->pgtree, GFP_KERNEL);
 	INIT_RADIX_TREE(&pcs->ftree, GFP_KERNEL);