f6e1793
From 658f1bd2dd632209df00ec66349e15941ffdd83b Mon Sep 17 00:00:00 2001
f6e1793
From: Stanislaw Gruszka <sgruszka@redhat.com>
f6e1793
Date: Wed, 16 Jan 2013 10:28:09 +0000
f6e1793
Subject: [PATCH 3.8] iwlegacy: fix IBSS cleanup
f6e1793
f6e1793
We do not correctly change interface type when switching from
f6e1793
IBSS mode to STA mode, that results in microcode errors. 
f6e1793
f6e1793
Resolves:
f6e1793
https://bugzilla.redhat.com/show_bug.cgi?id=886946
f6e1793
f6e1793
Reported-by: Jaroslav Skarvada <jskarvad@redhat.com>
f6e1793
Cc: stable@vger.kernel.org
f6e1793
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
f6e1793
---
f6e1793
 drivers/net/wireless/iwlegacy/common.c | 35 ++++++++++++++--------------------
f6e1793
 1 file changed, 14 insertions(+), 21 deletions(-)
f6e1793
f6e1793
diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c
f6e1793
index 7e16d10..90b8970 100644
f6e1793
--- a/drivers/net/wireless/iwlegacy/common.c
f6e1793
+++ b/drivers/net/wireless/iwlegacy/common.c
f6e1793
@@ -3958,17 +3958,21 @@ il_connection_init_rx_config(struct il_priv *il)
f6e1793
 
f6e1793
 	memset(&il->staging, 0, sizeof(il->staging));
f6e1793
 
f6e1793
-	if (!il->vif) {
f6e1793
+	switch (il->iw_mode) {
f6e1793
+	case NL80211_IFTYPE_UNSPECIFIED:
f6e1793
 		il->staging.dev_type = RXON_DEV_TYPE_ESS;
f6e1793
-	} else if (il->vif->type == NL80211_IFTYPE_STATION) {
f6e1793
+		break;
f6e1793
+	case NL80211_IFTYPE_STATION:
f6e1793
 		il->staging.dev_type = RXON_DEV_TYPE_ESS;
f6e1793
 		il->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK;
f6e1793
-	} else if (il->vif->type == NL80211_IFTYPE_ADHOC) {
f6e1793
+		break;
f6e1793
+	case NL80211_IFTYPE_ADHOC:
f6e1793
 		il->staging.dev_type = RXON_DEV_TYPE_IBSS;
f6e1793
 		il->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK;
f6e1793
 		il->staging.filter_flags =
f6e1793
 		    RXON_FILTER_BCON_AWARE_MSK | RXON_FILTER_ACCEPT_GRP_MSK;
f6e1793
-	} else {
f6e1793
+		break;
f6e1793
+	default:
f6e1793
 		IL_ERR("Unsupported interface type %d\n", il->vif->type);
f6e1793
 		return;
f6e1793
 	}
f6e1793
@@ -4550,8 +4554,7 @@ out:
f6e1793
 EXPORT_SYMBOL(il_mac_add_interface);
f6e1793
 
f6e1793
 static void
f6e1793
-il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif,
f6e1793
-		      bool mode_change)
f6e1793
+il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif)
f6e1793
 {
f6e1793
 	lockdep_assert_held(&il->mutex);
f6e1793
 
f6e1793
@@ -4560,9 +4563,7 @@ il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif,
f6e1793
 		il_force_scan_end(il);
f6e1793
 	}
f6e1793
 
f6e1793
-	if (!mode_change)
f6e1793
-		il_set_mode(il);
f6e1793
-
f6e1793
+	il_set_mode(il);
f6e1793
 }
f6e1793
 
f6e1793
 void
f6e1793
@@ -4575,8 +4576,8 @@ il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
f6e1793
 
f6e1793
 	WARN_ON(il->vif != vif);
f6e1793
 	il->vif = NULL;
f6e1793
-
f6e1793
-	il_teardown_interface(il, vif, false);
f6e1793
+	il->iw_mode = NL80211_IFTYPE_UNSPECIFIED;
f6e1793
+	il_teardown_interface(il, vif);
f6e1793
 	memset(il->bssid, 0, ETH_ALEN);
f6e1793
 
f6e1793
 	D_MAC80211("leave\n");
f6e1793
@@ -4685,18 +4686,10 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
f6e1793
 	}
f6e1793
 
f6e1793
 	/* success */
f6e1793
-	il_teardown_interface(il, vif, true);
f6e1793
 	vif->type = newtype;
f6e1793
 	vif->p2p = false;
f6e1793
-	err = il_set_mode(il);
f6e1793
-	WARN_ON(err);
f6e1793
-	/*
f6e1793
-	 * We've switched internally, but submitting to the
f6e1793
-	 * device may have failed for some reason. Mask this
f6e1793
-	 * error, because otherwise mac80211 will not switch
f6e1793
-	 * (and set the interface type back) and we'll be
f6e1793
-	 * out of sync with it.
f6e1793
-	 */
f6e1793
+	il->iw_mode = newtype;
f6e1793
+	il_teardown_interface(il, vif);
f6e1793
 	err = 0;
f6e1793
 
f6e1793
 out:
f6e1793
-- 
f6e1793
1.8.0.2
f6e1793