Skip to content

Commit 2be50b8

Browse files
yogeshpowarlinvjw
authored andcommitted
mwifiex: remove redundant encryption_mode mapping
remove MWIFIEX_ENCRYPTION_MODE_ and use WLAN_CIPHER_SUITE_ macros directly Signed-off-by: Yogesh Ashok Powar <yogeshp@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 2d3d0a8 commit 2be50b8

6 files changed

Lines changed: 19 additions & 83 deletions

File tree

‎drivers/net/wireless/mwifiex/cfg80211.c‎

Lines changed: 10 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ mwifiex_is_alg_wep(u32 cipher)
9090
int alg = 0;
9191

9292
switch (cipher) {
93-
case MWIFIEX_ENCRYPTION_MODE_WEP40:
94-
case MWIFIEX_ENCRYPTION_MODE_WEP104:
93+
case WLAN_CIPHER_SUITE_WEP40:
94+
case WLAN_CIPHER_SUITE_WEP104:
9595
alg = 1;
9696
break;
9797
default:
@@ -101,55 +101,6 @@ mwifiex_is_alg_wep(u32 cipher)
101101
return alg;
102102
}
103103

104-
/*
105-
* This function maps the given cipher type into driver specific type.
106-
*
107-
* It also sets a flag to indicate whether WPA is enabled or not.
108-
*
109-
* The mapping table is -
110-
* Input cipher Driver cipher type WPA enabled?
111-
* ------------ ------------------ ------------
112-
* IW_AUTH_CIPHER_NONE MWIFIEX_ENCRYPTION_MODE_NONE No
113-
* WLAN_CIPHER_SUITE_WEP40 MWIFIEX_ENCRYPTION_MODE_WEP40 No
114-
* WLAN_CIPHER_SUITE_WEP104 MWIFIEX_ENCRYPTION_MODE_WEP104 No
115-
* WLAN_CIPHER_SUITE_TKIP MWIFIEX_ENCRYPTION_MODE_TKIP Yes
116-
* WLAN_CIPHER_SUITE_CCMP MWIFIEX_ENCRYPTION_MODE_CCMP Yes
117-
* Others -1 No
118-
*/
119-
static int
120-
mwifiex_get_mwifiex_cipher(u32 cipher, int *wpa_enabled)
121-
{
122-
int encrypt_mode;
123-
124-
if (wpa_enabled)
125-
*wpa_enabled = 0;
126-
switch (cipher) {
127-
case IW_AUTH_CIPHER_NONE:
128-
encrypt_mode = MWIFIEX_ENCRYPTION_MODE_NONE;
129-
break;
130-
case WLAN_CIPHER_SUITE_WEP40:
131-
encrypt_mode = MWIFIEX_ENCRYPTION_MODE_WEP40;
132-
break;
133-
case WLAN_CIPHER_SUITE_WEP104:
134-
encrypt_mode = MWIFIEX_ENCRYPTION_MODE_WEP104;
135-
break;
136-
case WLAN_CIPHER_SUITE_TKIP:
137-
encrypt_mode = MWIFIEX_ENCRYPTION_MODE_TKIP;
138-
if (wpa_enabled)
139-
*wpa_enabled = 1;
140-
break;
141-
case WLAN_CIPHER_SUITE_CCMP:
142-
encrypt_mode = MWIFIEX_ENCRYPTION_MODE_CCMP;
143-
if (wpa_enabled)
144-
*wpa_enabled = 1;
145-
break;
146-
default:
147-
encrypt_mode = -1;
148-
}
149-
150-
return encrypt_mode;
151-
}
152-
153104
/*
154105
* This function retrieves the private structure from kernel wiphy structure.
155106
*/
@@ -252,13 +203,9 @@ mwifiex_cfg80211_add_key(struct wiphy *wiphy, struct net_device *netdev,
252203
{
253204
struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
254205
int ret = 0;
255-
int encrypt_mode;
256-
257-
encrypt_mode = mwifiex_get_mwifiex_cipher(params->cipher, NULL);
258206

259-
if (encrypt_mode != -1)
260-
ret = mwifiex_set_encode(priv, params->key, params->key_len,
261-
key_index, 0);
207+
ret = mwifiex_set_encode(priv, params->key, params->key_len,
208+
key_index, 0);
262209

263210
wiphy_dbg(wiphy, "info: crypto keys added\n");
264211

@@ -1019,7 +966,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
1019966
struct mwifiex_802_11_ssid req_ssid;
1020967
struct mwifiex_ssid_bssid ssid_bssid;
1021968
int ret = 0;
1022-
int auth_type = 0, pairwise_encrypt_mode = 0, wpa_enabled = 0;
969+
int auth_type = 0, pairwise_encrypt_mode = 0;
1023970
int group_encrypt_mode = 0;
1024971
int alg_is_wep = 0;
1025972

@@ -1052,13 +999,13 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
1052999
/* "privacy" is set only for ad-hoc mode */
10531000
if (privacy) {
10541001
/*
1055-
* Keep MWIFIEX_ENCRYPTION_MODE_WEP104 for now so that
1002+
* Keep WLAN_CIPHER_SUITE_WEP104 for now so that
10561003
* the firmware can find a matching network from the
10571004
* scan. The cfg80211 does not give us the encryption
10581005
* mode at this stage so just setting it to WEP here.
10591006
*/
10601007
priv->sec_info.encryption_mode =
1061-
MWIFIEX_ENCRYPTION_MODE_WEP104;
1008+
WLAN_CIPHER_SUITE_WEP104;
10621009
priv->sec_info.authentication_mode =
10631010
NL80211_AUTHTYPE_OPEN_SYSTEM;
10641011
}
@@ -1074,16 +1021,13 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
10741021
auth_type = NL80211_AUTHTYPE_SHARED_KEY;
10751022

10761023
if (sme->crypto.n_ciphers_pairwise) {
1077-
pairwise_encrypt_mode = mwifiex_get_mwifiex_cipher(sme->crypto.
1078-
ciphers_pairwise[0], &wpa_enabled);
1079-
priv->sec_info.encryption_mode = pairwise_encrypt_mode;
1024+
priv->sec_info.encryption_mode =
1025+
sme->crypto.ciphers_pairwise[0];
10801026
priv->sec_info.authentication_mode = auth_type;
10811027
}
10821028

10831029
if (sme->crypto.cipher_group) {
1084-
group_encrypt_mode = mwifiex_get_mwifiex_cipher(sme->crypto.
1085-
cipher_group, &wpa_enabled);
1086-
priv->sec_info.encryption_mode = group_encrypt_mode;
1030+
priv->sec_info.encryption_mode = sme->crypto.cipher_group;
10871031
priv->sec_info.authentication_mode = auth_type;
10881032
}
10891033
if (sme->ie)

‎drivers/net/wireless/mwifiex/init.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static int mwifiex_init_priv(struct mwifiex_private *priv)
8686

8787
priv->sec_info.wep_status = MWIFIEX_802_11_WEP_DISABLED;
8888
priv->sec_info.authentication_mode = NL80211_AUTHTYPE_OPEN_SYSTEM;
89-
priv->sec_info.encryption_mode = MWIFIEX_ENCRYPTION_MODE_NONE;
89+
priv->sec_info.encryption_mode = 0;
9090
for (i = 0; i < ARRAY_SIZE(priv->wep_key); i++)
9191
memset(&priv->wep_key[i], 0, sizeof(struct mwifiex_wep_key));
9292
priv->wep_key_curr_index = 0;

‎drivers/net/wireless/mwifiex/ioctl.h‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,6 @@ struct mwifiex_debug_info {
267267
u8 event_received;
268268
};
269269

270-
enum {
271-
MWIFIEX_ENCRYPTION_MODE_NONE = 0,
272-
MWIFIEX_ENCRYPTION_MODE_WEP40 = 1,
273-
MWIFIEX_ENCRYPTION_MODE_TKIP = 2,
274-
MWIFIEX_ENCRYPTION_MODE_CCMP = 3,
275-
MWIFIEX_ENCRYPTION_MODE_WEP104 = 4,
276-
};
277-
278270
#define MWIFIEX_KEY_INDEX_UNICAST 0x40000000
279271
#define MWIFIEX_MAX_KEY_LENGTH 32
280272
#define WAPI_RXPN_LEN 16

‎drivers/net/wireless/mwifiex/join.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
869869
tmp_cap |= WLAN_CAPABILITY_IBSS;
870870

871871
/* Set up privacy in bss_desc */
872-
if (priv->sec_info.encryption_mode != MWIFIEX_ENCRYPTION_MODE_NONE) {
872+
if (priv->sec_info.encryption_mode) {
873873
/* Ad-Hoc capability privacy on */
874874
dev_dbg(adapter->dev,
875875
"info: ADHOC_S_CMD: wep_status set privacy to WEP\n");

‎drivers/net/wireless/mwifiex/scan.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ mwifiex_is_network_compatible_for_no_sec(struct mwifiex_private *priv,
273273
&& ((!bss_desc->bcn_rsn_ie) ||
274274
((*(bss_desc->bcn_rsn_ie)).ieee_hdr.element_id !=
275275
WLAN_EID_RSN))
276-
&& priv->sec_info.encryption_mode ==
277-
MWIFIEX_ENCRYPTION_MODE_NONE && !bss_desc->privacy) {
276+
&& !priv->sec_info.encryption_mode
277+
&& !bss_desc->privacy) {
278278
return true;
279279
}
280280
return false;
@@ -386,8 +386,8 @@ mwifiex_is_network_compatible_for_adhoc_aes(struct mwifiex_private *priv,
386386
element_id != WLAN_EID_WPA))
387387
&& ((!bss_desc->bcn_rsn_ie) || ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.
388388
element_id != WLAN_EID_RSN))
389-
&& priv->sec_info.encryption_mode ==
390-
MWIFIEX_ENCRYPTION_MODE_NONE && bss_desc->privacy) {
389+
&& !priv->sec_info.encryption_mode
390+
&& bss_desc->privacy) {
391391
return true;
392392
}
393393
return false;
@@ -408,8 +408,8 @@ mwifiex_is_network_compatible_for_dynamic_wep(struct mwifiex_private *priv,
408408
element_id != WLAN_EID_WPA))
409409
&& ((!bss_desc->bcn_rsn_ie) || ((*(bss_desc->bcn_rsn_ie)).ieee_hdr.
410410
element_id != WLAN_EID_RSN))
411-
&& priv->sec_info.encryption_mode !=
412-
MWIFIEX_ENCRYPTION_MODE_NONE && bss_desc->privacy) {
411+
&& priv->sec_info.encryption_mode
412+
&& bss_desc->privacy) {
413413
dev_dbg(priv->adapter->dev, "info: %s: dynamic "
414414
"WEP: index=%d wpa_ie=%#x wpa2_ie=%#x "
415415
"EncMode=%#x privacy=%#x\n",

‎drivers/net/wireless/mwifiex/sta_event.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ mwifiex_reset_connect_state(struct mwifiex_private *priv)
7676
priv->wapi_ie_len = 0;
7777
priv->sec_info.wapi_key_on = false;
7878

79-
priv->sec_info.encryption_mode = MWIFIEX_ENCRYPTION_MODE_NONE;
79+
priv->sec_info.encryption_mode = 0;
8080

8181
/* Enable auto data rate */
8282
priv->is_data_rate_auto = true;

0 commit comments

Comments
 (0)