Skip to content

Commit eecd825

Browse files
bingzlinvjw
authored andcommitted
mwifiex: remove MWIFIEX_BSS_MODE_ macros
replace them with NL80211_IFTYPE_ macros Also remove redundant functions mwifiex_drv_get_mode() and mwifiex_bss_ioctl_mode(). Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 6a4c499 commit eecd825

12 files changed

Lines changed: 74 additions & 165 deletions

File tree

‎drivers/net/wireless/mwifiex/11n.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ mwifiex_fill_cap_info(struct mwifiex_private *priv,
109109
memset(&mcs[rx_mcs_supp], 0,
110110
sizeof(struct ieee80211_mcs_info) - rx_mcs_supp);
111111

112-
if (priv->bss_mode == MWIFIEX_BSS_MODE_INFRA ||
112+
if (priv->bss_mode == NL80211_IFTYPE_STATION ||
113113
(ht_cap_info & IEEE80211_HT_CAP_SUP_WIDTH_20_40))
114114
/* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
115115
SETHT_MCS32(ht_cap->ht_cap.mcs.rx_mask);
@@ -418,7 +418,7 @@ mwifiex_cmd_append_11n_tlv(struct mwifiex_private *priv,
418418
}
419419

420420
if (bss_desc->bcn_ht_info) {
421-
if (priv->bss_mode == MWIFIEX_BSS_MODE_IBSS) {
421+
if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
422422
ht_info = (struct mwifiex_ie_types_htinfo *) *buffer;
423423
memset(ht_info, 0,
424424
sizeof(struct mwifiex_ie_types_htinfo));

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

Lines changed: 39 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -398,24 +398,20 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv,
398398
int ret = 0;
399399
int status = 0;
400400
struct mwifiex_ds_band_cfg band_cfg;
401-
int mode;
402-
u8 wait_option = MWIFIEX_IOCTL_WAIT;
403401
u32 config_bands = 0;
404402
struct wiphy *wiphy = priv->wdev->wiphy;
405403

406-
mode = mwifiex_drv_get_mode(priv, wait_option);
407-
408404
if (chan) {
409405
memset(&band_cfg, 0, sizeof(band_cfg));
410406
/* Set appropriate bands */
411407
if (chan->band == IEEE80211_BAND_2GHZ)
412408
config_bands = BAND_B | BAND_G | BAND_GN;
413409
else
414410
config_bands = BAND_AN | BAND_A;
415-
if (mode == MWIFIEX_BSS_MODE_INFRA
416-
|| mode == MWIFIEX_BSS_MODE_AUTO) {
411+
if (priv->bss_mode == NL80211_IFTYPE_STATION
412+
|| priv->bss_mode == NL80211_IFTYPE_UNSPECIFIED) {
417413
band_cfg.config_bands = config_bands;
418-
} else if (mode == MWIFIEX_BSS_MODE_IBSS) {
414+
} else if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
419415
band_cfg.config_bands = config_bands;
420416
band_cfg.adhoc_start_band = config_bands;
421417
}
@@ -432,7 +428,8 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv,
432428
}
433429

434430
wiphy_dbg(wiphy, "info: setting band %d, channel offset %d and "
435-
"mode %d\n", config_bands, band_cfg.sec_chan_offset, mode);
431+
"mode %d\n", config_bands, band_cfg.sec_chan_offset,
432+
priv->bss_mode);
436433
if (!chan)
437434
return ret;
438435

@@ -561,14 +558,6 @@ mwifiex_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
561558

