net/ionic: make minor refactorings
authorAndrew Boyer <aboyer@pensando.io>
Thu, 10 Dec 2020 02:57:36 +0000 (18:57 -0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 8 Jan 2021 15:03:04 +0000 (16:03 +0100)
This makes the code clearer and conserves resources.

Signed-off-by: Andrew Boyer <aboyer@pensando.io>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
drivers/net/ionic/ionic_lif.c
drivers/net/ionic/ionic_main.c

index 2e33fb8..722a895 100644 (file)
@@ -77,11 +77,14 @@ void
 ionic_lif_reset(struct ionic_lif *lif)
 {
        struct ionic_dev *idev = &lif->adapter->idev;
+       int err;
 
        IONIC_PRINT_CALL();
 
        ionic_dev_cmd_lif_reset(idev, lif->index);
-       ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
+       err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
+       if (err)
+               IONIC_PRINT(WARNING, "Failed to reset lif");
 }
 
 static void
@@ -305,10 +308,11 @@ ionic_dev_add_mac(struct rte_eth_dev *eth_dev,
 }
 
 void
-ionic_dev_remove_mac(struct rte_eth_dev *eth_dev, uint32_t index __rte_unused)
+ionic_dev_remove_mac(struct rte_eth_dev *eth_dev, uint32_t index)
 {
        struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev);
        struct ionic_adapter *adapter = lif->adapter;
+       struct rte_ether_addr *mac_addr;
 
        IONIC_PRINT_CALL();
 
@@ -319,11 +323,12 @@ ionic_dev_remove_mac(struct rte_eth_dev *eth_dev, uint32_t index __rte_unused)
                return;
        }
 
-       if (!rte_is_valid_assigned_ether_addr(&eth_dev->data->mac_addrs[index]))
+       mac_addr = &eth_dev->data->mac_addrs[index];
+
+       if (!rte_is_valid_assigned_ether_addr(mac_addr))
                return;
 
-       ionic_lif_addr_del(lif, (const uint8_t *)
-               &eth_dev->data->mac_addrs[index]);
+       ionic_lif_addr_del(lif, (const uint8_t *)mac_addr);
 }
 
 int
index f77bdda..92cf0f3 100644 (file)
@@ -188,8 +188,7 @@ ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
        done = ionic_wait_ctx_for_completion(lif, qcq, ctx,
                IONIC_DEVCMD_TIMEOUT);
 
-       err = ionic_adminq_check_err(ctx, !done /* timed out */);
-       return err;
+       return ionic_adminq_check_err(ctx, !done /* timed out */);
 }
 
 static int
@@ -241,10 +240,11 @@ ionic_dev_cmd_wait_check(struct ionic_dev *idev, unsigned long max_wait)
        int err;
 
        err = ionic_dev_cmd_wait(idev, max_wait);
-       if (err)
-               return err;
 
-       return ionic_dev_cmd_check_error(idev);
+       if (!err)
+               err = ionic_dev_cmd_check_error(idev);
+
+       return err;
 }
 
 int
@@ -299,22 +299,18 @@ int
 ionic_init(struct ionic_adapter *adapter)
 {
        struct ionic_dev *idev = &adapter->idev;
-       int err;
 
        ionic_dev_cmd_init(idev);
-       err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
-       return err;
+       return ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
 }
 
 int
 ionic_reset(struct ionic_adapter *adapter)
 {
        struct ionic_dev *idev = &adapter->idev;
-       int err;
 
        ionic_dev_cmd_reset(idev);
-       err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
-       return err;
+       return ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
 }
 
 int