All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
To: qiwuchen55@gmail.com
Cc: Linus Walleij <linus.walleij@linaro.org>,
	linux-gpio <linux-gpio@vger.kernel.org>,
	chenqiwu <chenqiwu@xiaomi.com>
Subject: Re: [PATCH] gpio: mmio: use devm_platform_ioremap_resource_byname()
Date: Mon, 17 Feb 2020 11:02:46 +0100	[thread overview]
Message-ID: <CAMpxmJW1-r2iL+mJ9azyihYcp-_Km__FAanBvN4UUG6C8ZXKQQ@mail.gmail.com> (raw)
In-Reply-To: <1581690602-345-1-git-send-email-qiwuchen55@gmail.com>

pt., 14 lut 2020 o 15:30 <qiwuchen55@gmail.com> napisał(a):
>
> From: chenqiwu <chenqiwu@xiaomi.com>
>
> Use devm_platform_ioremap_resource_byname() instead of calling
> platform_get_resource_byname() and devm_ioremap_resource() separately.
>
> Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
> ---
>  drivers/gpio/gpio-mmio.c | 26 +++++++-------------------
>  1 file changed, 7 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mmio.c b/drivers/gpio/gpio-mmio.c
> index f729e3e..5cfef3c 100644
> --- a/drivers/gpio/gpio-mmio.c
> +++ b/drivers/gpio/gpio-mmio.c
> @@ -655,21 +655,9 @@ int bgpio_init(struct gpio_chip *gc, struct device *dev,
>  #if IS_ENABLED(CONFIG_GPIO_GENERIC_PLATFORM)
>
>  static void __iomem *bgpio_map(struct platform_device *pdev,
> -                              const char *name,
> -                              resource_size_t sane_sz)
> +                              const char *name)
>  {
> -       struct resource *r;
> -       resource_size_t sz;
> -
> -       r = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
> -       if (!r)
> -               return NULL;
> -
> -       sz = resource_size(r);
> -       if (sz != sane_sz)
> -               return IOMEM_ERR_PTR(-EINVAL);
> -
> -       return devm_ioremap_resource(&pdev->dev, r);
> +       return devm_platform_ioremap_resource_byname(pdev, name);
>  }
>
>  #ifdef CONFIG_OF
> @@ -742,23 +730,23 @@ static int bgpio_pdev_probe(struct platform_device *pdev)
>
>         sz = resource_size(r);
>
> -       dat = bgpio_map(pdev, "dat", sz);
> +       dat = bgpio_map(pdev, "dat");
>         if (IS_ERR(dat))
>                 return PTR_ERR(dat);
>
> -       set = bgpio_map(pdev, "set", sz);
> +       set = bgpio_map(pdev, "set");
>         if (IS_ERR(set))
>                 return PTR_ERR(set);
>
> -       clr = bgpio_map(pdev, "clr", sz);
> +       clr = bgpio_map(pdev, "clr");
>         if (IS_ERR(clr))
>                 return PTR_ERR(clr);
>
> -       dirout = bgpio_map(pdev, "dirout", sz);
> +       dirout = bgpio_map(pdev, "dirout");
>         if (IS_ERR(dirout))
>                 return PTR_ERR(dirout);
>
> -       dirin = bgpio_map(pdev, "dirin", sz);
> +       dirin = bgpio_map(pdev, "dirin");
>         if (IS_ERR(dirin))
>                 return PTR_ERR(dirin);
>
> --
> 1.9.1
>

Why not remove bgpio_map() entirely then?

Bart

      reply	other threads:[~2020-02-17 10:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-14 14:30 [PATCH] gpio: mmio: use devm_platform_ioremap_resource_byname() qiwuchen55
2020-02-17 10:02 ` Bartosz Golaszewski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMpxmJW1-r2iL+mJ9azyihYcp-_Km__FAanBvN4UUG6C8ZXKQQ@mail.gmail.com \
    --to=bgolaszewski@baylibre.com \
    --cc=chenqiwu@xiaomi.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=qiwuchen55@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.