netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Ruan Jinjie <ruanjinjie@huawei.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, lars.povlsen@microchip.com,
	Steen.Hegelund@microchip.com, daniel.machon@microchip.com,
	alexandre.torgue@foss.st.com, joabreu@synopsys.com,
	mcoquelin.stm32@gmail.com, horatiu.vultur@microchip.com,
	simon.horman@corigine.com, netdev@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH net-next 2/2] net: stmmac: Use helper function IS_ERR_OR_NULL()
Date: Thu, 17 Aug 2023 11:07:10 +0100	[thread overview]
Message-ID: <ZN3xTiaIGPzfmEjY@shell.armlinux.org.uk> (raw)
In-Reply-To: <20230817071941.346590-3-ruanjinjie@huawei.com>

On Thu, Aug 17, 2023 at 03:19:41PM +0800, 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/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 733b5e900817..fe2452a70d23 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -1165,7 +1165,7 @@ static int stmmac_init_phy(struct net_device *dev)
>  	/* Some DT bindings do not set-up the PHY handle. Let's try to
>  	 * manually parse it
>  	 */
> -	if (!phy_fwnode || IS_ERR(phy_fwnode)) {
> +	if (IS_ERR_OR_NULL(phy_fwnode)) {
>  		int addr = priv->plat->phy_addr;
>  		struct phy_device *phydev;

Up to the stmmac maintainers, but I have never been a fan of
"IS_ERR_OR_NULL" because it leads to programming errors such as
those I pointed out in your changes to I2C drivers. I would
much rather see IS_ERR_OR_NULL removed from the kernel entirely.
That is my personal opinion.

In this case, it doesn't matter because we're not returning the
phy_fwnode error, we're detecting it and taking some alternative
action - but given my inherent dislike of IS_ERR_OR_NULL, I
prefer the original.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2023-08-17 10:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17  7:19 [PATCH net-next 0/2] net: Use helper function IS_ERR_OR_NULL() Ruan Jinjie
2023-08-17  7:19 ` [PATCH net-next 1/2] net: microchip: sparx5: " Ruan Jinjie
2023-08-17  7:19 ` [PATCH net-next 2/2] net: stmmac: " Ruan Jinjie
2023-08-17 10:07   ` Russell King (Oracle) [this message]
2023-08-17  8:02 ` [PATCH net-next 0/2] net: " Leon Romanovsky
2023-08-17  9:50   ` 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=ZN3xTiaIGPzfmEjY@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=Steen.Hegelund@microchip.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=daniel.machon@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=joabreu@synopsys.com \
    --cc=kuba@kernel.org \
    --cc=lars.povlsen@microchip.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ruanjinjie@huawei.com \
    --cc=simon.horman@corigine.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 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).