[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZOD2hylmo1/HgaYO@vergenet.net>
Date: Sat, 19 Aug 2023 19:06:15 +0200
From: Simon Horman <horms@...nel.org>
To: Ruan Jinjie <ruanjinjie@...wei.com>
Cc: rafal@...ecki.pl, bcm-kernel-feedback-list@...adcom.com,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, opendmb@...il.com, florian.fainelli@...adcom.com,
bryan.whitehead@...rochip.com, UNGLinuxDriver@...rochip.com,
netdev@...r.kernel.org
Subject: Re: [PATCH net-next v3 2/3] net: bcmgenet: Return PTR_ERR() for
fixed_phy_register()
On Fri, Aug 18, 2023 at 03:07:06PM +0800, Ruan Jinjie wrote:
> fixed_phy_register() returns -EPROBE_DEFER, -EINVAL and -EBUSY,
> etc, in addition to -ENODEV. The Best practice is to return these
> error codes with PTR_ERR().
>
> Signed-off-by: Ruan Jinjie <ruanjinjie@...wei.com>
> ---
> v3:
> - Split the return value check into another patch set.
> - Update the commit title and message.
> ---
> drivers/net/ethernet/broadcom/genet/bcmmii.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
> index 0092e46c46f8..4012a141a229 100644
> --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
> +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
> @@ -619,7 +619,7 @@ static int bcmgenet_mii_pd_init(struct bcmgenet_priv *priv)
> phydev = fixed_phy_register(PHY_POLL, &fphy_status, NULL);
> if (!phydev || IS_ERR(phydev)) {
> dev_err(kdev, "failed to register fixed PHY device\n");
> - return -ENODEV;
> + return PTR_ERR(phydev);
Hi Ruan,
thanks for your patch.
Perhaps I am missing something, but this doesn't seem right to me.
In the case where phydev is NULL will return 0.
But bcmgenet_mii_pd_init() also returns 0 on success.
Perhaps this is better?
if (!phydev || IS_ERR(phydev)) {
dev_err(kdev, "failed to register fixed PHY device\n");
return physdev ? PTR_ERR(phydev) : -ENODEV;
}
I have a similar concern for patch 1/3 of this series.
Patch 3/3 seems fine in this regard.
> }
>
> /* Make sure we initialize MoCA PHYs with a link down */
> --
> 2.34.1
>
>
Powered by blists - more mailing lists