* [PATCH net-next 0/3] net: Fix return value check for get_phy_device()
@ 2023-08-17 7:39 Ruan Jinjie
2023-08-17 7:39 ` [PATCH net-next 1/3] net: mdio: " Ruan Jinjie
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Ruan Jinjie @ 2023-08-17 7:39 UTC (permalink / raw)
To: Shyam-sundar.S-k, davem, edumazet, kuba, pabeni, yisen.zhuang,
salil.mehta, iyappan, keyur, quan, andrew, hkallweit1, linux,
yankejian, netdev
Cc: ruanjinjie
The get_phy_device() function returns error pointers and never
returns NULL. Update the checks accordingly.
And get_phy_device() returns -EIO on bus access error and -ENOMEM
on kzalloc failure in addition to -ENODEV, return PTR_ERR is more
sensible.
Ruan Jinjie (3):
net: mdio: Fix return value check for get_phy_device()
amd-xgbe: Return proper error code for get_phy_device()
net: hisilicon: hns: Fix return value check for get_phy_device()
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 2 +-
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 4 ++--
drivers/net/mdio/mdio-xgene.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net-next 1/3] net: mdio: Fix return value check for get_phy_device()
2023-08-17 7:39 [PATCH net-next 0/3] net: Fix return value check for get_phy_device() Ruan Jinjie
@ 2023-08-17 7:39 ` Ruan Jinjie
2023-08-17 12:25 ` Andrew Lunn
2023-08-17 7:39 ` [PATCH net-next 2/3] amd-xgbe: Return proper error code " Ruan Jinjie
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Ruan Jinjie @ 2023-08-17 7:39 UTC (permalink / raw)
To: Shyam-sundar.S-k, davem, edumazet, kuba, pabeni, yisen.zhuang,
salil.mehta, iyappan, keyur, quan, andrew, hkallweit1, linux,
yankejian, netdev
Cc: ruanjinjie
The get_phy_device() function returns error pointers and never
returns NULL. Update the checks accordingly.
Fixes: 43b3cf6634a4 ("drivers: net: phy: xgene: Add MDIO driver")
Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
---
drivers/net/mdio/mdio-xgene.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/mdio/mdio-xgene.c b/drivers/net/mdio/mdio-xgene.c
index 683e8f8319ab..4e097ce2a7fd 100644
--- a/drivers/net/mdio/mdio-xgene.c
+++ b/drivers/net/mdio/mdio-xgene.c
@@ -265,7 +265,7 @@ struct phy_device *xgene_enet_phy_register(struct mii_bus *bus, int phy_addr)
struct phy_device *phy_dev;
phy_dev = get_phy_device(bus, phy_addr, false);
- if (!phy_dev || IS_ERR(phy_dev))
+ if (IS_ERR(phy_dev))
return NULL;
if (phy_device_register(phy_dev))
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next 2/3] amd-xgbe: Return proper error code for get_phy_device()
2023-08-17 7:39 [PATCH net-next 0/3] net: Fix return value check for get_phy_device() Ruan Jinjie
2023-08-17 7:39 ` [PATCH net-next 1/3] net: mdio: " Ruan Jinjie
@ 2023-08-17 7:39 ` Ruan Jinjie
2023-08-17 8:09 ` Shyam Sundar S K
2023-08-17 12:28 ` Andrew Lunn
2023-08-17 7:40 ` [PATCH net-next 3/3] net: hisilicon: hns: Fix return value check " Ruan Jinjie
2023-08-17 8:04 ` [PATCH net-next 0/3] net: " Leon Romanovsky
3 siblings, 2 replies; 10+ messages in thread
From: Ruan Jinjie @ 2023-08-17 7:39 UTC (permalink / raw)
To: Shyam-sundar.S-k, davem, edumazet, kuba, pabeni, yisen.zhuang,
salil.mehta, iyappan, keyur, quan, andrew, hkallweit1, linux,
yankejian, netdev
Cc: ruanjinjie
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(-)
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);
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next 3/3] net: hisilicon: hns: Fix return value check for get_phy_device()
2023-08-17 7:39 [PATCH net-next 0/3] net: Fix return value check for get_phy_device() Ruan Jinjie
2023-08-17 7:39 ` [PATCH net-next 1/3] net: mdio: " Ruan Jinjie
2023-08-17 7:39 ` [PATCH net-next 2/3] amd-xgbe: Return proper error code " Ruan Jinjie
@ 2023-08-17 7:40 ` Ruan Jinjie
2023-08-17 12:29 ` Andrew Lunn
2023-08-17 8:04 ` [PATCH net-next 0/3] net: " Leon Romanovsky
3 siblings, 1 reply; 10+ messages in thread
From: Ruan Jinjie @ 2023-08-17 7:40 UTC (permalink / raw)
To: Shyam-sundar.S-k, davem, edumazet, kuba, pabeni, yisen.zhuang,
salil.mehta, iyappan, keyur, quan, andrew, hkallweit1, linux,
yankejian, netdev
Cc: ruanjinjie
The get_phy_device() function returns error pointers and never
returns NULL. Update the checks accordingly.
Fixes: 1d1afa2ebf82 ("net: hns: register phy device in each mac initial sequence")
Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
---
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 928d934cb21a..13b5ee548744 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -705,8 +705,8 @@ hns_mac_register_phydev(struct mii_bus *mdio, struct hns_mac_cb *mac_cb,
return -ENODATA;
phy = get_phy_device(mdio, addr, is_c45);
- if (!phy || IS_ERR(phy))
- return -EIO;
+ if (IS_ERR(phy))
+ return PTR_ERR(phy);
phy->irq = mdio->irq[addr];
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 0/3] net: Fix return value check for get_phy_device()
2023-08-17 7:39 [PATCH net-next 0/3] net: Fix return value check for get_phy_device() Ruan Jinjie
` (2 preceding siblings ...)
2023-08-17 7:40 ` [PATCH net-next 3/3] net: hisilicon: hns: Fix return value check " Ruan Jinjie
@ 2023-08-17 8:04 ` Leon Romanovsky
3 siblings, 0 replies; 10+ messages in thread
From: Leon Romanovsky @ 2023-08-17 8:04 UTC (permalink / raw)
To: Ruan Jinjie
Cc: Shyam-sundar.S-k, davem, edumazet, kuba, pabeni, yisen.zhuang,
salil.mehta, iyappan, keyur, quan, andrew, hkallweit1, linux,
yankejian, netdev
On Thu, Aug 17, 2023 at 03:39:57PM +0800, Ruan Jinjie wrote:
> The get_phy_device() function returns error pointers and never
> returns NULL. Update the checks accordingly.
>
> And get_phy_device() returns -EIO on bus access error and -ENOMEM
> on kzalloc failure in addition to -ENODEV, return PTR_ERR is more
> sensible.
>
> Ruan Jinjie (3):
> net: mdio: Fix return value check for get_phy_device()
> amd-xgbe: Return proper error code for get_phy_device()
> net: hisilicon: hns: Fix return value check for get_phy_device()
>
> drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 2 +-
> drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 4 ++--
> drivers/net/mdio/mdio-xgene.c | 2 +-
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 2/3] amd-xgbe: Return proper error code for get_phy_device()
2023-08-17 7:39 ` [PATCH net-next 2/3] amd-xgbe: Return proper error code " Ruan Jinjie
@ 2023-08-17 8:09 ` Shyam Sundar S K
2023-08-17 12:28 ` Andrew Lunn
1 sibling, 0 replies; 10+ messages in thread
From: Shyam Sundar S K @ 2023-08-17 8:09 UTC (permalink / raw)
To: Ruan Jinjie, davem, edumazet, kuba, pabeni, yisen.zhuang,
salil.mehta, iyappan, keyur, quan, andrew, hkallweit1, linux,
yankejian, netdev, Rangoju, Raju
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);
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 1/3] net: mdio: Fix return value check for get_phy_device()
2023-08-17 7:39 ` [PATCH net-next 1/3] net: mdio: " Ruan Jinjie
@ 2023-08-17 12:25 ` Andrew Lunn
0 siblings, 0 replies; 10+ messages in thread
From: Andrew Lunn @ 2023-08-17 12:25 UTC (permalink / raw)
To: Ruan Jinjie
Cc: Shyam-sundar.S-k, davem, edumazet, kuba, pabeni, yisen.zhuang,
salil.mehta, iyappan, keyur, quan, hkallweit1, linux, yankejian,
netdev
On Thu, Aug 17, 2023 at 03:39:58PM +0800, Ruan Jinjie wrote:
> The get_phy_device() function returns error pointers and never
> returns NULL. Update the checks accordingly.
>
> Fixes: 43b3cf6634a4 ("drivers: net: phy: xgene: Add MDIO driver")
> Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 2/3] amd-xgbe: Return proper error code for get_phy_device()
2023-08-17 7:39 ` [PATCH net-next 2/3] amd-xgbe: Return proper error code " Ruan Jinjie
2023-08-17 8:09 ` Shyam Sundar S K
@ 2023-08-17 12:28 ` Andrew Lunn
2023-08-17 12:54 ` Ruan Jinjie
1 sibling, 1 reply; 10+ messages in thread
From: Andrew Lunn @ 2023-08-17 12:28 UTC (permalink / raw)
To: Ruan Jinjie
Cc: Shyam-sundar.S-k, davem, edumazet, kuba, pabeni, yisen.zhuang,
salil.mehta, iyappan, keyur, quan, hkallweit1, linux, yankejian,
netdev
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 3/3] net: hisilicon: hns: Fix return value check for get_phy_device()
2023-08-17 7:40 ` [PATCH net-next 3/3] net: hisilicon: hns: Fix return value check " Ruan Jinjie
@ 2023-08-17 12:29 ` Andrew Lunn
0 siblings, 0 replies; 10+ messages in thread
From: Andrew Lunn @ 2023-08-17 12:29 UTC (permalink / raw)
To: Ruan Jinjie
Cc: Shyam-sundar.S-k, davem, edumazet, kuba, pabeni, yisen.zhuang,
salil.mehta, iyappan, keyur, quan, hkallweit1, linux, yankejian,
netdev
On Thu, Aug 17, 2023 at 03:40:00PM +0800, Ruan Jinjie wrote:
> The get_phy_device() function returns error pointers and never
> returns NULL. Update the checks accordingly.
>
> Fixes: 1d1afa2ebf82 ("net: hns: register phy device in each mac initial sequence")
> Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next 2/3] amd-xgbe: Return proper error code for get_phy_device()
2023-08-17 12:28 ` Andrew Lunn
@ 2023-08-17 12:54 ` Ruan Jinjie
0 siblings, 0 replies; 10+ messages in thread
From: Ruan Jinjie @ 2023-08-17 12:54 UTC (permalink / raw)
To: Andrew Lunn
Cc: Shyam-sundar.S-k, davem, edumazet, kuba, pabeni, yisen.zhuang,
salil.mehta, iyappan, keyur, quan, hkallweit1, linux, yankejian,
netdev
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
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-08-17 12:54 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-17 7:39 [PATCH net-next 0/3] net: Fix return value check for get_phy_device() Ruan Jinjie
2023-08-17 7:39 ` [PATCH net-next 1/3] net: mdio: " Ruan Jinjie
2023-08-17 12:25 ` Andrew Lunn
2023-08-17 7:39 ` [PATCH net-next 2/3] amd-xgbe: Return proper error code " Ruan Jinjie
2023-08-17 8:09 ` Shyam Sundar S K
2023-08-17 12:28 ` Andrew Lunn
2023-08-17 12:54 ` Ruan Jinjie
2023-08-17 7:40 ` [PATCH net-next 3/3] net: hisilicon: hns: Fix return value check " Ruan Jinjie
2023-08-17 12:29 ` Andrew Lunn
2023-08-17 8:04 ` [PATCH net-next 0/3] net: " Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).