diff mbox series

[v2,35/50] wilc1000: introduce copy_and_send_packets() helper function

Message ID 20211223011358.4031459-36-davidm@egauge.net (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series wilc1000: rework tx path to use sk_buffs throughout | expand

Commit Message

David Mosberger-Tang Dec. 23, 2021, 1:14 a.m. UTC
Continuing the quest of simplifying the txq handler, factor the code
to copy and send packets into its own function.

Signed-off-by: David Mosberger-Tang <davidm@egauge.net>
---
 .../net/wireless/microchip/wilc1000/wlan.c    | 23 ++++++++++++++-----
 1 file changed, 17 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index 803d35b18d2e0..18b1e7fad4d71 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -906,6 +906,22 @@  static int send_packets(struct wilc *wilc, int len)
 	return func->hif_block_tx_ext(wilc, 0, wilc->tx_buffer, len);
 }
 
+static int copy_and_send_packets(struct wilc *wilc, int entries,
+				 u32 vmm_table[WILC_VMM_TBL_SIZE],
+				 u8 vmm_entries_ac[WILC_VMM_TBL_SIZE])
+{
+	int len, ret;
+
+	len = copy_packets(wilc, entries, vmm_table, vmm_entries_ac);
+	if (len <= 0)
+		return len;
+
+	acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
+	ret = send_packets(wilc, len);
+	release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
+	return ret;
+}
+
 int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
 {
 	int vmm_table_len, entries;
@@ -940,12 +956,7 @@  int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
 	if (entries <= 0) {
 		ret = entries;
 	} else {
-		ret = copy_packets(wilc, entries, vmm_table, vmm_entries_ac);
-		if (ret > 0) {
-			acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
-			ret = send_packets(wilc, ret);
-			release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP);
-		}
+		ret = copy_and_send_packets(wilc, entries, vmm_table, vmm_entries_ac);
 	}
 	if (ret >= 0 && entries < vmm_table_len)
 		ret = WILC_VMM_ENTRY_FULL_RETRY;