net: hns3: fix return value error of hclge_get_mac_vlan_cmd_status()
authorJian Shen <shenjian15@huawei.com>
Sat, 10 Mar 2018 03:29:31 +0000 (11:29 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Mar 2018 02:53:32 +0000 (22:53 -0400)
Error code -EIO was used to indicate mutilple errors in function
hclge_get_mac_vlan_cmd_status().This patch fixes it by using
error code depending on the error type.

For no space error, return -ENOSPC.
For entry not found, return -ENOENT.
For command send fail, return -EIO.
For invalid op code, return -EINVAL.

Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
Signed-off-by: Jian Shen <shenjian15@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 ba84281a36bb4d85902f34345be1349652b156ca..47dcc9856d4cc99f8d4ee32c47c124c1414d2833 100644 (file)
@@ -3779,11 +3779,11 @@ static int hclge_get_mac_vlan_cmd_status(struct hclge_vport *vport,
                if ((!resp_code) || (resp_code == 1)) {
                        return_status = 0;
                } else if (resp_code == 2) {
-                       return_status = -EIO;
+                       return_status = -ENOSPC;
                        dev_err(&hdev->pdev->dev,
                                "add mac addr failed for uc_overflow.\n");
                } else if (resp_code == 3) {
-                       return_status = -EIO;
+                       return_status = -ENOSPC;
                        dev_err(&hdev->pdev->dev,
                                "add mac addr failed for mc_overflow.\n");
                } else {
@@ -3795,7 +3795,7 @@ static int hclge_get_mac_vlan_cmd_status(struct hclge_vport *vport,
                if (!resp_code) {
                        return_status = 0;
                } else if (resp_code == 1) {
-                       return_status = -EIO;
+                       return_status = -ENOENT;
                        dev_dbg(&hdev->pdev->dev,
                                "remove mac addr failed for miss.\n");
                } else {
@@ -3807,7 +3807,7 @@ static int hclge_get_mac_vlan_cmd_status(struct hclge_vport *vport,
                if (!resp_code) {
                        return_status = 0;
                } else if (resp_code == 1) {
-                       return_status = -EIO;
+                       return_status = -ENOENT;
                        dev_dbg(&hdev->pdev->dev,
                                "lookup mac addr failed for miss.\n");
                } else {
@@ -3816,7 +3816,7 @@ static int hclge_get_mac_vlan_cmd_status(struct hclge_vport *vport,
                                resp_code);
                }
        } else {
-               return_status = -EIO;
+               return_status = -EINVAL;
                dev_err(&hdev->pdev->dev,
                        "unknown opcode for get_mac_vlan_cmd_status,opcode=%d.\n",
                        op);