net: hns3: fix for getting auto-negotiation state in hclge_get_autoneg
authorFuyun Liang <liangfuyun1@huawei.com>
Fri, 22 Dec 2017 04:21:50 +0000 (12:21 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 27 Dec 2017 15:41:38 +0000 (10:41 -0500)
When phy exists, we use the value of phydev.autoneg to represent the
auto-negotiation state of hardware. Otherwise, we use the value of
mac.autoneg to represent it.

This patch fixes for getting a error value of auto-negotiation state in
hclge_get_autoneg().

Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index 046f4bb1767df58ebaef6f25b3c11f6c2a529a89..14e10548ab8c4f5e91a6a9025c8db26513f13da7 100644 (file)
@@ -2172,6 +2172,10 @@ static int hclge_get_autoneg(struct hnae3_handle *handle)
 {
        struct hclge_vport *vport = hclge_get_vport(handle);
        struct hclge_dev *hdev = vport->back;
+       struct phy_device *phydev = hdev->hw.mac.phydev;
+
+       if (phydev)
+               return phydev->autoneg;
 
        return hdev->hw.mac.autoneg;
 }