diff mbox series

[62/65] staging: wfx: simplify hif_handle_tx_data()

Message ID 20200115121041.10863-63-Jerome.Pouiller@silabs.com (mailing list archive)
State Not Applicable
Delegated to: Johannes Berg
Headers show
Series Simplify and improve the wfx driver | expand

Commit Message

Jérôme Pouiller Jan. 15, 2020, 12:13 p.m. UTC
From: Jérôme Pouiller <jerome.pouiller@silabs.com>

Since enum action has now only two cases, it can be dropped. Then
hif_handle_tx_data() can be simplified.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/queue.c | 40 ++++++++++++++-----------------------
 1 file changed, 15 insertions(+), 25 deletions(-)
diff mbox series

Patch

diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c
index e0c609c35a7b..024497eb19ac 100644
--- a/drivers/staging/wfx/queue.c
+++ b/drivers/staging/wfx/queue.c
@@ -359,16 +359,13 @@  bool wfx_tx_queues_is_empty(struct wfx_dev *wdev)
 static bool hif_handle_tx_data(struct wfx_vif *wvif, struct sk_buff *skb,
 			       struct wfx_queue *queue)
 {
-	bool handled = false;
-	struct wfx_tx_priv *tx_priv = wfx_skb_tx_priv(skb);
 	struct hif_req_tx *req = wfx_skb_txreq(skb);
-	struct ieee80211_hdr *frame = (struct ieee80211_hdr *) (req->frame + req->data_flags.fc_offset);
-
-	enum {
-		do_wep,
-		do_tx,
-	} action = do_tx;
+	struct ieee80211_key_conf *hw_key = wfx_skb_tx_priv(skb)->hw_key;
+	struct ieee80211_hdr *frame =
+		(struct ieee80211_hdr *)(req->frame + req->data_flags.fc_offset);
 
+	// FIXME: mac80211 is smart enough to handle BSS loss. Driver should not
+	// try to do anything about that.
 	if (ieee80211_is_nullfunc(frame->frame_control)) {
 		mutex_lock(&wvif->bss_loss_lock);
 		if (wvif->bss_loss_state) {
@@ -376,31 +373,24 @@  static bool hif_handle_tx_data(struct wfx_vif *wvif, struct sk_buff *skb,
 			req->queue_id.queue_id = HIF_QUEUE_ID_VOICE;
 		}
 		mutex_unlock(&wvif->bss_loss_lock);
-	} else if (ieee80211_has_protected(frame->frame_control) &&
-		   tx_priv->hw_key &&
-		   tx_priv->hw_key->keyidx != wvif->wep_default_key_id &&
-		   (tx_priv->hw_key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
-		    tx_priv->hw_key->cipher == WLAN_CIPHER_SUITE_WEP104)) {
-		action = do_wep;
 	}
 
-	switch (action) {
-	case do_wep:
+	// FIXME: identify the exact scenario matched by this condition. Does it
+	// happen yet?
+	if (ieee80211_has_protected(frame->frame_control) &&
+	    hw_key && hw_key->keyidx != wvif->wep_default_key_id &&
+	    (hw_key->cipher == WLAN_CIPHER_SUITE_WEP40 ||
+	     hw_key->cipher == WLAN_CIPHER_SUITE_WEP104)) {
 		wfx_tx_lock(wvif->wdev);
 		WARN_ON(wvif->wep_pending_skb);
-		wvif->wep_default_key_id = tx_priv->hw_key->keyidx;
+		wvif->wep_default_key_id = hw_key->keyidx;
 		wvif->wep_pending_skb = skb;
 		if (!schedule_work(&wvif->wep_key_work))
 			wfx_tx_unlock(wvif->wdev);
-		handled = true;
-		break;
-	case do_tx:
-		break;
-	default:
-		/* Do nothing */
-		break;
+		return true;
+	} else {
+		return false;
 	}
-	return handled;
 }
 
 static int wfx_get_prio_queue(struct wfx_vif *wvif,