562559
/*
563560
* CFG802.11 operation handler to change interface type.
564-
*
565-
* This function creates an IOCTL request, populates it accordingly
566-
* and issues an IOCTL.
567-
*
568-
* The function also maps the CFG802.11 mode type into driver mode type.
569-
* NL80211_IFTYPE_ADHOC -> MWIFIEX_BSS_MODE_IBSS
570-
* NL80211_IFTYPE_STATION -> MWIFIEX_BSS_MODE_INFRA
571-
* NL80211_IFTYPE_UNSPECIFIED -> MWIFIEX_BSS_MODE_AUTO
572561
*/
573562
static int
574563
mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
@@ -578,41 +567,50 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy,
578567
{
579568
int ret = 0;
580569
struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
581-
int mode = -1;
582570
struct mwifiex_wait_queue *wait = NULL;
583-
int status = 0;
584571

585-
wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
586-
if (!wait)
587-
return -ENOMEM;
572+
if (priv->bss_mode == type) {
573+
wiphy_warn(wiphy, "already set to required type\n");
574+
return 0;
575+
}
576+
577+
priv->bss_mode = type;
588578

589579
switch (type) {
590580
case NL80211_IFTYPE_ADHOC:
591-
mode = MWIFIEX_BSS_MODE_IBSS;
592581
dev->ieee80211_ptr->iftype = NL80211_IFTYPE_ADHOC;
593582
wiphy_dbg(wiphy, "info: setting interface type to adhoc\n");
594583
break;
595584
case NL80211_IFTYPE_STATION:
596-
mode = MWIFIEX_BSS_MODE_INFRA;
597585
dev->ieee80211_ptr->iftype = NL80211_IFTYPE_STATION;
598-
wiphy_dbg(wiphy, "info: Setting interface type to managed\n");
586+
wiphy_dbg(wiphy, "info: setting interface type to managed\n");
599587
break;
600588
case NL80211_IFTYPE_UNSPECIFIED:
601-
mode = MWIFIEX_BSS_MODE_AUTO;
602589
dev->ieee80211_ptr->iftype = NL80211_IFTYPE_STATION;
603590
wiphy_dbg(wiphy, "info: setting interface type to auto\n");
604-
break;
591+
return 0;
605592
default:
606-
ret = -EINVAL;
593+
wiphy_err(wiphy, "unknown interface type: %d\n", type);
594+
return -EINVAL;
607595
}
608-
if (ret)
609-
goto done;
610-
status = mwifiex_bss_ioctl_mode(priv, wait, HostCmd_ACT_GEN_SET, &mode);
611596

612-
if (mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT))
597+
wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
598+
if (!wait)
599+
return -ENOMEM;
600+
601+
mwifiex_deauthenticate(priv, wait, NULL);
602+
603+
priv->sec_info.authentication_mode = MWIFIEX_AUTH_MODE_OPEN;
604+
605+
ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_SET_BSS_MODE,
606+
HostCmd_ACT_GEN_SET, 0, wait, NULL);
607+
if (!ret)
608+
ret = -EINPROGRESS;
609+
610+
ret = mwifiex_request_ioctl(priv, wait, ret, MWIFIEX_IOCTL_WAIT);
611+
if (ret)
613612
ret = -EFAULT;
614613

615-
done:
616614
kfree(wait);
617615
return ret;
618616
}
@@ -1046,7 +1044,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
10461044

10471045
ret = mwifiex_set_encode(priv, NULL, 0, 0, 1); /* Disable keys */
10481046

