From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
This patch deletes the parameter phydev of hclge_set_phy_loopback() function for optimization, as it can be gotten by hdev->hw.mac.phydev.
The variable phydev should be checked whether null pointer before use.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Yonglong Liu liuyonglong@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index a92de09..bfad236 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -6733,11 +6733,14 @@ static int hclge_disable_phy_loopback(struct hclge_dev *hdev, return ret; }
-static int hclge_set_phy_loopback(struct hclge_dev *hdev, - struct phy_device *phydev, bool en) +static int hclge_set_phy_loopback(struct hclge_dev *hdev, bool en) { + struct phy_device *phydev = hdev->hw.mac.phydev; int ret;
+ if (!phydev) + return -ENOTSUPP; + if (en) ret = hclge_enable_phy_loopback(hdev, phydev); else @@ -6783,7 +6786,6 @@ static int hclge_set_loopback(struct hnae3_handle *handle, enum hnae3_loop loop_mode, bool en) { struct hclge_vport *vport = hclge_get_vport(handle); - struct phy_device *phydev = handle->netdev->phydev; struct hnae3_knic_private_info *kinfo; struct hclge_dev *hdev = vport->back; int i, ret; @@ -6811,8 +6813,7 @@ static int hclge_set_loopback(struct hnae3_handle *handle, ret = hclge_set_serdes_loopback(hdev, en, loop_mode); break; case HNAE3_LOOP_PHY: - if (phydev) - ret = hclge_set_phy_loopback(hdev, phydev, en); + ret = hclge_set_phy_loopback(hdev, en); break; default: ret = -ENOTSUPP;