linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: npcm7xx: Add missing check for ioremap
@ 2023-06-07  9:58 Jiasheng Jiang
  2023-06-07 17:57 ` andy.shevchenko
  2023-06-09  7:43 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Jiasheng Jiang @ 2023-06-07  9:58 UTC (permalink / raw)
  To: avifishman70, tmaimon77, tali.perry1, venture, yuenn,
	benjaminfair, linus.walleij
  Cc: openbmc, linux-gpio, linux-kernel, Jiasheng Jiang

Add check for ioremap() and return the error if it fails in order to
guarantee the success of ioremap().

Fixes: 3b588e43ee5c ("pinctrl: nuvoton: add NPCM7xx pinctrl and GPIO driver")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
index 21e61c2a3798..843ffcd96877 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
@@ -1884,6 +1884,8 @@ static int npcm7xx_gpio_of(struct npcm7xx_pinctrl *pctrl)
 		}
 
 		pctrl->gpio_bank[id].base = ioremap(res.start, resource_size(&res));
+		if (!pctrl->gpio_bank[id].base)
+			return -EINVAL;
 
 		ret = bgpio_init(&pctrl->gpio_bank[id].gc, dev, 4,
 				 pctrl->gpio_bank[id].base + NPCM7XX_GP_N_DIN,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] pinctrl: npcm7xx: Add missing check for ioremap
  2023-06-07  9:58 [PATCH] pinctrl: npcm7xx: Add missing check for ioremap Jiasheng Jiang
@ 2023-06-07 17:57 ` andy.shevchenko
  2023-06-09  7:43 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: andy.shevchenko @ 2023-06-07 17:57 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: avifishman70, tmaimon77, tali.perry1, venture, yuenn,
	benjaminfair, linus.walleij, openbmc, linux-gpio, linux-kernel

Wed, Jun 07, 2023 at 05:58:29PM +0800, Jiasheng Jiang kirjoitti:
> Add check for ioremap() and return the error if it fails in order to
> guarantee the success of ioremap().

This one is correct, otherwise the GPIO is not functional at all.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Fixes: 3b588e43ee5c ("pinctrl: nuvoton: add NPCM7xx pinctrl and GPIO driver")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
> index 21e61c2a3798..843ffcd96877 100644
> --- a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
> +++ b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
> @@ -1884,6 +1884,8 @@ static int npcm7xx_gpio_of(struct npcm7xx_pinctrl *pctrl)
>  		}
>  
>  		pctrl->gpio_bank[id].base = ioremap(res.start, resource_size(&res));
> +		if (!pctrl->gpio_bank[id].base)
> +			return -EINVAL;
>  
>  		ret = bgpio_init(&pctrl->gpio_bank[id].gc, dev, 4,
>  				 pctrl->gpio_bank[id].base + NPCM7XX_GP_N_DIN,

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pinctrl: npcm7xx: Add missing check for ioremap
  2023-06-07  9:58 [PATCH] pinctrl: npcm7xx: Add missing check for ioremap Jiasheng Jiang
  2023-06-07 17:57 ` andy.shevchenko
@ 2023-06-09  7:43 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2023-06-09  7:43 UTC (permalink / raw)
  To: Jiasheng Jiang
  Cc: avifishman70, tmaimon77, tali.perry1, venture, yuenn,
	benjaminfair, openbmc, linux-gpio, linux-kernel

On Wed, Jun 7, 2023 at 11:58 AM Jiasheng Jiang <jiasheng@iscas.ac.cn> wrote:

> Add check for ioremap() and return the error if it fails in order to
> guarantee the success of ioremap().
>
> Fixes: 3b588e43ee5c ("pinctrl: nuvoton: add NPCM7xx pinctrl and GPIO driver")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>

Patch applied as nonurgent fix.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-09  7:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-07  9:58 [PATCH] pinctrl: npcm7xx: Add missing check for ioremap Jiasheng Jiang
2023-06-07 17:57 ` andy.shevchenko
2023-06-09  7:43 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).