cfg80211: Advertise ciphers via WE according to driver capability

Signed-off-by: David Kilroy <kilroyd@googlemail.com>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 9e56f35..7dbe6c6 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -204,8 +204,19 @@
 	range->avg_qual.noise = range->max_qual.noise / 2;
 	range->avg_qual.updated = range->max_qual.updated;
 
-	range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
-			  IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
+	range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2;
+
+	for (c = 0; c < wdev->wiphy->n_cipher_suites; c++) {
+		switch (wdev->wiphy->cipher_suites[c]) {
+		case WLAN_CIPHER_SUITE_TKIP:
+			range->enc_capa |= IW_ENC_CAPA_CIPHER_TKIP;
+			break;
+
+		case WLAN_CIPHER_SUITE_CCMP:
+			range->enc_capa |= IW_ENC_CAPA_CIPHER_CCMP;
+			break;
+		}
+	}
 
 	for (band = 0; band < IEEE80211_NUM_BANDS; band ++) {
 		int i;