All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
To: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>,
	Linus Walleij <linus.walleij@linaro.org>,
	Ray Jui <rjui@broadcom.com>,
	bcm-kernel-feedback-list@broadcom.com,
	linux-gpio <linux-gpio@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Xuefeng Li <lixuefeng@loongson.cn>
Subject: Re: [PATCH 2/3] gpio: pxa: Fix return value of pxa_gpio_probe()
Date: Mon, 25 May 2020 11:14:23 +0200	[thread overview]
Message-ID: <CAMpxmJXc5-+hj5p2GTMJR4MZX95YWpTTg5FHD79au8pdcYi6mA@mail.gmail.com> (raw)
In-Reply-To: <3382c1df-1429-ecd3-70b6-35bc00343608@loongson.cn>

sob., 23 maj 2020 o 05:25 Tiezhu Yang <yangtiezhu@loongson.cn> napisał(a):
>
> On 05/23/2020 03:07 AM, Robert Jarzmik wrote:
> > Tiezhu Yang <yangtiezhu@loongson.cn> writes:
> >
> >> When call function devm_platform_ioremap_resource(), we should use IS_ERR()
> >> to check the return value and return PTR_ERR() if failed.
> >>
> >> Fixes: 542c25b7a209 ("drivers: gpio: pxa: use devm_platform_ioremap_resource()")
> >> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> >> ---
> >>   drivers/gpio/gpio-pxa.c | 4 ++--
> >>   1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
> >> index 1361270..0cb6600 100644
> >> --- a/drivers/gpio/gpio-pxa.c
> >> +++ b/drivers/gpio/gpio-pxa.c
> >> @@ -660,8 +660,8 @@ static int pxa_gpio_probe(struct platform_device *pdev)
> >>      pchip->irq1 = irq1;
> >>
> >>      gpio_reg_base = devm_platform_ioremap_resource(pdev, 0);
> >> -    if (!gpio_reg_base)
> >> -            return -EINVAL;
> >> +    if (IS_ERR(gpio_reg_base))
> >> +            return PTR_ERR(gpio_reg_base);
> > As far as I know, devm_platform_ioremap_resource() could return NULL which is
> > not handled by this test (unless __devm_ioremap() semantics changed since I had
> > a look).
>
> Hi Robert,
>
> In the function __devm_ioremap_resource(), if __devm_ioremap returns NULL,
> it will return IOMEM_ERR_PTR(-ENOMEM).
>
> devm_platform_ioremap_resource()
>          devm_ioremap_resource()
>                  __devm_ioremap_resource()
>                         __devm_ioremap()
>
> static void __iomem *
> __devm_ioremap_resource(struct device *dev, const struct resource *res,
>              enum devm_ioremap_type type)
> {
> ...
>      dest_ptr = __devm_ioremap(dev, res->start, size, type);
>      if (!dest_ptr) {
>          dev_err(dev, "ioremap failed for resource %pR\n", res);
>          devm_release_mem_region(dev, res->start, size);
>          dest_ptr = IOMEM_ERR_PTR(-ENOMEM);
>      }
>
>      return dest_ptr;
> }
>
> And also, we can see the comment of devm_ioremap_resource():
>
> Usage example:
>
>          res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>          base = devm_ioremap_resource(&pdev->dev, res);
>          if (IS_ERR(base))
>                  return PTR_ERR(base);
>
> >
> > Therefore, this patch is incorrect, or rather incomplete.
>
> So I think this patch is correct, do I miss something?
>
>

Yes, this patch is correct. Applied for fixes.

Bart

  reply	other threads:[~2020-05-25  9:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22  4:12 [PATCH 1/3] gpio: bcm-kona: Fix return value of bcm_kona_gpio_probe() Tiezhu Yang
2020-05-22  4:12 ` [PATCH 2/3] gpio: pxa: Fix return value of pxa_gpio_probe() Tiezhu Yang
2020-05-22 19:07   ` Robert Jarzmik
2020-05-23  3:24     ` Tiezhu Yang
2020-05-25  9:14       ` Bartosz Golaszewski [this message]
2020-05-27 18:26       ` Robert Jarzmik
2020-05-22  4:12 ` [PATCH 3/3] gpio: pxa: Add COMPILE_TEST support Tiezhu Yang
2020-05-25  9:15   ` Bartosz Golaszewski
2020-05-25  9:16 ` [PATCH 1/3] gpio: bcm-kona: Fix return value of bcm_kona_gpio_probe() Bartosz Golaszewski

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=CAMpxmJXc5-+hj5p2GTMJR4MZX95YWpTTg5FHD79au8pdcYi6mA@mail.gmail.com \
    --to=bgolaszewski@baylibre.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=rjui@broadcom.com \
    --cc=robert.jarzmik@free.fr \
    --cc=yangtiezhu@loongson.cn \
    /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.