diff mbox series

[net-next,2/3] amd-xgbe: Return proper error code for get_phy_device()

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

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1330 this patch: 1330
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 1353 this patch: 1353
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1353 this patch: 1353
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jinjie Ruan Aug. 17, 2023, 7:39 a.m. UTC
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(-)

Comments

Shyam Sundar S K Aug. 17, 2023, 8:09 a.m. UTC | #1
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);
>
Andrew Lunn Aug. 17, 2023, 12:28 p.m. UTC | #2
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
Jinjie Ruan Aug. 17, 2023, 12:54 p.m. UTC | #3
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 mbox series

Patch

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);