1049-
if (mode == MWIFIEX_BSS_MODE_IBSS) {
1047+
if (mode == NL80211_IFTYPE_ADHOC) {
10501048
/* "privacy" is set only for ad-hoc mode */
10511049
if (privacy) {
10521050
/*
@@ -1108,7 +1106,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
11081106

11091107
memcpy(&ssid_bssid.ssid, &req_ssid, sizeof(struct mwifiex_802_11_ssid));
11101108

1111-
if (mode != MWIFIEX_BSS_MODE_IBSS) {
1109+
if (mode != NL80211_IFTYPE_ADHOC) {
11121110
if (mwifiex_find_best_bss(priv, MWIFIEX_IOCTL_WAIT,
11131111
&ssid_bssid))
11141112
return -EFAULT;
@@ -1129,7 +1127,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
11291127
if (mwifiex_bss_start(priv, MWIFIEX_IOCTL_WAIT, &ssid_bssid))
11301128
return -EFAULT;
11311129

1132-
if (mode == MWIFIEX_BSS_MODE_IBSS) {
1130+
if (mode == NL80211_IFTYPE_ADHOC) {
11331131
/* Inform the BSS information to kernel, otherwise
11341132
* kernel will give a panic after successful assoc */
11351133
if (mwifiex_cfg80211_inform_ibss_bss(priv))
@@ -1152,14 +1150,11 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
11521150
{
11531151
struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
11541152
int ret = 0;
1155-
int mode = 0;
11561153

11571154
if (priv->assoc_request)
11581155
return -EBUSY;
11591156

1160-
mode = mwifiex_drv_get_mode(priv, MWIFIEX_IOCTL_WAIT);
1161-
1162-
if (mode == MWIFIEX_BSS_MODE_IBSS) {
1157+
if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
11631158
wiphy_err(wiphy, "received infra assoc request "
11641159
"when station is in ibss mode\n");
11651160
goto done;
@@ -1171,7 +1166,7 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
11711166
(char *) sme->ssid, sme->bssid);
11721167

11731168
ret = mwifiex_cfg80211_assoc(priv, sme->ssid_len, sme->ssid, sme->bssid,
1174-
mode, sme->channel, sme, 0);
1169+
priv->bss_mode, sme->channel, sme, 0);
11751170

11761171
done:
11771172
priv->assoc_result = ret;
@@ -1191,13 +1186,11 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
11911186
{
11921187
struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
11931188
int ret = 0;
1194-
int mode = 0;
11951189

11961190
if (priv->ibss_join_request)
11971191
return -EBUSY;
11981192

1199-
mode = mwifiex_drv_get_mode(priv, MWIFIEX_IOCTL_WAIT);
1200-
if (mode != MWIFIEX_BSS_MODE_IBSS) {
1193+
if (priv->bss_mode != NL80211_IFTYPE_ADHOC) {
12011194
wiphy_err(wiphy, "request to join ibss received "
12021195
"when station is not in ibss mode\n");
12031196
goto done;
@@ -1209,8 +1202,8 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
12091202
(char *) params->ssid, params->bssid);
12101203

12111204
ret = mwifiex_cfg80211_assoc(priv, params->ssid_len, params->ssid,
1212-
params->bssid, mode, params->channel, NULL,
1213-
params->privacy);
1205+
params->bssid, priv->bss_mode,
1206+
params->channel, NULL, params->privacy);
12141207
done:
12151208
priv->ibss_join_result = ret;
12161209
queue_work(priv->workqueue, &priv->cfg_workqueue);
@@ -1301,7 +1294,7 @@ mwifiex_setup_ht_caps(struct ieee80211_sta_ht_cap *ht_info,
13011294
/* Clear all the other values */
13021295
memset(&mcs[rx_mcs_supp], 0,
13031296
sizeof(struct ieee80211_mcs_info) - rx_mcs_supp);
1304-
if (priv->bss_mode == MWIFIEX_BSS_MODE_INFRA ||
1297+
if (priv->bss_mode == NL80211_IFTYPE_STATION ||
13051298
ISSUPP_CHANWIDTH40(adapter->hw_dot_11n_dev_cap))
13061299
/* Set MCS32 for infra mode or ad-hoc mode with 40MHz support */
13071300
SETHT_MCS32(mcs_set.rx_mask);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,7 @@ u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates)
288288
{
289289
u32 k = 0;
290290
struct mwifiex_adapter *adapter = priv->adapter;
291-
if (priv->bss_mode == MWIFIEX_BSS_MODE_INFRA) {
292-
/* Infra. mode */
291+
if (priv->bss_mode == NL80211_IFTYPE_STATION) {
293292
switch (adapter->config_bands) {
294293
case BAND_B:
295294
dev_dbg(adapter->dev, "info: infra band=%d "

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static int mwifiex_init_priv(struct mwifiex_private *priv)
7878
memset(priv->curr_addr, 0xff, ETH_ALEN);
7979

8080
priv->pkt_tx_ctrl = 0;
81-
priv->bss_mode = MWIFIEX_BSS_MODE_INFRA;
81+
priv->bss_mode = NL80211_IFTYPE_STATION;
8282
priv->data_rate = 0; /* Initially indicate the rate as auto */
8383
priv->is_data_rate_auto = true;
8484
priv->bcn_avg_factor = DEFAULT_BCN_AVG_FACTOR;

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ struct mwifiex_scan_resp {
6666
u8 *scan_table;
6767
};
6868

69-
enum {
70-
MWIFIEX_BSS_MODE_INFRA = 1,
71-
MWIFIEX_BSS_MODE_IBSS,
72-
MWIFIEX_BSS_MODE_AUTO
73-
};
74-
7569
#define MWIFIEX_PROMISC_MODE 1
7670
#define MWIFIEX_MULTICAST_MODE 2
7771
#define MWIFIEX_ALL_MULTI_MODE 4

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
808808

809809
/* Set the BSS mode */
810810
adhoc_start->bss_mode = HostCmd_BSS_MODE_IBSS;
811-
bss_desc->bss_mode = MWIFIEX_BSS_MODE_IBSS;
811+
bss_desc->bss_mode = NL80211_IFTYPE_ADHOC;
812812
adhoc_start->beacon_period = cpu_to_le16(priv->beacon_period);
813813
bss_desc->beacon_period = priv->beacon_period;
814814

@@ -1289,8 +1289,8 @@ int mwifiex_associate(struct mwifiex_private *priv,
12891289
u8 current_bssid[ETH_ALEN];
12901290

12911291
/* Return error if the adapter or table entry is not marked as infra */
1292-
if ((priv->bss_mode != MWIFIEX_BSS_MODE_INFRA) ||
1293-
(bss_desc->bss_mode != MWIFIEX_BSS_MODE_INFRA))
1292+
if ((priv->bss_mode != NL80211_IFTYPE_STATION) ||
1293+
(bss_desc->bss_mode != NL80211_IFTYPE_STATION))
12941294
return -1;
12951295

12961296
memcpy(&current_bssid,
@@ -1358,7 +1358,7 @@ int mwifiex_adhoc_join(struct mwifiex_private *priv,
13581358
!mwifiex_ssid_cmp(&bss_desc->ssid,
13591359
&priv->curr_bss_params.bss_descriptor.ssid) &&
13601360
(priv->curr_bss_params.bss_descriptor.bss_mode ==
1361-
MWIFIEX_BSS_MODE_IBSS)) {
1361+
NL80211_IFTYPE_ADHOC)) {
13621362
dev_dbg(priv->adapter->dev, "info: ADHOC_J_CMD: new ad-hoc SSID"
13631363
" is the same as current; not attempting to re-join\n");
13641364
return -1;
@@ -1421,9 +1421,9 @@ int mwifiex_deauthenticate(struct mwifiex_private *priv,
14211421
int ret = 0;
14221422

14231423
if (priv->media_connected) {
1424-
if (priv->bss_mode == MWIFIEX_BSS_MODE_INFRA) {
1424+
if (priv->bss_mode == NL80211_IFTYPE_STATION) {
14251425
ret = mwifiex_deauthenticate_infra(priv, wait, mac);
1426-
} else if (priv->bss_mode == MWIFIEX_BSS_MODE_IBSS) {
1426+
} else if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
14271427
ret = mwifiex_prepare_cmd(priv,
14281428
HostCmd_CMD_802_11_AD_HOC_STOP,
14291429
HostCmd_ACT_GEN_SET, 0, wait, NULL);

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ mwifiex_queuing_ra_based(struct mwifiex_private *priv)
877877
* Currently we assume if we are in Infra, then DA=RA. This might not be
878878
* true in the future
879879
*/
880-
if ((priv->bss_mode == MWIFIEX_BSS_MODE_INFRA) &&
880+
if ((priv->bss_mode == NL80211_IFTYPE_STATION) &&
881881
(GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA))
882882
return false;
883883

@@ -1003,8 +1003,6 @@ int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv,
10031003
int mwifiex_change_adhoc_chan(struct mwifiex_private *priv, int channel);
10041004
int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
10051005

1006-
int mwifiex_drv_get_mode(struct mwifiex_private *priv, u8 wait_option);
1007-
10081006
int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel);
10091007

10101008
int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
@@ -1043,9 +1041,6 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv, int type, int dbm);
10431041

10441042
int mwifiex_main_process(struct mwifiex_adapter *);
10451043

1046-
int mwifiex_bss_ioctl_mode(struct mwifiex_private *,
1047-
struct mwifiex_wait_queue *,
1048-
u16 action, int *mode);
10491044
int mwifiex_bss_ioctl_channel(struct mwifiex_private *,
10501045
u16 action,
10511046
struct mwifiex_chan_freq_power *cfp);

0 commit comments

Comments
 (0)