Message ID | 20240828122336.3697176-1-lihongbo22@huawei.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 4266563afbb1eb1735aa7063fe8ff6377991ae42 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next] net: hns: Use IS_ERR_OR_NULL() helper function | expand |
On 8/28/2024 5:23 AM, Hongbo Li wrote: > Use the IS_ERR_OR_NULL() helper instead of open-coding a > NULL and an error pointer checks to simplify the code and > improve readability. > > Signed-off-by: Hongbo Li <lihongbo22@huawei.com> > --- > drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c > index f75668c47935..53e0da0bfbed 100644 > --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c > +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c > @@ -734,7 +734,7 @@ 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)) > + if (IS_ERR_OR_NULL(phy)) > return -EIO; > This does collapse any error from get_phy_device into -EIO, when you should specifically check and return the PTR_ERR value. I'm not sure how useful that is, and feels like a separate cleanup. Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> > phy->irq = mdio->irq[addr];
Hello: This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <kuba@kernel.org>: On Wed, 28 Aug 2024 20:23:36 +0800 you wrote: > Use the IS_ERR_OR_NULL() helper instead of open-coding a > NULL and an error pointer checks to simplify the code and > improve readability. > > Signed-off-by: Hongbo Li <lihongbo22@huawei.com> > --- > drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Here is the summary with links: - [net-next] net: hns: Use IS_ERR_OR_NULL() helper function https://git.kernel.org/netdev/net-next/c/4266563afbb1 You are awesome, thank you!
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c index f75668c47935..53e0da0bfbed 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c @@ -734,7 +734,7 @@ 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)) + if (IS_ERR_OR_NULL(phy)) return -EIO; phy->irq = mdio->irq[addr];
Use the IS_ERR_OR_NULL() helper instead of open-coding a NULL and an error pointer checks to simplify the code and improve readability. Signed-off-by: Hongbo Li <lihongbo22@huawei.com> --- drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)