From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C18EAC77B7A for ; Wed, 7 Jun 2023 17:57:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231977AbjFGR5w (ORCPT ); Wed, 7 Jun 2023 13:57:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232400AbjFGR5w (ORCPT ); Wed, 7 Jun 2023 13:57:52 -0400 Received: from fgw23-7.mail.saunalahti.fi (fgw23-7.mail.saunalahti.fi [62.142.5.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E0841FD4 for ; Wed, 7 Jun 2023 10:57:49 -0700 (PDT) Received: from localhost (88-113-24-87.elisa-laajakaista.fi [88.113.24.87]) by fgw23.mail.saunalahti.fi (Halon) with ESMTP id c846300f-055c-11ee-b972-005056bdfda7; Wed, 07 Jun 2023 20:57:35 +0300 (EEST) From: andy.shevchenko@gmail.com Date: Wed, 7 Jun 2023 20:57:34 +0300 To: Jiasheng Jiang Cc: avifishman70@gmail.com, tmaimon77@gmail.com, tali.perry1@gmail.com, venture@google.com, yuenn@google.com, benjaminfair@google.com, linus.walleij@linaro.org, openbmc@lists.ozlabs.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] pinctrl: npcm7xx: Add missing check for ioremap Message-ID: References: <20230607095829.1345-1-jiasheng@iscas.ac.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230607095829.1345-1-jiasheng@iscas.ac.cn> Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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 > Fixes: 3b588e43ee5c ("pinctrl: nuvoton: add NPCM7xx pinctrl and GPIO driver") > Signed-off-by: Jiasheng Jiang > --- > 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 592FCC77B7A for ; Wed, 7 Jun 2023 17:59:17 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Qbw8M3bk7z3dyw for ; Thu, 8 Jun 2023 03:59:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=softfail (domain owner discourages use of this host) smtp.mailfrom=gmail.com (client-ip=62.142.5.84; helo=fgw23-7.mail.saunalahti.fi; envelope-from=andy.shevchenko@gmail.com; receiver=) Received: from fgw23-7.mail.saunalahti.fi (fgw23-7.mail.saunalahti.fi [62.142.5.84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Qbw7m3YGHz3dsR for ; Thu, 8 Jun 2023 03:58:42 +1000 (AEST) Received: from localhost (88-113-24-87.elisa-laajakaista.fi [88.113.24.87]) by fgw23.mail.saunalahti.fi (Halon) with ESMTP id c846300f-055c-11ee-b972-005056bdfda7; Wed, 07 Jun 2023 20:57:35 +0300 (EEST) From: andy.shevchenko@gmail.com Date: Wed, 7 Jun 2023 20:57:34 +0300 To: Jiasheng Jiang Subject: Re: [PATCH] pinctrl: npcm7xx: Add missing check for ioremap Message-ID: References: <20230607095829.1345-1-jiasheng@iscas.ac.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230607095829.1345-1-jiasheng@iscas.ac.cn> X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: benjaminfair@google.com, linux-gpio@vger.kernel.org, avifishman70@gmail.com, venture@google.com, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, tali.perry1@gmail.com, openbmc@lists.ozlabs.org, tmaimon77@gmail.com Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Sender: "openbmc" 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 > Fixes: 3b588e43ee5c ("pinctrl: nuvoton: add NPCM7xx pinctrl and GPIO driver") > Signed-off-by: Jiasheng Jiang > --- > 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