aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/wext.c
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 /drivers/net/wireless/libertas/wext.c
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>
Diffstat (limited to 'drivers/net/wireless/libertas/wext.c')
-rw-r--r--drivers/net/wireless/libertas/wext.c69
1 files changed, 31 insertions, 38 deletions
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