From: Danylo Vodopianov <dvo-...@napatech.com>

simplify conditionals and remove redundant checks

Signed-off-by: Danylo Vodopianov <dvo-...@napatech.com>
---
 drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c |  3 +-
 .../link_agx_100g/nt4ga_agx_link_100g.c       | 16 +++++------
 drivers/net/ntnic/nim/i2c_nim.c               |  3 +-
 .../core/nt200a0x/reset/nthw_fpga_rst9563.c   | 10 -------
 .../nthw/core/nt400dxx/nthw_fpga_nt400dxx.c   |  3 +-
 drivers/net/ntnic/nthw/core/nthw_phy_tile.c   |  2 +-
 drivers/net/ntnic/nthw/core/nthw_sdc.c        |  3 +-
 drivers/net/ntnic/nthw/core/nthw_tsm.c        |  6 ++--
 drivers/net/ntnic/nthw/flow_api/flow_api.c    |  3 +-
 .../ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c   |  3 --
 .../profile_inline/flow_api_profile_inline.c  |  9 +-----
 drivers/net/ntnic/nthw/nthw_rac.c             |  7 -----
 drivers/net/ntnic/ntnic_ethdev.c              | 28 ++++++++-----------
 13 files changed, 28 insertions(+), 68 deletions(-)

diff --git a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c 
b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
index cc09fdcc4a..c9a0580391 100644
--- a/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
+++ b/drivers/net/ntnic/dbsconfig/ntnic_dbsconfig.c
@@ -761,8 +761,7 @@ static struct nthw_virt_queue 
*nthw_setup_tx_virt_queue(nthw_dbs_t *p_nthw_dbs,
         */
        if (irq_vector < 0) {
                if (set_tx_am_data(p_nthw_dbs, index, 
(uint64_t)avail_struct_phys_addr,
-                               TX_AM_ENABLE, host_id, 0,
-                               irq_vector >= 0 ? 1 : 0) != 0) {
+                               TX_AM_ENABLE, host_id, 0, 0) != 0) {
                        return NULL;
                }
        }
diff --git a/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c 
b/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
index f1c17ea80a..4f6be900fd 100644
--- a/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
+++ b/drivers/net/ntnic/link_mgmt/link_agx_100g/nt4ga_agx_link_100g.c
@@ -1010,20 +1010,18 @@ int nt4ga_agx_link_100g_ports_init(struct 
adapter_info_s *p_adapter_info, nthw_f
 
                nthw_rpf_set_ts_at_eof(p_nthw_agx->p_rpf, true);
 
-               if (res == 0) {
-                       p_adapter_info->nt4ga_link.speed_capa = 
NT_LINK_SPEED_100G;
-                       p_adapter_info->nt4ga_link.variables_initialized = true;
-               }
+
+               p_adapter_info->nt4ga_link.speed_capa = NT_LINK_SPEED_100G;
+               p_adapter_info->nt4ga_link.variables_initialized = true;
        }
 
        /*
         * Create state-machine thread
         */
