fixed_phy_register() returns not only -EIO or -ENODEV, but also
-EPROBE_DEFER, -EINVAL and -EBUSY. The Best practice is to return these
error codes with PTR_ERR().
Ruan Jinjie (3):
net: bgmac: Return PTR_ERR() for fixed_phy_register()
net: bcmgenet: Return PTR_ERR() for fixed_phy_register()
net: lan743x: Return PTR_ERR() for fixed_phy_register()
drivers/net/ethernet/broadcom/bgmac.c | 2 +-
drivers/net/ethernet/broadcom/genet/bcmmii.c | 2 +-
drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
--
2.34.1
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 <redacted>
---
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(-)
@@ -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;+returnPTR_ERR(phydev);}/* Make sure we initialize MoCA PHYs with a link down */
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 <redacted>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
v3:
- Split the return value check into another patch set.
- Update the commit title and message.
---
drivers/net/ethernet/broadcom/bgmac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
fixed_phy_register() returns -EPROBE_DEFER, -EINVAL and -EBUSY,
etc, in addition to -EIO. The Best practice is to return these
error codes with PTR_ERR().
Signed-off-by: Ruan Jinjie <redacted>
---
v3:
- Update the commit title and message.
---
drivers/net/ethernet/microchip/lan743x_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 <redacted>
---
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(-)
From: Simon Horman <horms@kernel.org> Date: 2023-08-19 17:06:20
On Fri, Aug 18, 2023 at 03:07:06PM +0800, Ruan Jinjie wrote:
quoted hunk
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 <redacted>
---
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(-)
@@ -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;+returnPTR_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
From: Simon Horman <horms@kernel.org> Date: 2023-08-19 17:10:59
On Sat, Aug 19, 2023 at 07:06:15PM +0200, Simon Horman wrote:
On Fri, Aug 18, 2023 at 03:07:06PM +0800, Ruan Jinjie wrote:
quoted
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 <redacted>
---
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(-)
@@ -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;+returnPTR_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.
Sorry for the noise.
I now see that fixed_phy_register() never returns NULL,
and that condition is being removed by another patchset [1].
I'm fine with this, other than that I suspect your two series
conflict with each other.
[1] https://lore.kernel.org/all/20230818051221.3634844-1-ruanjinjie@huawei.com/
On Sat, Aug 19, 2023 at 07:06:15PM +0200, Simon Horman wrote:
quoted
On Fri, Aug 18, 2023 at 03:07:06PM +0800, Ruan Jinjie wrote:
quoted
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 <redacted>
---
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(-)
@@ -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;+returnPTR_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.
Sorry for the noise.
I now see that fixed_phy_register() never returns NULL,
and that condition is being removed by another patchset [1].
I'm fine with this, other than that I suspect your two series
conflict with each other.
Thank you! I'll resend this patch to be consistent.