[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZN3xTiaIGPzfmEjY@shell.armlinux.org.uk>
Date: Thu, 17 Aug 2023 11:07:10 +0100
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Ruan Jinjie <ruanjinjie@...wei.com>
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, lars.povlsen@...rochip.com,
Steen.Hegelund@...rochip.com, daniel.machon@...rochip.com,
alexandre.torgue@...s.st.com, joabreu@...opsys.com,
mcoquelin.stm32@...il.com, horatiu.vultur@...rochip.com,
simon.horman@...igine.com, netdev@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-stm32@...md-mailman.stormreply.com
Subject: Re: [PATCH net-next 2/2] net: stmmac: Use helper function
IS_ERR_OR_NULL()
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@...wei.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!
Powered by blists - more mailing lists