-       if (res == 0) {
-               if (!monitor_task_is_running[adapter_no]) {
-                       res = rte_thread_create(&monitor_tasks[adapter_no], 
NULL,
-                                       nt4ga_agx_link_100g_mon, 
p_adapter_info);
-               }
+
+       if (!monitor_task_is_running[adapter_no]) {
+               res = rte_thread_create(&monitor_tasks[adapter_no], NULL,
+                               nt4ga_agx_link_100g_mon, p_adapter_info);
        }
 
        return res;
diff --git a/drivers/net/ntnic/nim/i2c_nim.c b/drivers/net/ntnic/nim/i2c_nim.c
index 654e2dd80e..5e8eeb16a7 100644
--- a/drivers/net/ntnic/nim/i2c_nim.c
+++ b/drivers/net/ntnic/nim/i2c_nim.c
@@ -123,8 +123,7 @@ static int nim_read_write_data_lin(nim_i2c_ctx_p ctx, bool 
m_page_addressing, ui
                 * Find out how much can be read from the current block in case 
of
                 * single byte access
                 */
-               if (multi_byte == 1)
-                       max_seq_cnt = block_size - (lin_addr % block_size);
+               max_seq_cnt = block_size - (lin_addr % block_size);
 
                if (m_page_addressing) {
                        if (lin_addr >= 128) {  /* Only page setup above this 
address */
diff --git a/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c 
b/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c
index ee2c2453e5..7b0c47e9b2 100644
--- a/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c
+++ b/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst9563.c
@@ -104,11 +104,6 @@ static int nthw_fpga_rst9563_setup(nthw_fpga_t *p_fpga, 
struct nthw_fpga_rst_nt2
                nthw_register_get_field(p_curr_reg, 
RST9563_STAT_TS_MMCM_LOCKED);
        p->mp_fld_stat_tsm_ref_mmcm_locked = NULL;      /* Field not present on 
9563 */
 
-       if (!p->mp_fld_stat_tsm_ref_mmcm_locked) {
-               NT_LOG(DBG, NTHW, "%s: No RST9563_STAT_TSM_REF_MMCM_LOCKED 
found",
-                       p_adapter_id_str);
-       }
-
        nthw_register_update(p_curr_reg);
 
        /* STICKY register field pointers */
@@ -126,11 +121,6 @@ static int nthw_fpga_rst9563_setup(nthw_fpga_t *p_fpga, 
struct nthw_fpga_rst_nt2
        p->mp_fld_sticky_pci_sys_mmcm_unlocked = NULL;  /* Field not present on 
9563 */
        p->mp_fld_sticky_tsm_ref_mmcm_unlocked = NULL;  /* Field not present on 
9563 */
 
-       if (!p->mp_fld_sticky_tsm_ref_mmcm_unlocked) {
-               NT_LOG(DBG, NTHW, "%s: No RST9563_STICKY_TSM_REF_MMCM_UNLOCKED 
found",
-                       p_adapter_id_str);
-       }
-
        nthw_register_update(p_curr_reg);
 
        /* POWER register field pointers */
diff --git a/drivers/net/ntnic/nthw/core/nt400dxx/nthw_fpga_nt400dxx.c 
b/drivers/net/ntnic/nthw/core/nt400dxx/nthw_fpga_nt400dxx.c
index d610e3a7cc..e7c9fec10d 100644
--- a/drivers/net/ntnic/nthw/core/nt400dxx/nthw_fpga_nt400dxx.c
+++ b/drivers/net/ntnic/nthw/core/nt400dxx/nthw_fpga_nt400dxx.c
@@ -184,8 +184,7 @@ static int nthw_fpga_nt400dxx_init(struct fpga_info_s 
*p_fpga_info)
                /* reset specific */
        switch (p_fpga_info->n_fpga_prod_id) {
        case 9574:
-               if (rst9574_ops)
-                       res = rst9574_ops->nthw_fpga_rst9574_init(p_fpga_info, 
&rst);
+               res = rst9574_ops->nthw_fpga_rst9574_init(p_fpga_info, &rst);
 
                if (res) {
                        NT_LOG(ERR, NTHW,
diff --git a/drivers/net/ntnic/nthw/core/nthw_phy_tile.c 
b/drivers/net/ntnic/nthw/core/nthw_phy_tile.c
index eea220e40b..77400d2514 100644
--- a/drivers/net/ntnic/nthw/core/nthw_phy_tile.c
+++ b/drivers/net/ntnic/nthw/core/nthw_phy_tile.c
@@ -806,7 +806,7 @@ static uint32_t nthw_phy_tile_cpi_request(nthw_phy_tile_t 
*p, uint8_t intf_no, u
 
        nt_os_wait_usec(10000);
 
-       for (int i = 20; i > 0; i--) {
+       for (int i = 20; i >= 0; i--) {
                data = nthw_phy_tile_read_xcvr(p, intf_no, lane, phy_addr + 
lane_offset);
 
                value =
diff --git a/drivers/net/ntnic/nthw/core/nthw_sdc.c 
b/drivers/net/ntnic/nthw/core/nthw_sdc.c
index fc73e6957c..ae967e5ed9 100644
--- a/drivers/net/ntnic/nthw/core/nthw_sdc.c
+++ b/drivers/net/ntnic/nthw/core/nthw_sdc.c
@@ -132,8 +132,7 @@ int nthw_sdc_get_states(nthw_sdc_t *p, uint64_t 
*pn_result_mask)
        if (val != 0)
                n_err_cnt++;
 
-       if (pn_result_mask)
-               *pn_result_mask = n_mask;
+       *pn_result_mask = n_mask;
 
        return n_err_cnt;       /* 0 = all ok */
 }
diff --git a/drivers/net/ntnic/nthw/core/nthw_tsm.c 
b/drivers/net/ntnic/nthw/core/nthw_tsm.c
index b88dcb9b0b..a748c4e1ae 100644
--- a/drivers/net/ntnic/nthw/core/nthw_tsm.c
+++ b/drivers/net/ntnic/nthw/core/nthw_tsm.c
@@ -89,8 +89,7 @@ int nthw_tsm_get_ts(nthw_tsm_t *p, uint64_t *p_ts)
 
        val = ((((uint64_t)n_ts_hi) << 32UL) | n_ts_lo);
 
-       if (p_ts)
-               *p_ts = val;
+       *p_ts = val;
 
        return 0;
 }
@@ -108,8 +107,7 @@ int nthw_tsm_get_time(nthw_tsm_t *p, uint64_t *p_time)
 
        val = ((((uint64_t)n_time_hi) << 32UL) | n_time_lo);
 
-       if (p_time)
-               *p_time = val;
+       *p_time = val;
 
        return 0;
 }
diff --git a/drivers/net/ntnic/nthw/flow_api/flow_api.c 
b/drivers/net/ntnic/nthw/flow_api/flow_api.c
index 358ea3e4fa..90fc3f51a6 100644
--- a/drivers/net/ntnic/nthw/flow_api/flow_api.c
+++ b/drivers/net/ntnic/nthw/flow_api/flow_api.c
@@ -829,8 +829,7 @@ struct flow_nic_dev *nthw_flow_api_create(uint8_t 
adapter_no,
 
 err_exit:
 
-       if (ndev)
-               nthw_flow_api_done(ndev);
+       nthw_flow_api_done(ndev);
 
        NT_LOG(DBG, FILTER, "ERR: %s", __func__);
        return NULL;
diff --git a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c 
b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c
index 69dec801f2..4babc30d2b 100644
--- a/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c
+++ b/drivers/net/ntnic/nthw/flow_api/hw_mod/hw_mod_flm.c
@@ -834,9 +834,6 @@ int hw_mod_flm_stat_get(struct flow_api_backend_s *be, enum 
hw_flm_e field, uint
                        break;
 
                default: {
-                       if (_VER_ < 18)
-                               return UNSUP_FIELD;
-
                        switch (field) {
                        case HW_FLM_STAT_STA_DONE:
                                *value = be->flm.v25.sta_done->cnt;
diff --git 
a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c 
b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
index 6bfa471321..c674531396 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
@@ -4267,8 +4267,6 @@ int flow_destroy_locked_profile_inline(struct 
flow_eth_dev *dev,
        RTE_ASSERT(dev);
        RTE_ASSERT(fh);
 
-       int err = 0;
-
        nthw_flow_nic_set_error(ERR_SUCCESS, error);
 
        /* take flow out of ndev list - may not have been put there yet */
@@ -4318,11 +4316,6 @@ int flow_destroy_locked_profile_inline(struct 
flow_eth_dev *dev,
                fh->fd = NULL;
        }
 
-       if (err) {
-               NT_LOG(ERR, FILTER, "FAILED removing flow: %p", fh);
-               nthw_flow_nic_set_error(ERR_REMOVE_FLOW_FAILED, error);
-       }
-
        free(fh);
        fh = NULL;
 
@@ -4330,7 +4323,7 @@ int flow_destroy_locked_profile_inline(struct 
flow_eth_dev *dev,
        dev->ndev->be.iface->set_debug_mode(dev->ndev->be.be_dev, 
FLOW_BACKEND_DEBUG_MODE_NONE);
 #endif
 
-       return err;
+       return 0;
 }
 
 int flow_destroy_profile_inline(struct flow_eth_dev *dev, struct flow_handle 
*flow,
diff --git a/drivers/net/ntnic/nthw/nthw_rac.c 
b/drivers/net/ntnic/nthw/nthw_rac.c
index d6fdea2ddb..13813fe516 100644
--- a/drivers/net/ntnic/nthw/nthw_rac.c
+++ b/drivers/net/ntnic/nthw/nthw_rac.c
@@ -517,13 +517,6 @@ int nthw_rac_rab_read32_dma(nthw_rac_t *p, 
nthw_rab_bus_id_t bus_id, uint32_t ad
                return -1;
        }
 
-       if ((word_cnt + 3) > RAB_DMA_BUF_CNT) {
-               NT_LOG(ERR, NTHW,
-                       "%s: Failed rab dma read length check - bus: %d addr: 
0x%08X wordcount: %d",
-                       p_adapter_id_str, bus_id, address, word_cnt);
-               return -1;
-       }
-
        if (p->m_in_free < 3) {
                /*
                 * No more memory available.
diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c
index 87a0c3576b..e3ed22b89b 100644
--- a/drivers/net/ntnic/ntnic_ethdev.c
+++ b/drivers/net/ntnic/ntnic_ethdev.c
@@ -1375,7 +1375,6 @@ eth_dev_set_link_up(struct rte_eth_dev *eth_dev)
                return 0;
 
        RTE_ASSERT(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
-       RTE_ASSERT(port == internals->n_intf_no);
 
        port_ops->set_adm_state(p_adapter_info, port, true);
 
@@ -1401,7 +1400,6 @@ eth_dev_set_link_down(struct rte_eth_dev *eth_dev)
                return 0;
 
        RTE_ASSERT(port >= 0 && port < NUM_ADAPTER_PORTS_MAX);
-       RTE_ASSERT(port == internals->n_intf_no);
 
        port_ops->set_link_status(p_adapter_info, port, false);
 
@@ -2201,25 +2199,23 @@ nthw_pci_dev_init(struct rte_pci_device *pci_dev)
                NT_LOG(DBG, NTNIC, "Meter module is not initialized");
 
        /* Initialize the queue system */
-       if (err == 0) {
-               sg_ops = get_sg_ops();
-
-               if (sg_ops != NULL) {
-                       err = sg_ops->nthw_virt_queue_init(fpga_info);
+       sg_ops = get_sg_ops();
 
-                       if (err != 0) {
-                               NT_LOG(ERR, NTNIC,
-                                       "%s: Cannot initialize scatter-gather 
queues",
-                                       
p_nt_drv->adapter_info.mp_adapter_id_str);
+       if (sg_ops != NULL) {
+               err = sg_ops->nthw_virt_queue_init(fpga_info);
 
-                       } else {
-                               NT_LOG(DBG, NTNIC, "%s: Initialized 
scatter-gather queues",
-                                       
p_nt_drv->adapter_info.mp_adapter_id_str);
-                       }
+               if (err != 0) {
+                       NT_LOG(ERR, NTNIC,
+                               "%s: Cannot initialize scatter-gather queues",
+                               p_nt_drv->adapter_info.mp_adapter_id_str);
 
                } else {
-                       NT_LOG_DBGX(DBG, NTNIC, "SG module is not initialized");
+                       NT_LOG(DBG, NTNIC, "%s: Initialized scatter-gather 
queues",
+                               p_nt_drv->adapter_info.mp_adapter_id_str);
                }
+
+       } else {
+               NT_LOG_DBGX(DBG, NTNIC, "SG module is not initialized");
        }
 
        /* Start ctrl, monitor, stat thread only for primary process. */
-- 
2.47.1

Reply via email to