aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2008-08-21 17:51:07 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-08-29 16:24:07 -0400
commitd5db2dfa660de13c3643149b89c7602dd49aa168 (patch)
treec2dbf5cbd27a83c73cba68f4285d1e51024d168f
parent191bb40e725304c5fcfabd92c57eef58799f0e25 (diff)
libertas: convert CMD_802_11_RADIO_CONTROL to a direct command
and return errors for operations like join & scan that aren't possible when the radio is turned off. Signed-off-by: Dan Williams <dcbw@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/libertas/assoc.c57
-rw-r--r--drivers/net/wireless/libertas/cmd.c46
-rw-r--r--drivers/net/wireless/libertas/cmd.h2
-rw-r--r--drivers/net/wireless/libertas/decl.h1
-rw-r--r--drivers/net/wireless/libertas/dev.h3
-rw-r--r--drivers/net/wireless/libertas/host.h15
-rw-r--r--drivers/net/wireless/libertas/main.c2
-rw-r--r--drivers/net/wireless/libertas/scan.c5
-rw-r--r--drivers/net/wireless/libertas/wext.c69
9 files changed, 100 insertions, 100 deletions
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 5072a8917fd9..d47e4d5734cd 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -25,7 +25,7 @@ static const u8 bssid_off[ETH_ALEN] __attribute__ ((aligned (2))) =
25 * @brief Associate to a specific BSS discovered in a scan 25 * @brief Associate to a specific BSS discovered in a scan
26 * 26 *
27 * @param priv A pointer to struct lbs_private structure 27 * @param priv A pointer to struct lbs_private structure
28 * @param pbssdesc Pointer to the BSS descriptor to associate with. 28 * @param assoc_req The association request describing the BSS to associate with
29 * 29 *
30 * @return 0-success, otherwise fail 30 * @return 0-success, otherwise fail
31 */ 31 */
@@ -33,29 +33,29 @@ static int lbs_associate(struct lbs_private *priv,
33 struct assoc_request *assoc_req) 33 struct assoc_request *assoc_req)
34{ 34{
35 int ret; 35 int ret;
36 u8 preamble = RADIO_PREAMBLE_LONG;
36 37
37 lbs_deb_enter(LBS_DEB_ASSOC); 38 lbs_deb_enter(LBS_DEB_ASSOC);
38 39
39 ret = lbs_prepare_and_send_command(priv, CMD_802_11_AUTHENTICATE, 40 ret = lbs_prepare_and_send_command(priv, CMD_802_11_AUTHENTICATE,
40 0, CMD_OPTION_WAITFORRSP, 41 0, CMD_OPTION_WAITFORRSP,
41 0, assoc_req->bss.bssid); 42 0, assoc_req->bss.bssid);
42
43 if (ret) 43 if (ret)
44 goto done; 44 goto out;
45 45
46 /* set preamble to firmware */ 46 /* Use short preamble only when both the BSS and firmware support it */
47 if ((priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) && 47 if ((priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) &&
48 (assoc_req->bss.capability & WLAN_CAPABILITY_SHORT_PREAMBLE)) 48 (assoc_req->bss.capability & WLAN_CAPABILITY_SHORT_PREAMBLE))
49 priv->preamble = CMD_TYPE_SHORT_PREAMBLE; 49 preamble = RADIO_PREAMBLE_SHORT;
50 else
51 priv->preamble = CMD_TYPE_LONG_PREAMBLE;
52 50
53 lbs_set_radio_control(priv); 51 ret = lbs_set_radio(priv, preamble, 1);
52 if (ret)
53 goto out;
54 54
55 ret = lbs_prepare_and_send_command(priv, CMD_802_11_ASSOCIATE, 55 ret = lbs_prepare_and_send_command(priv, CMD_802_11_ASSOCIATE,
56 0, CMD_OPTION_WAITFORRSP, 0, assoc_req); 56 0, CMD_OPTION_WAITFORRSP, 0, assoc_req);
57 57
58done: 58out:
59 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 59 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
60 return ret; 60 return ret;
61} 61}
@@ -64,8 +64,7 @@ done:
64 * @brief Join an adhoc network found in a previous scan 64 * @brief Join an adhoc network found in a previous scan
65 * 65 *
66 * @param priv A pointer to struct lbs_private structure 66 * @param priv A pointer to struct lbs_private structure
67 * @param pbssdesc Pointer to a BSS descriptor found in a previous scan 67 * @param assoc_req The association request describing the BSS to join
68 * to attempt to join
69 * 68 *
70 * @return 0--success, -1--fail 69 * @return 0--success, -1--fail
71 */ 70 */
@@ -74,6 +73,9 @@ static int lbs_join_adhoc_network(struct lbs_private *priv,
74{ 73{
75 struct bss_descriptor *bss = &assoc_req->bss; 74 struct bss_descriptor *bss = &assoc_req->bss;
76 int ret = 0; 75 int ret = 0;
76 u8 preamble = RADIO_PREAMBLE_LONG;
77
78 lbs_deb_enter(LBS_DEB_ASSOC);
77 79
78 lbs_deb_join("current SSID '%s', ssid length %u\n", 80 lbs_deb_join("current SSID '%s', ssid length %u\n",
79 escape_essid(priv->curbssparams.ssid, 81 escape_essid(priv->curbssparams.ssid,
@@ -106,18 +108,16 @@ static int lbs_join_adhoc_network(struct lbs_private *priv,
106 goto out; 108 goto out;
107 } 109 }
108 110
109 /* Use shortpreamble only when both creator and card supports 111 /* Use short preamble only when both the BSS and firmware support it */
110 short preamble */ 112 if ((priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) &&
111 if (!(bss->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) || 113 (bss->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)) {
112 !(priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)) {
113 lbs_deb_join("AdhocJoin: Long preamble\n");
114 priv->preamble = CMD_TYPE_LONG_PREAMBLE;
115 } else {
116 lbs_deb_join("AdhocJoin: Short preamble\n"); 114 lbs_deb_join("AdhocJoin: Short preamble\n");
117 priv->preamble = CMD_TYPE_SHORT_PREAMBLE; 115 preamble = RADIO_PREAMBLE_SHORT;
118 } 116 }
119 117
120 lbs_set_radio_control(priv); 118 ret = lbs_set_radio(priv, preamble, 1);
119 if (ret)
120 goto out;
121 121
122 lbs_deb_join("AdhocJoin: channel = %d\n", assoc_req->channel); 122 lbs_deb_join("AdhocJoin: channel = %d\n", assoc_req->channel);
123 lbs_deb_join("AdhocJoin: band = %c\n", assoc_req->band); 123 lbs_deb_join("AdhocJoin: band = %c\n", assoc_req->band);
@@ -129,6 +129,7 @@ static int lbs_join_adhoc_network(struct lbs_private *priv,
129 OID_802_11_SSID, assoc_req); 129 OID_802_11_SSID, assoc_req);
130 130
131out: 131out:
132 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
132 return ret; 133 return ret;
133} 134}
134 135
@@ -136,25 +137,27 @@ out:
136 * @brief Start an Adhoc Network 137 * @brief Start an Adhoc Network
137 * 138 *
138 * @param priv A pointer to struct lbs_private structure 139 * @param priv A pointer to struct lbs_private structure
139 * @param adhocssid The ssid of the Adhoc Network 140 * @param assoc_req The association request describing the BSS to start
140 * @return 0--success, -1--fail 141 * @return 0--success, -1--fail
141 */ 142 */
142static int lbs_start_adhoc_network(struct lbs_private *priv, 143static int lbs_start_adhoc_network(struct lbs_private *priv,
143 struct assoc_request *assoc_req) 144 struct assoc_request *assoc_req)
144{ 145{
145 int ret = 0; 146 int ret = 0;
147 u8 preamble = RADIO_PREAMBLE_LONG;
148
149 lbs_deb_enter(LBS_DEB_ASSOC);
146 150
147 priv->adhoccreate = 1; 151 priv->adhoccreate = 1;
148 152
149 if (priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) { 153 if (priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) {
150 lbs_deb_join("AdhocStart: Short preamble\n"); 154 lbs_deb_join("AdhocStart: Short preamble\n");
151 priv->preamble = CMD_TYPE_SHORT_PREAMBLE; 155 preamble = RADIO_PREAMBLE_SHORT;
152 } else {
153 lbs_deb_join("AdhocStart: Long preamble\n");
154 priv->preamble = CMD_TYPE_LONG_PREAMBLE;
155 } 156 }
156 157
157 lbs_set_radio_control(priv); 158 ret = lbs_set_radio(priv, preamble, 1);
159 if (ret)
160 goto out;
158 161
159 lbs_deb_join("AdhocStart: channel = %d\n", assoc_req->channel); 162 lbs_deb_join("AdhocStart: channel = %d\n", assoc_req->channel);
160 lbs_deb_join("AdhocStart: band = %d\n", assoc_req->band); 163 lbs_deb_join("AdhocStart: band = %d\n", assoc_req->band);
@@ -162,6 +165,8 @@ static int lbs_start_adhoc_network(struct lbs_private *priv,
162 ret = lbs_prepare_and_send_command(priv, CMD_802_11_AD_HOC_START, 165 ret = lbs_prepare_and_send_command(priv, CMD_802_11_AD_HOC_START,
163 0, CMD_OPTION_WAITFORRSP, 0, assoc_req); 166 0, CMD_OPTION_WAITFORRSP, 0, assoc_req);
164 167
168out:
169 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
165 return ret; 170 return ret;
166} 171}
167 172
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 8364a2f71b51..f3073a5a954a 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -1289,41 +1289,47 @@ void lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd,
1289 priv->cur_cmd = NULL; 1289 priv->cur_cmd = NULL;
1290} 1290}
1291 1291
1292int lbs_set_radio_control(struct lbs_private *priv) 1292int lbs_set_radio(struct lbs_private *priv, u8 preamble, u8 radio_on)
1293{ 1293{
1294 int ret = 0;
1295 struct cmd_ds_802_11_radio_control cmd; 1294 struct cmd_ds_802_11_radio_control cmd;
1295 int ret = -EINVAL;
1296 1296
1297 lbs_deb_enter(LBS_DEB_CMD); 1297 lbs_deb_enter(LBS_DEB_CMD);
1298 1298
1299 cmd.hdr.size = cpu_to_le16(sizeof(cmd)); 1299 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
1300 cmd.action = cpu_to_le16(CMD_ACT_SET); 1300 cmd.action = cpu_to_le16(CMD_ACT_SET);
1301 1301
1302 switch (priv->preamble) { 1302 /* Only v8 and below support setting the preamble */
1303 case CMD_TYPE_SHORT_PREAMBLE: 1303 if (priv->fwrelease < 0x09000000) {
1304 cmd.control = cpu_to_le16(SET_SHORT_PREAMBLE); 1304 switch (preamble) {
1305 break; 1305 case RADIO_PREAMBLE_SHORT:
1306 1306 if (!(priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE))
1307 case CMD_TYPE_LONG_PREAMBLE: 1307 goto out;
1308 cmd.control = cpu_to_le16(SET_LONG_PREAMBLE); 1308 /* Fall through */
1309 break; 1309 case RADIO_PREAMBLE_AUTO:
1310 case RADIO_PREAMBLE_LONG:
1311 cmd.control = cpu_to_le16(preamble);
1312 break;
1313 default:
1314 goto out;
1315 }
1316 }
1310 1317
1311 case CMD_TYPE_AUTO_PREAMBLE: 1318 if (radio_on)
1312 default: 1319 cmd.control |= cpu_to_le16(0x1);
1313 cmd.control = cpu_to_le16(SET_AUTO_PREAMBLE); 1320 else {
1314 break; 1321 cmd.control &= cpu_to_le16(~0x1);
1322 priv->txpower_cur = 0;
1315 } 1323 }
1316 1324
1317 if (priv->radioon) 1325 lbs_deb_cmd("RADIO_CONTROL: radio %s, preamble %d\n",
1318 cmd.control |= cpu_to_le16(TURN_ON_RF); 1326 radio_on ? "ON" : "OFF", preamble);
1319 else
1320 cmd.control &= cpu_to_le16(~TURN_ON_RF);
1321 1327
1322 lbs_deb_cmd("RADIO_SET: radio %d, preamble %d\n", priv->radioon, 1328 priv->radio_on = radio_on;
1323 priv->preamble);
1324 1329
1325 ret = lbs_cmd_with_response(priv, CMD_802_11_RADIO_CONTROL, &cmd); 1330 ret = lbs_cmd_with_response(priv, CMD_802_11_RADIO_CONTROL, &cmd);
1326 1331
1332out:
1327 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); 1333 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
1328 return ret; 1334 return ret;
1329} 1335}
diff --git a/drivers/net/wireless/libertas/cmd.h b/drivers/net/wireless/libertas/cmd.h
index 6fba8ef7d09a..11ac996e895e 100644
--- a/drivers/net/wireless/libertas/cmd.h
+++ b/drivers/net/wireless/libertas/cmd.h
@@ -65,4 +65,6 @@ int lbs_get_tx_power(struct lbs_private *priv, s16 *curlevel, s16 *minlevel,
65 s16 *maxlevel); 65 s16 *maxlevel);
66int lbs_set_tx_power(struct lbs_private *priv, s16 dbm); 66int lbs_set_tx_power(struct lbs_private *priv, s16 dbm);
67 67
68int lbs_set_radio(struct lbs_private *priv, u8 preamble, u8 radio_on);
69
68#endif /* _LBS_CMD_H */ 70#endif /* _LBS_CMD_H */
diff --git a/drivers/net/wireless/libertas/decl.h b/drivers/net/wireless/libertas/decl.h
index a8ac974dacac..1a8888cceadc 100644
--- a/drivers/net/wireless/libertas/decl.h
+++ b/drivers/net/wireless/libertas/decl.h
@@ -34,7 +34,6 @@ int lbs_process_event(struct lbs_private *priv, u32 event);
34void lbs_queue_event(struct lbs_private *priv, u32 event); 34void lbs_queue_event(struct lbs_private *priv, u32 event);
35void lbs_notify_command_response(struct lbs_private *priv, u8 resp_idx); 35void lbs_notify_command_response(struct lbs_private *priv, u8 resp_idx);
36 36
37int lbs_set_radio_control(struct lbs_private *priv);
38u32 lbs_fw_index_to_data_rate(u8 index); 37u32 lbs_fw_index_to_data_rate(u8 index);
39u8 lbs_data_rate_to_fw_index(u32 rate); 38u8 lbs_data_rate_to_fw_index(u32 rate);
40 39
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index 560d4d3db66b..fd59e1816460 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -293,8 +293,7 @@ struct lbs_private {
293 u16 nextSNRNF; 293 u16 nextSNRNF;
294 u16 numSNRNF; 294 u16 numSNRNF;
295 295
296 u8 radioon; 296 u8 radio_on;
297 u32 preamble;
298 297
299 /** data rate stuff */ 298 /** data rate stuff */
300 u8 cur_rate; 299 u8 cur_rate;
diff --git a/drivers/net/wireless/libertas/host.h b/drivers/net/wireless/libertas/host.h
index caebb9b5715b..da618fc997ce 100644
--- a/drivers/net/wireless/libertas/host.h
+++ b/drivers/net/wireless/libertas/host.h
@@ -152,11 +152,6 @@
152#define CMD_ACT_MAC_ALL_MULTICAST_ENABLE 0x0100 152#define CMD_ACT_MAC_ALL_MULTICAST_ENABLE 0x0100
153#define CMD_ACT_MAC_STRICT_PROTECTION_ENABLE 0x0400 153#define CMD_ACT_MAC_STRICT_PROTECTION_ENABLE 0x0400
154 154
155/* Define action or option for CMD_802_11_RADIO_CONTROL */
156#define CMD_TYPE_AUTO_PREAMBLE 0x0001
157#define CMD_TYPE_SHORT_PREAMBLE 0x0002
158#define CMD_TYPE_LONG_PREAMBLE 0x0003
159
160/* Event flags for CMD_802_11_SUBSCRIBE_EVENT */ 155/* Event flags for CMD_802_11_SUBSCRIBE_EVENT */
161#define CMD_SUBSCRIBE_RSSI_LOW 0x0001 156#define CMD_SUBSCRIBE_RSSI_LOW 0x0001
162#define CMD_SUBSCRIBE_SNR_LOW 0x0002 157#define CMD_SUBSCRIBE_SNR_LOW 0x0002
@@ -165,13 +160,9 @@
165#define CMD_SUBSCRIBE_RSSI_HIGH 0x0010 160#define CMD_SUBSCRIBE_RSSI_HIGH 0x0010
166#define CMD_SUBSCRIBE_SNR_HIGH 0x0020 161#define CMD_SUBSCRIBE_SNR_HIGH 0x0020
167 162
168#define TURN_ON_RF 0x01 163#define RADIO_PREAMBLE_LONG 0x00
169#define RADIO_ON 0x01 164#define RADIO_PREAMBLE_SHORT 0x02
170#define RADIO_OFF 0x00 165#define RADIO_PREAMBLE_AUTO 0x04
171
172#define SET_AUTO_PREAMBLE 0x05
173#define SET_SHORT_PREAMBLE 0x03
174#define SET_LONG_PREAMBLE 0x01
175 166
176/* Define action or option for CMD_802_11_RF_CHANNEL */ 167/* Define action or option for CMD_802_11_RF_CHANNEL */
177#define CMD_OPT_802_11_RF_CHANNEL_GET 0x00 168#define CMD_OPT_802_11_RF_CHANNEL_GET 0x00
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 5e4c4e41098a..dafe62e9d3e7 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -1051,7 +1051,7 @@ static int lbs_init_adapter(struct lbs_private *priv)
1051 priv->mode = IW_MODE_INFRA; 1051 priv->mode = IW_MODE_INFRA;
1052 priv->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL; 1052 priv->curbssparams.channel = DEFAULT_AD_HOC_CHANNEL;
1053 priv->mac_control = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON; 1053 priv->mac_control = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON;
1054 priv->radioon = RADIO_ON; 1054 priv->radio_on = 1;
1055 priv->enablehwauto = 1; 1055 priv->enablehwauto = 1;
1056 priv->capability = WLAN_CAPABILITY_SHORT_PREAMBLE; 1056 priv->capability = WLAN_CAPABILITY_SHORT_PREAMBLE;
1057 priv->psmode = LBS802_11POWERMODECAM; 1057 priv->psmode = LBS802_11POWERMODECAM;
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index 4b274562f965..8f66903641b9 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -944,6 +944,11 @@ int lbs_set_scan(struct net_device *dev, struct iw_request_info *info,
944 944
945 lbs_deb_enter(LBS_DEB_WEXT); 945 lbs_deb_enter(LBS_DEB_WEXT);
946 946
947 if (!priv->radio_on) {
948 ret = -EINVAL;
949 goto out;
950 }
951
947 if (!netif_running(dev)) { 952 if (!netif_running(dev)) {
948 ret = -ENETDOWN; 953 ret = -ENETDOWN;
949 goto out; 954 goto out;
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 38295ee1a05f..4307090f4eff 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -120,34 +120,6 @@ static struct chan_freq_power *find_cfp_by_band_and_freq(
120 return cfp; 120 return cfp;
121} 121}
122 122
123
124/**
125 * @brief Set Radio On/OFF
126 *
127 * @param priv A pointer to struct lbs_private structure
128 * @option Radio Option
129 * @return 0 --success, otherwise fail
130 */
131static int lbs_radio_ioctl(struct lbs_private *priv, u8 option)
132{
133 int ret = 0;
134
135 lbs_deb_enter(LBS_DEB_WEXT);
136
137 if (priv->radioon != option) {
138 lbs_deb_wext("switching radio %s\n", option ? "on" : "off");
139 priv->radioon = option;
140
141 ret = lbs_prepare_and_send_command(priv,
142 CMD_802_11_RADIO_CONTROL,
143 CMD_ACT_SET,
144 CMD_OPTION_WAITFORRSP, 0, NULL);
145 }
146
147 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
148 return ret;
149}
150
151/** 123/**
152 * @brief Copy active data rates based on adapter mode and status 124 * @brief Copy active data rates based on adapter mode and status
153 * 125 *
@@ -420,26 +392,30 @@ static int lbs_get_txpow(struct net_device *dev,
420 struct iw_request_info *info, 392 struct iw_request_info *info,
421 struct iw_param *vwrq, char *extra) 393 struct iw_param *vwrq, char *extra)
422{ 394{
423 int ret = 0;
424 struct lbs_private *priv = dev->priv; 395 struct lbs_private *priv = dev->priv;
425 s16 curlevel = 0; 396 s16 curlevel = 0;
397 int ret = 0;
426 398
427 lbs_deb_enter(LBS_DEB_WEXT); 399 lbs_deb_enter(LBS_DEB_WEXT);
428 400
401 if (!priv->radio_on) {
402 lbs_deb_wext("tx power off\n");
403 vwrq->value = 0;
404 vwrq->disabled = 1;
405 goto out;
406 }
407
429 ret = lbs_get_tx_power(priv, &curlevel, NULL, NULL); 408 ret = lbs_get_tx_power(priv, &curlevel, NULL, NULL);
430 if (ret) 409 if (ret)
431 goto out; 410 goto out;
432 411
433 lbs_deb_wext("tx power level %d dbm\n", curlevel); 412 lbs_deb_wext("tx power level %d dbm\n", curlevel);
434
435 priv->txpower_cur = curlevel; 413 priv->txpower_cur = curlevel;
414
436 vwrq->value = curlevel; 415 vwrq->value = curlevel;
437 vwrq->fixed = 1; 416 vwrq->fixed = 1;
438 if (priv->radioon) { 417 vwrq->disabled = 0;
439 vwrq->disabled = 0; 418 vwrq->flags = IW_TXPOW_DBM;
440 vwrq->flags = IW_TXPOW_DBM;
441 } else
442 vwrq->disabled = 1;
443 419
444out: 420out:
445 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 421 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
@@ -1839,13 +1815,12 @@ static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
1839 lbs_deb_enter(LBS_DEB_WEXT); 1815 lbs_deb_enter(LBS_DEB_WEXT);
1840 1816
1841 if (vwrq->disabled) { 1817 if (vwrq->disabled) {
1842 lbs_radio_ioctl(priv, RADIO_OFF); 1818 lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 0);
1843 goto out; 1819 goto out;
1844 } 1820 }
1845 1821
1846 if (vwrq->fixed == 0) { 1822 if (vwrq->fixed == 0) {
1847 /* Auto power control */ 1823 /* Auto power control */
1848 priv->preamble = CMD_TYPE_AUTO_PREAMBLE;
1849 dbm = priv->txpower_max; 1824 dbm = priv->txpower_max;
1850 } else { 1825 } else {
1851 /* Userspace check in iwrange if it should use dBm or mW, 1826 /* Userspace check in iwrange if it should use dBm or mW,
@@ -1867,7 +1842,12 @@ static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
1867 } 1842 }
1868 } 1843 }
1869 1844
1870 lbs_radio_ioctl(priv, RADIO_ON); 1845 /* If the radio was off, turn it on */
1846 if (!priv->radio_on) {
1847 ret = lbs_set_radio(priv, RADIO_PREAMBLE_AUTO, 1);
1848 if (ret)
1849 goto out;
1850 }
1871 1851
1872 lbs_deb_wext("txpower set %d dBm\n", dbm); 1852 lbs_deb_wext("txpower set %d dBm\n", dbm);
1873 1853
@@ -1925,6 +1905,11 @@ static int lbs_set_essid(struct net_device *dev, struct iw_request_info *info,
1925 1905
1926 lbs_deb_enter(LBS_DEB_WEXT); 1906 lbs_deb_enter(LBS_DEB_WEXT);
1927 1907
1908 if (!priv->radio_on) {
1909 ret = -EINVAL;
1910 goto out;
1911 }
1912
1928 /* Check the size of the string */ 1913 /* Check the size of the string */
1929 if (in_ssid_len > IW_ESSID_MAX_SIZE) { 1914 if (in_ssid_len > IW_ESSID_MAX_SIZE) {
1930 ret = -E2BIG; 1915 ret = -E2BIG;
@@ -2002,6 +1987,11 @@ static int lbs_mesh_set_essid(struct net_device *dev,
2002 1987
2003 lbs_deb_enter(LBS_DEB_WEXT); 1988 lbs_deb_enter(LBS_DEB_WEXT);
2004 1989
1990 if (!priv->radio_on) {
1991 ret = -EINVAL;
1992 goto out;
1993 }
1994
2005 /* Check the size of the string */ 1995 /* Check the size of the string */
2006 if (dwrq->length > IW_ESSID_MAX_SIZE) { 1996 if (dwrq->length > IW_ESSID_MAX_SIZE) {
2007 ret = -E2BIG; 1997 ret = -E2BIG;
@@ -2043,6 +2033,9 @@ static int lbs_set_wap(struct net_device *dev, struct iw_request_info *info,
2043 2033
2044 lbs_deb_enter(LBS_DEB_WEXT); 2034 lbs_deb_enter(LBS_DEB_WEXT);
2045 2035
2036 if (!priv->radio_on)
2037 return -EINVAL;
2038
2046 if (awrq->sa_family != ARPHRD_ETHER) 2039 if (awrq->sa_family != ARPHRD_ETHER)
2047 return -EINVAL; 2040 return -EINVAL;
2048 2041