From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Ruan Jinjie <ruanjinjie@huawei.com>
Cc: linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
Codrin Ciubotariu <codrin.ciubotariu@microchip.com>,
Andi Shyti <andi.shyti@kernel.org>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
Oleksij Rempel <linux@rempel-privat.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
NXP Linux Team <linux-imx@nxp.com>
Subject: Re: [PATCH -next] I2C: Use helper function IS_ERR_OR_NULL()
Date: Wed, 16 Aug 2023 11:08:03 +0100 [thread overview]
Message-ID: <ZNygA72nKogZvlG3@shell.armlinux.org.uk> (raw)
In-Reply-To: <50f61322-de65-1632-d404-7dcfe9a82744@huawei.com>
On Wed, Aug 16, 2023 at 05:48:34PM +0800, Ruan Jinjie wrote:
>
>
> On 2023/8/16 17:46, Ruan Jinjie wrote:
> > Use IS_ERR_OR_NULL() instead of open-coding it
> > to simplify the code.
> >
> > Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
> > ---
> > drivers/i2c/busses/i2c-at91-master.c | 2 +-
> > drivers/i2c/busses/i2c-imx.c | 2 +-
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-at91-master.c b/drivers/i2c/busses/i2c-at91-master.c
> > index 94cff1cd527e..0e454c04a145 100644
> > --- a/drivers/i2c/busses/i2c-at91-master.c
> > +++ b/drivers/i2c/busses/i2c-at91-master.c
> > @@ -831,7 +831,7 @@ static int at91_init_twi_recovery_gpio(struct platform_device *pdev,
> > struct i2c_bus_recovery_info *rinfo = &dev->rinfo;
> >
> > rinfo->pinctrl = devm_pinctrl_get(&pdev->dev);
> > - if (!rinfo->pinctrl || IS_ERR(rinfo->pinctrl)) {
> > + if (IS_ERR_OR_NULL(rinfo->pinctrl)) {
> > dev_info(dev->dev, "can't get pinctrl, bus recovery not supported\n");
> > return PTR_ERR(rinfo->pinctrl);
> > }
> > diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> > index 10e89586ca72..8807c90df749 100644
> > --- a/drivers/i2c/busses/i2c-imx.c
> > +++ b/drivers/i2c/busses/i2c-imx.c
> > @@ -1388,7 +1388,7 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
> > struct i2c_bus_recovery_info *rinfo = &i2c_imx->rinfo;
> >
> > i2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev);
> > - if (!i2c_imx->pinctrl || IS_ERR(i2c_imx->pinctrl)) {
> > + if (!IS_ERR_OR_NULL(i2c_imx->pinctrl)) {
>
> Sorry, there is a problem, please ignore it.
I don't think these conversions are appropriate for devm_pinctrl_get().
If one reads the code for devm_pinctrl_get() and pinctrl_get(), then
one finds that it will never return NULL.
So the tests for NULL do not serve any practical purpose than giving
coders a warm fuzzy feeling that they've tested for a NULL pointer.
Practically, they are of no use, so should be removed... thus making
the conversion to IS_ERR_OR_NULL() irrelevant.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
WARNING: multiple messages have this Message-ID (diff)
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Ruan Jinjie <ruanjinjie@huawei.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
Andi Shyti <andi.shyti@kernel.org>,
Fabio Estevam <festevam@gmail.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
linux-i2c@vger.kernel.org,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Codrin Ciubotariu <codrin.ciubotariu@microchip.com>,
Oleksij Rempel <linux@rempel-privat.de>,
Shawn Guo <shawnguo@kernel.org>,
linux-arm-kernel@lists.infradead.org,
NXP Linux Team <linux-imx@nxp.com>
Subject: Re: [PATCH -next] I2C: Use helper function IS_ERR_OR_NULL()
Date: Wed, 16 Aug 2023 11:08:03 +0100 [thread overview]
Message-ID: <ZNygA72nKogZvlG3@shell.armlinux.org.uk> (raw)
In-Reply-To: <50f61322-de65-1632-d404-7dcfe9a82744@huawei.com>
On Wed, Aug 16, 2023 at 05:48:34PM +0800, Ruan Jinjie wrote:
>
>
> On 2023/8/16 17:46, Ruan Jinjie wrote:
> > Use IS_ERR_OR_NULL() instead of open-coding it
> > to simplify the code.
> >
> > Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
> > ---
> > drivers/i2c/busses/i2c-at91-master.c | 2 +-
> > drivers/i2c/busses/i2c-imx.c | 2 +-
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/i2c/busses/i2c-at91-master.c b/drivers/i2c/busses/i2c-at91-master.c
> > index 94cff1cd527e..0e454c04a145 100644
> > --- a/drivers/i2c/busses/i2c-at91-master.c
> > +++ b/drivers/i2c/busses/i2c-at91-master.c
> > @@ -831,7 +831,7 @@ static int at91_init_twi_recovery_gpio(struct platform_device *pdev,
> > struct i2c_bus_recovery_info *rinfo = &dev->rinfo;
> >
> > rinfo->pinctrl = devm_pinctrl_get(&pdev->dev);
> > - if (!rinfo->pinctrl || IS_ERR(rinfo->pinctrl)) {
> > + if (IS_ERR_OR_NULL(rinfo->pinctrl)) {
> > dev_info(dev->dev, "can't get pinctrl, bus recovery not supported\n");
> > return PTR_ERR(rinfo->pinctrl);
> > }
> > diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> > index 10e89586ca72..8807c90df749 100644
> > --- a/drivers/i2c/busses/i2c-imx.c
> > +++ b/drivers/i2c/busses/i2c-imx.c
> > @@ -1388,7 +1388,7 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
> > struct i2c_bus_recovery_info *rinfo = &i2c_imx->rinfo;
> >
> > i2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev);
> > - if (!i2c_imx->pinctrl || IS_ERR(i2c_imx->pinctrl)) {
> > + if (!IS_ERR_OR_NULL(i2c_imx->pinctrl)) {
>
> Sorry, there is a problem, please ignore it.
I don't think these conversions are appropriate for devm_pinctrl_get().
If one reads the code for devm_pinctrl_get() and pinctrl_get(), then
one finds that it will never return NULL.
So the tests for NULL do not serve any practical purpose than giving
coders a warm fuzzy feeling that they've tested for a NULL pointer.
Practically, they are of no use, so should be removed... thus making
the conversion to IS_ERR_OR_NULL() irrelevant.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-08-16 10:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-16 9:46 [PATCH -next] I2C: Use helper function IS_ERR_OR_NULL() Ruan Jinjie
2023-08-16 9:46 ` Ruan Jinjie
2023-08-16 9:48 ` Ruan Jinjie
2023-08-16 9:48 ` Ruan Jinjie
2023-08-16 10:08 ` Russell King (Oracle) [this message]
2023-08-16 10:08 ` Russell King (Oracle)
2023-08-17 1:38 ` Ruan Jinjie
2023-08-17 1:38 ` Ruan Jinjie
2023-08-16 9:51 ` Yann Sionneau
2023-08-16 9:51 ` Yann Sionneau
2023-08-16 10:22 ` Russell King (Oracle)
2023-08-16 10:22 ` Russell King (Oracle)
2023-08-16 10:22 ` Russell King (Oracle)
2023-08-16 10:22 ` Russell King (Oracle)
2023-08-17 1:39 ` Ruan Jinjie
2023-08-17 1:39 ` Ruan Jinjie
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=ZNygA72nKogZvlG3@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=alexandre.belloni@bootlin.com \
--cc=andi.shyti@kernel.org \
--cc=claudiu.beznea@tuxon.dev \
--cc=codrin.ciubotariu@microchip.com \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux@rempel-privat.de \
--cc=nicolas.ferre@microchip.com \
--cc=ruanjinjie@huawei.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/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.