diff mbox

[3/3,v6] mac80211: Refactor ieee80211_iface_work

Message ID 1468693140-19483-3-git-send-email-br.shurik@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show

Commit Message

Alex Briskin July 16, 2016, 6:19 p.m. UTC
Added ieee80211_iface_work_handle_vif_type function. Moved the code that
handles sdata->vif.type from ieee80211_iface_work to the function.

Signed-off-by: Alex Briskin <br.shurik@gmail.com>
---
 net/mac80211/iface.c | 44 ++++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 20 deletions(-)

Comments

Johannes Berg Aug. 1, 2016, 12:23 p.m. UTC | #1
> +		if (ieee80211_iface_work_handle_pkt_type(skb, sdata) &&
> +		    ieee80211_iface_work_handle_frame_control(skb, sdata)) {
> +			ieee80211_iface_work_handle_vif_type(skb, sdata);
>  		}
> 
This ends up being pretty strange IMHO, using boolean short-circuit
evaluation to avoid doing the next thing...

Not sure how to better do this though.

(You also don't need braces here for a single-statement if branch
contents)

johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index c185801..f8f7363 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1323,6 +1323,27 @@  static int ieee80211_iface_work_handle_frame_control(struct sk_buff *skb,
 	return 0;
 }
 
+static void ieee80211_iface_work_handle_vif_type(struct sk_buff *skb,
+					 struct ieee80211_sub_if_data *sdata)
+{
+	switch (sdata->vif.type) {
+	case NL80211_IFTYPE_STATION:
+		ieee80211_sta_rx_queued_mgmt(sdata, skb);
+		break;
+	case NL80211_IFTYPE_ADHOC:
+		ieee80211_ibss_rx_queued_mgmt(sdata, skb);
+		break;
+	case NL80211_IFTYPE_MESH_POINT:
+		if (!ieee80211_vif_is_mesh(&sdata->vif))
+			break;
+		ieee80211_mesh_rx_queued_mgmt(sdata, skb);
+		break;
+	default:
+		WARN(1, "frame for unexpected interface type");
+		break;
+	}
+}
+
 static void ieee80211_iface_work(struct work_struct *work)
 {
 	struct ieee80211_sub_if_data *sdata =
@@ -1341,28 +1362,11 @@  static void ieee80211_iface_work(struct work_struct *work)
 
 	/* first process frames */
 	while ((skb = skb_dequeue(&sdata->skb_queue))) {
-		if (!ieee80211_iface_work_handle_pkt_type(skb, sdata)) {
-			goto free_skb;
-		} else if (!ieee80211_iface_work_handle_frame_control(skb, sdata)) {
-			goto free_skb;
-		} else switch (sdata->vif.type) {
-		case NL80211_IFTYPE_STATION:
-			ieee80211_sta_rx_queued_mgmt(sdata, skb);
-			break;
-		case NL80211_IFTYPE_ADHOC:
-			ieee80211_ibss_rx_queued_mgmt(sdata, skb);
-			break;
-		case NL80211_IFTYPE_MESH_POINT:
-			if (!ieee80211_vif_is_mesh(&sdata->vif))
-				break;
-			ieee80211_mesh_rx_queued_mgmt(sdata, skb);
-			break;
-		default:
-			WARN(1, "frame for unexpected interface type");
-			break;
+		if (ieee80211_iface_work_handle_pkt_type(skb, sdata) &&
+		    ieee80211_iface_work_handle_frame_control(skb, sdata)) {
+			ieee80211_iface_work_handle_vif_type(skb, sdata);
 		}
 
-free_skb:
 		kfree_skb(skb);
 	}