From: Andrew Boyer Date: Thu, 10 Dec 2020 02:57:36 +0000 (-0800) Subject: net/ionic: make minor refactorings X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=75f9690223b5ebd6b171ae09746ae23bc8d221d6;p=dpdk.git net/ionic: make minor refactorings This makes the code clearer and conserves resources. Signed-off-by: Andrew Boyer Reviewed-by: Ferruh Yigit --- diff --git a/drivers/net/ionic/ionic_lif.c b/drivers/net/ionic/ionic_lif.c index 2e33fb8d9b..722a895655 100644 --- a/drivers/net/ionic/ionic_lif.c +++ b/drivers/net/ionic/ionic_lif.c @@ -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(ð_dev->data->mac_addrs[index])) + mac_addr = ð_dev->data->mac_addrs[index]; + + if (!rte_is_valid_assigned_ether_addr(mac_addr)) return; - ionic_lif_addr_del(lif, (const uint8_t *) - ð_dev->data->mac_addrs[index]); + ionic_lif_addr_del(lif, (const uint8_t *)mac_addr); } int diff --git a/drivers/net/ionic/ionic_main.c b/drivers/net/ionic/ionic_main.c index f77bddaa4d..92cf0f3984 100644 --- a/drivers/net/ionic/ionic_main.c +++ b/drivers/net/ionic/ionic_main.c @@ -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