[1/9] net/hns3: simplify process of some return values
diff mbox series

Message ID 20200410110930.15717-2-huwei013@chinasoftinc.com
State Accepted, archived
Delegated to: Ferruh Yigit
Headers show
Series
  • misc updates for hns3 PMD driver
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Wei Hu (Xavier) April 10, 2020, 11:09 a.m. UTC
From: Lijun Ou <oulijun@huawei.com>

Currently, the return value processing of some functions can be combined
and the result is that some codes can be optimized.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
 drivers/net/hns3/hns3_dcb.c       | 28 +++++++++-------------------
 drivers/net/hns3/hns3_ethdev.c    | 27 ++++++++-------------------
 drivers/net/hns3/hns3_ethdev_vf.c | 18 ++++++------------
 3 files changed, 23 insertions(+), 50 deletions(-)

Patch
diff mbox series

diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c
index 8688de2a7..3fde222dc 100644
--- a/drivers/net/hns3/hns3_dcb.c
+++ b/drivers/net/hns3/hns3_dcb.c
@@ -749,12 +749,10 @@  hns3_dcb_schd_mode_cfg(struct hns3_hw *hw)
 	}
 
 	ret = hns3_dcb_lvl34_schd_mode_cfg(hw);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "config lvl34_schd_mode failed: %d", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -845,12 +843,10 @@  hns3_dcb_dwrr_cfg(struct hns3_hw *hw)
 	}
 
 	ret = hns3_dcb_pri_dwrr_cfg(hw);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "config pri_dwrr failed: %d", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -932,12 +928,10 @@  hns3_pri_q_qs_cfg(struct hns3_hw *hw)
 
 	/* Cfg q -> qs mapping */
 	ret = hns3_q_to_qs_map(hw);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "nq_to_qs mapping fail: %d", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -1552,12 +1546,10 @@  hns3_update_queue_map_configure(struct hns3_adapter *hns)
 
 	hns3_dcb_update_tc_queue_mapping(hw, nb_rx_q, nb_tx_q);
 	ret = hns3_q_to_qs_map(hw);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "failed to map nq to qs! ret = %d", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 int
@@ -1569,10 +1561,8 @@  hns3_dcb_cfg_update(struct hns3_adapter *hns)
 
 	if ((uint32_t)mq_mode & ETH_MQ_RX_DCB_FLAG) {
 		ret = hns3_dcb_configure(hns);
-		if (ret) {
+		if (ret)
 			hns3_err(hw, "Failed to config dcb: %d", ret);
-			return ret;
-		}
 	} else {
 		/*
 		 * Update queue map without PFC configuration,
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index 215e2b2c6..e55e46e38 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -312,11 +312,9 @@  hns3_restore_vlan_table(struct hns3_adapter *hns)
 	uint16_t vlan_id;
 	int ret = 0;
 
-	if (pf->port_base_vlan_cfg.state == HNS3_PORT_BASE_VLAN_ENABLE) {
-		ret = hns3_vlan_pvid_configure(hns, pf->port_base_vlan_cfg.pvid,
-					       1);
-		return ret;
-	}
+	if (pf->port_base_vlan_cfg.state == HNS3_PORT_BASE_VLAN_ENABLE)
+		return hns3_vlan_pvid_configure(hns,
+						pf->port_base_vlan_cfg.pvid, 1);
 
 	LIST_FOREACH(vlan_entry, &pf->vlan_list, next) {
 		if (vlan_entry->hd_tbl_status) {
@@ -2238,12 +2236,10 @@  hns3_config_mtu(struct hns3_hw *hw, uint16_t mps)
 	}
 
 	ret = hns3_buffer_alloc(hw);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "Failed to allocate buffer, ret = %d", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -2725,12 +2721,10 @@  hns3_get_configuration(struct hns3_hw *hw)
 	}
 
 	ret = hns3_get_board_configuration(hw);
-	if (ret) {
+	if (ret)
 		PMD_INIT_LOG(ERR, "Failed to get board configuration: %d", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -3664,7 +3658,6 @@  hns3_set_promisc_mode(struct hns3_hw *hw, bool en_uc_pmc, bool en_mc_pmc)
 	struct hns3_promisc_param param;
 	bool en_bc_pmc = true;
 	uint8_t vf_id;
-	int ret;
 
 	/*
 	 * In current version VF is not supported when PF is driven by DPDK
@@ -3674,11 +3667,7 @@  hns3_set_promisc_mode(struct hns3_hw *hw, bool en_uc_pmc, bool en_mc_pmc)
 	vf_id = 0;
 
 	hns3_promisc_param_init(&param, en_uc_pmc, en_mc_pmc, en_bc_pmc, vf_id);
-	ret = hns3_cmd_set_promisc_mode(hw, &param);
-	if (ret)
-		return ret;
-
-	return 0;
+	return hns3_cmd_set_promisc_mode(hw, &param);
 }
 
 static int
diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c
index 8be743d19..a1286a71e 100644
--- a/drivers/net/hns3/hns3_ethdev_vf.c
+++ b/drivers/net/hns3/hns3_ethdev_vf.c
@@ -283,10 +283,9 @@  hns3vf_add_mc_mac_addr(struct hns3_adapter *hns,
 				      mac_addr);
 		hns3_err(hw, "Failed to add mc mac addr(%s) for vf: %d",
 			 mac_str, ret);
-		return ret;
 	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -306,10 +305,9 @@  hns3vf_remove_mc_mac_addr(struct hns3_adapter *hns,
 				      mac_addr);
 		hns3_err(hw, "Failed to remove mc mac addr(%s) for vf: %d",
 			 mac_str, ret);
-		return ret;
 	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -550,13 +548,11 @@  hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint8_t vector_id,
 	op_str = mmap ? "Map" : "Unmap";
 	ret = hns3_send_mbx_msg(hw, code, 0, (uint8_t *)&bind_msg,
 				sizeof(bind_msg), false, NULL, 0);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "%s TQP %d fail, vector_id is %d, ret is %d.",
 			 op_str, queue_id, bind_msg.vector_id, ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int
@@ -1675,12 +1671,10 @@  hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)
 		return ret;
 
 	ret = hns3_start_queues(hns, reset_queue);
-	if (ret) {
+	if (ret)
 		hns3_err(hw, "Failed to start queues: %d", ret);
-		return ret;
-	}
 
-	return 0;
+	return ret;
 }
 
 static int