Message ID | 20230817074000.355564-3-ruanjinjie@huawei.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: Fix return value check for get_phy_device() | expand |
On 8/17/2023 1:09 PM, Ruan Jinjie wrote: > get_phy_device() returns -EIO on bus access error and -ENOMEM > on kzalloc failure in addition to -ENODEV, just return -ENODEV is not > sensible, use PTR_ERR(phydev) to fix the issue. > > Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> Looks good to me. Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Thanks, Shyam > --- > drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c > index 6a716337f48b..2f0a014ffc72 100644 > --- a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c > +++ b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c > @@ -1090,7 +1090,7 @@ static int xgbe_phy_find_phy_device(struct xgbe_prv_data *pdata) > (phy_data->phydev_mode == XGBE_MDIO_MODE_CL45)); > if (IS_ERR(phydev)) { > netdev_err(pdata->netdev, "get_phy_device failed\n"); > - return -ENODEV; > + return PTR_ERR(phydev); > } > netif_dbg(pdata, drv, pdata->netdev, "external PHY id is %#010x\n", > phydev->phy_id); >
On Thu, Aug 17, 2023 at 03:39:59PM +0800, Ruan Jinjie wrote: > get_phy_device() returns -EIO on bus access error and -ENOMEM > on kzalloc failure in addition to -ENODEV, just return -ENODEV is not > sensible, use PTR_ERR(phydev) to fix the issue. Rather than say 'not sensible', it would be better to say 'Best practice is to return these error codes'. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Andrew --- pw-bot: cr
On 2023/8/17 20:28, Andrew Lunn wrote: > On Thu, Aug 17, 2023 at 03:39:59PM +0800, Ruan Jinjie wrote: >> get_phy_device() returns -EIO on bus access error and -ENOMEM >> on kzalloc failure in addition to -ENODEV, just return -ENODEV is not >> sensible, use PTR_ERR(phydev) to fix the issue. > > Rather than say 'not sensible', it would be better to say 'Best > practice is to return these error codes'. Thank you! I'll watch the wording next time. > > Reviewed-by: Andrew Lunn <andrew@lunn.ch> > > > Andrew > > --- > pw-bot: cr
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c index 6a716337f48b..2f0a014ffc72 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c @@ -1090,7 +1090,7 @@ static int xgbe_phy_find_phy_device(struct xgbe_prv_data *pdata) (phy_data->phydev_mode == XGBE_MDIO_MODE_CL45)); if (IS_ERR(phydev)) { netdev_err(pdata->netdev, "get_phy_device failed\n"); - return -ENODEV; + return PTR_ERR(phydev); } netif_dbg(pdata, drv, pdata->netdev, "external PHY id is %#010x\n", phydev->phy_id);
get_phy_device() returns -EIO on bus access error and -ENOMEM on kzalloc failure in addition to -ENODEV, just return -ENODEV is not sensible, use PTR_ERR(phydev) to fix the issue. Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com> --- drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)