Commit 60df7e91 authored by Huazhong Tan's avatar Huazhong Tan Committed by David S. Miller

net: hns3: cleanup some coding style issue

This patch removes some unnecessary return value assignments,
some duplicated printing in the caller, refines the judgment
of 0 and uses le16_to_cpu to replace __le16_to_cpu.
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 322cb97c
...@@ -2094,10 +2094,8 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -2094,10 +2094,8 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
int ret; int ret;
ae_dev = devm_kzalloc(&pdev->dev, sizeof(*ae_dev), GFP_KERNEL); ae_dev = devm_kzalloc(&pdev->dev, sizeof(*ae_dev), GFP_KERNEL);
if (!ae_dev) { if (!ae_dev)
ret = -ENOMEM; return -ENOMEM;
return ret;
}
ae_dev->pdev = pdev; ae_dev->pdev = pdev;
ae_dev->flag = ent->driver_data; ae_dev->flag = ent->driver_data;
......
...@@ -1898,10 +1898,8 @@ static int hclge_handle_all_hw_msix_error(struct hclge_dev *hdev, ...@@ -1898,10 +1898,8 @@ static int hclge_handle_all_hw_msix_error(struct hclge_dev *hdev,
bd_num = max_t(u32, mpf_bd_num, pf_bd_num); bd_num = max_t(u32, mpf_bd_num, pf_bd_num);
desc = kcalloc(bd_num, sizeof(struct hclge_desc), GFP_KERNEL); desc = kcalloc(bd_num, sizeof(struct hclge_desc), GFP_KERNEL);
if (!desc) { if (!desc)
ret = -ENOMEM; return -ENOMEM;
goto out;
}
ret = hclge_handle_mpf_msix_error(hdev, desc, mpf_bd_num, ret = hclge_handle_mpf_msix_error(hdev, desc, mpf_bd_num,
reset_requests); reset_requests);
......
...@@ -862,9 +862,7 @@ static int hclge_query_function_status(struct hclge_dev *hdev) ...@@ -862,9 +862,7 @@ static int hclge_query_function_status(struct hclge_dev *hdev)
usleep_range(1000, 2000); usleep_range(1000, 2000);
} while (timeout++ < HCLGE_QUERY_MAX_CNT); } while (timeout++ < HCLGE_QUERY_MAX_CNT);
ret = hclge_parse_func_status(hdev, req); return hclge_parse_func_status(hdev, req);
return ret;
} }
static int hclge_query_pf_resource(struct hclge_dev *hdev) static int hclge_query_pf_resource(struct hclge_dev *hdev)
...@@ -882,12 +880,12 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev) ...@@ -882,12 +880,12 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev)
} }
req = (struct hclge_pf_res_cmd *)desc.data; req = (struct hclge_pf_res_cmd *)desc.data;
hdev->num_tqps = __le16_to_cpu(req->tqp_num); hdev->num_tqps = le16_to_cpu(req->tqp_num);
hdev->pkt_buf_size = __le16_to_cpu(req->buf_size) << HCLGE_BUF_UNIT_S; hdev->pkt_buf_size = le16_to_cpu(req->buf_size) << HCLGE_BUF_UNIT_S;
if (req->tx_buf_size) if (req->tx_buf_size)
hdev->tx_buf_size = hdev->tx_buf_size =
__le16_to_cpu(req->tx_buf_size) << HCLGE_BUF_UNIT_S; le16_to_cpu(req->tx_buf_size) << HCLGE_BUF_UNIT_S;
else else
hdev->tx_buf_size = HCLGE_DEFAULT_TX_BUF; hdev->tx_buf_size = HCLGE_DEFAULT_TX_BUF;
...@@ -895,7 +893,7 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev) ...@@ -895,7 +893,7 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev)
if (req->dv_buf_size) if (req->dv_buf_size)
hdev->dv_buf_size = hdev->dv_buf_size =
__le16_to_cpu(req->dv_buf_size) << HCLGE_BUF_UNIT_S; le16_to_cpu(req->dv_buf_size) << HCLGE_BUF_UNIT_S;
else else
hdev->dv_buf_size = HCLGE_DEFAULT_DV; hdev->dv_buf_size = HCLGE_DEFAULT_DV;
...@@ -903,10 +901,10 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev) ...@@ -903,10 +901,10 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev)
if (hnae3_dev_roce_supported(hdev)) { if (hnae3_dev_roce_supported(hdev)) {
hdev->roce_base_msix_offset = hdev->roce_base_msix_offset =
hnae3_get_field(__le16_to_cpu(req->msixcap_localid_ba_rocee), hnae3_get_field(le16_to_cpu(req->msixcap_localid_ba_rocee),
HCLGE_MSIX_OFT_ROCEE_M, HCLGE_MSIX_OFT_ROCEE_S); HCLGE_MSIX_OFT_ROCEE_M, HCLGE_MSIX_OFT_ROCEE_S);
hdev->num_roce_msi = hdev->num_roce_msi =
hnae3_get_field(__le16_to_cpu(req->pf_intr_vector_number), hnae3_get_field(le16_to_cpu(req->pf_intr_vector_number),
HCLGE_PF_VEC_NUM_M, HCLGE_PF_VEC_NUM_S); HCLGE_PF_VEC_NUM_M, HCLGE_PF_VEC_NUM_S);
/* nic's msix numbers is always equals to the roce's. */ /* nic's msix numbers is always equals to the roce's. */
...@@ -919,7 +917,7 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev) ...@@ -919,7 +917,7 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev)
hdev->roce_base_msix_offset; hdev->roce_base_msix_offset;
} else { } else {
hdev->num_msi = hdev->num_msi =
hnae3_get_field(__le16_to_cpu(req->pf_intr_vector_number), hnae3_get_field(le16_to_cpu(req->pf_intr_vector_number),
HCLGE_PF_VEC_NUM_M, HCLGE_PF_VEC_NUM_S); HCLGE_PF_VEC_NUM_M, HCLGE_PF_VEC_NUM_S);
hdev->num_nic_msi = hdev->num_msi; hdev->num_nic_msi = hdev->num_msi;
...@@ -1333,11 +1331,7 @@ static int hclge_get_cap(struct hclge_dev *hdev) ...@@ -1333,11 +1331,7 @@ static int hclge_get_cap(struct hclge_dev *hdev)
} }
/* get pf resource */ /* get pf resource */
ret = hclge_query_pf_resource(hdev); return hclge_query_pf_resource(hdev);
if (ret)
dev_err(&hdev->pdev->dev, "query pf resource error %d.\n", ret);
return ret;
} }
static void hclge_init_kdump_kernel_config(struct hclge_dev *hdev) static void hclge_init_kdump_kernel_config(struct hclge_dev *hdev)
...@@ -2621,30 +2615,21 @@ static int hclge_mac_init(struct hclge_dev *hdev) ...@@ -2621,30 +2615,21 @@ static int hclge_mac_init(struct hclge_dev *hdev)
hdev->hw.mac.duplex = HCLGE_MAC_FULL; hdev->hw.mac.duplex = HCLGE_MAC_FULL;
ret = hclge_cfg_mac_speed_dup_hw(hdev, hdev->hw.mac.speed, ret = hclge_cfg_mac_speed_dup_hw(hdev, hdev->hw.mac.speed,
hdev->hw.mac.duplex); hdev->hw.mac.duplex);
if (ret) { if (ret)
dev_err(&hdev->pdev->dev,
"Config mac speed dup fail ret=%d\n", ret);
return ret; return ret;
}
if (hdev->hw.mac.support_autoneg) { if (hdev->hw.mac.support_autoneg) {
ret = hclge_set_autoneg_en(hdev, hdev->hw.mac.autoneg); ret = hclge_set_autoneg_en(hdev, hdev->hw.mac.autoneg);
if (ret) { if (ret)
dev_err(&hdev->pdev->dev,
"Config mac autoneg fail ret=%d\n", ret);
return ret; return ret;
}
} }
mac->link = 0; mac->link = 0;
if (mac->user_fec_mode & BIT(HNAE3_FEC_USER_DEF)) { if (mac->user_fec_mode & BIT(HNAE3_FEC_USER_DEF)) {
ret = hclge_set_fec_hw(hdev, mac->user_fec_mode); ret = hclge_set_fec_hw(hdev, mac->user_fec_mode);
if (ret) { if (ret)
dev_err(&hdev->pdev->dev,
"Fec mode init fail, ret = %d\n", ret);
return ret; return ret;
}
} }
ret = hclge_set_mac_mtu(hdev, hdev->mps); ret = hclge_set_mac_mtu(hdev, hdev->mps);
...@@ -2916,7 +2901,7 @@ static int hclge_get_status(struct hnae3_handle *handle) ...@@ -2916,7 +2901,7 @@ static int hclge_get_status(struct hnae3_handle *handle)
static struct hclge_vport *hclge_get_vf_vport(struct hclge_dev *hdev, int vf) static struct hclge_vport *hclge_get_vf_vport(struct hclge_dev *hdev, int vf)
{ {
if (pci_num_vf(hdev->pdev) == 0) { if (!pci_num_vf(hdev->pdev)) {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"SRIOV is disabled, can not get vport(%d) info.\n", vf); "SRIOV is disabled, can not get vport(%d) info.\n", vf);
return NULL; return NULL;
...@@ -6584,7 +6569,7 @@ static int hclge_set_serdes_loopback(struct hclge_dev *hdev, bool en, ...@@ -6584,7 +6569,7 @@ static int hclge_set_serdes_loopback(struct hclge_dev *hdev, bool en,
hclge_cfg_mac_mode(hdev, en); hclge_cfg_mac_mode(hdev, en);
ret = hclge_mac_phy_link_status_wait(hdev, en, FALSE); ret = hclge_mac_phy_link_status_wait(hdev, en, false);
if (ret) if (ret)
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"serdes loopback config mac mode timeout\n"); "serdes loopback config mac mode timeout\n");
...@@ -6642,7 +6627,7 @@ static int hclge_set_phy_loopback(struct hclge_dev *hdev, bool en) ...@@ -6642,7 +6627,7 @@ static int hclge_set_phy_loopback(struct hclge_dev *hdev, bool en)
hclge_cfg_mac_mode(hdev, en); hclge_cfg_mac_mode(hdev, en);
ret = hclge_mac_phy_link_status_wait(hdev, en, TRUE); ret = hclge_mac_phy_link_status_wait(hdev, en, true);
if (ret) if (ret)
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"phy loopback config mac mode timeout\n"); "phy loopback config mac mode timeout\n");
...@@ -9394,17 +9379,13 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) ...@@ -9394,17 +9379,13 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
sema_init(&hdev->reset_sem, 1); sema_init(&hdev->reset_sem, 1);
ret = hclge_pci_init(hdev); ret = hclge_pci_init(hdev);
if (ret) { if (ret)
dev_err(&pdev->dev, "PCI init failed\n");
goto out; goto out;
}
/* Firmware command queue initialize */ /* Firmware command queue initialize */
ret = hclge_cmd_queue_init(hdev); ret = hclge_cmd_queue_init(hdev);
if (ret) { if (ret)
dev_err(&pdev->dev, "Cmd queue init failed, ret = %d.\n", ret);
goto err_pci_uninit; goto err_pci_uninit;
}
/* Firmware command initialize */ /* Firmware command initialize */
ret = hclge_cmd_init(hdev); ret = hclge_cmd_init(hdev);
...@@ -9412,11 +9393,8 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) ...@@ -9412,11 +9393,8 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
goto err_cmd_uninit; goto err_cmd_uninit;
ret = hclge_get_cap(hdev); ret = hclge_get_cap(hdev);
if (ret) { if (ret)
dev_err(&pdev->dev, "get hw capability error, ret = %d.\n",
ret);
goto err_cmd_uninit; goto err_cmd_uninit;
}
ret = hclge_configure(hdev); ret = hclge_configure(hdev);
if (ret) { if (ret) {
...@@ -9431,12 +9409,8 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) ...@@ -9431,12 +9409,8 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
} }
ret = hclge_misc_irq_init(hdev); ret = hclge_misc_irq_init(hdev);
if (ret) { if (ret)
dev_err(&pdev->dev,
"Misc IRQ(vector0) init error, ret = %d.\n",
ret);
goto err_msi_uninit; goto err_msi_uninit;
}
ret = hclge_alloc_tqps(hdev); ret = hclge_alloc_tqps(hdev);
if (ret) { if (ret) {
...@@ -9445,31 +9419,22 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) ...@@ -9445,31 +9419,22 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
} }
ret = hclge_alloc_vport(hdev); ret = hclge_alloc_vport(hdev);
if (ret) { if (ret)
dev_err(&pdev->dev, "Allocate vport error, ret = %d.\n", ret);
goto err_msi_irq_uninit; goto err_msi_irq_uninit;
}
ret = hclge_map_tqp(hdev); ret = hclge_map_tqp(hdev);
if (ret) { if (ret)
dev_err(&pdev->dev, "Map tqp error, ret = %d.\n", ret);
goto err_msi_irq_uninit; goto err_msi_irq_uninit;
}
if (hdev->hw.mac.media_type == HNAE3_MEDIA_TYPE_COPPER) { if (hdev->hw.mac.media_type == HNAE3_MEDIA_TYPE_COPPER) {
ret = hclge_mac_mdio_config(hdev); ret = hclge_mac_mdio_config(hdev);
if (ret) { if (ret)
dev_err(&hdev->pdev->dev,
"mdio config fail ret=%d\n", ret);
goto err_msi_irq_uninit; goto err_msi_irq_uninit;
}
} }
ret = hclge_init_umv_space(hdev); ret = hclge_init_umv_space(hdev);
if (ret) { if (ret)
dev_err(&pdev->dev, "umv space init error, ret=%d.\n", ret);
goto err_mdiobus_unreg; goto err_mdiobus_unreg;
}
ret = hclge_mac_init(hdev); ret = hclge_mac_init(hdev);
if (ret) { if (ret) {
......
...@@ -2597,11 +2597,11 @@ static int hclgevf_query_vf_resource(struct hclgevf_dev *hdev) ...@@ -2597,11 +2597,11 @@ static int hclgevf_query_vf_resource(struct hclgevf_dev *hdev)
if (hnae3_dev_roce_supported(hdev)) { if (hnae3_dev_roce_supported(hdev)) {
hdev->roce_base_msix_offset = hdev->roce_base_msix_offset =
hnae3_get_field(__le16_to_cpu(req->msixcap_localid_ba_rocee), hnae3_get_field(le16_to_cpu(req->msixcap_localid_ba_rocee),
HCLGEVF_MSIX_OFT_ROCEE_M, HCLGEVF_MSIX_OFT_ROCEE_M,
HCLGEVF_MSIX_OFT_ROCEE_S); HCLGEVF_MSIX_OFT_ROCEE_S);
hdev->num_roce_msix = hdev->num_roce_msix =
hnae3_get_field(__le16_to_cpu(req->vf_intr_vector_number), hnae3_get_field(le16_to_cpu(req->vf_intr_vector_number),
HCLGEVF_VEC_NUM_M, HCLGEVF_VEC_NUM_S); HCLGEVF_VEC_NUM_M, HCLGEVF_VEC_NUM_S);
/* nic's msix numbers is always equals to the roce's. */ /* nic's msix numbers is always equals to the roce's. */
...@@ -2614,7 +2614,7 @@ static int hclgevf_query_vf_resource(struct hclgevf_dev *hdev) ...@@ -2614,7 +2614,7 @@ static int hclgevf_query_vf_resource(struct hclgevf_dev *hdev)
hdev->roce_base_msix_offset; hdev->roce_base_msix_offset;
} else { } else {
hdev->num_msi = hdev->num_msi =
hnae3_get_field(__le16_to_cpu(req->vf_intr_vector_number), hnae3_get_field(le16_to_cpu(req->vf_intr_vector_number),
HCLGEVF_VEC_NUM_M, HCLGEVF_VEC_NUM_S); HCLGEVF_VEC_NUM_M, HCLGEVF_VEC_NUM_S);
hdev->num_nic_msix = hdev->num_msi; hdev->num_nic_msix = hdev->num_msi;
...@@ -2711,16 +2711,12 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev) ...@@ -2711,16 +2711,12 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
int ret; int ret;
ret = hclgevf_pci_init(hdev); ret = hclgevf_pci_init(hdev);
if (ret) { if (ret)
dev_err(&pdev->dev, "PCI initialization failed\n");
return ret; return ret;
}
ret = hclgevf_cmd_queue_init(hdev); ret = hclgevf_cmd_queue_init(hdev);
if (ret) { if (ret)
dev_err(&pdev->dev, "Cmd queue init failed: %d\n", ret);
goto err_cmd_queue_init; goto err_cmd_queue_init;
}
ret = hclgevf_cmd_init(hdev); ret = hclgevf_cmd_init(hdev);
if (ret) if (ret)
...@@ -2728,11 +2724,8 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev) ...@@ -2728,11 +2724,8 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
/* Get vf resource */ /* Get vf resource */
ret = hclgevf_query_vf_resource(hdev); ret = hclgevf_query_vf_resource(hdev);
if (ret) { if (ret)
dev_err(&hdev->pdev->dev,
"Query vf status error, ret = %d.\n", ret);
goto err_cmd_init; goto err_cmd_init;
}
ret = hclgevf_init_msi(hdev); ret = hclgevf_init_msi(hdev);
if (ret) { if (ret) {
...@@ -2745,11 +2738,8 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev) ...@@ -2745,11 +2738,8 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
hdev->reset_type = HNAE3_NONE_RESET; hdev->reset_type = HNAE3_NONE_RESET;
ret = hclgevf_misc_irq_init(hdev); ret = hclgevf_misc_irq_init(hdev);
if (ret) { if (ret)
dev_err(&pdev->dev, "failed(%d) to init Misc IRQ(vector0)\n",
ret);
goto err_misc_irq_init; goto err_misc_irq_init;
}
set_bit(HCLGEVF_STATE_IRQ_INITED, &hdev->state); set_bit(HCLGEVF_STATE_IRQ_INITED, &hdev->state);
...@@ -2766,10 +2756,8 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev) ...@@ -2766,10 +2756,8 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
} }
ret = hclgevf_set_handle_info(hdev); ret = hclgevf_set_handle_info(hdev);
if (ret) { if (ret)
dev_err(&pdev->dev, "failed(%d) to set handle info\n", ret);
goto err_config; goto err_config;
}
ret = hclgevf_config_gro(hdev, true); ret = hclgevf_config_gro(hdev, true);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment