aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/wext.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2008-08-19 15:15:35 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-08-29 16:24:06 -0400
commit87c8c72d532f96257162f978d5945dcf7f0df19e (patch)
tree71f270c1844e74ba41a6fe347e53f035db923e7d /drivers/net/wireless/libertas/wext.c
parent095f695cbb07281682462da0618fffabb499d0be (diff)
libertas: convert CMD_802_11_RF_TX_POWER to a direct command
And while we're at it, grab min/max TX power from the firmware and use that to validate incoming TX power requests from WEXT. 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.c83
1 files changed, 39 insertions, 44 deletions
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 8b3ed77860b3..10a806666001 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -422,26 +422,24 @@ static int lbs_get_txpow(struct net_device *dev,
422{ 422{
423 int ret = 0; 423 int ret = 0;
424 struct lbs_private *priv = dev->priv; 424 struct lbs_private *priv = dev->priv;
425 s16 curlevel = 0;
425 426
426 lbs_deb_enter(LBS_DEB_WEXT); 427 lbs_deb_enter(LBS_DEB_WEXT);
427 428
428 ret = lbs_prepare_and_send_command(priv, 429 ret = lbs_get_tx_power(priv, &curlevel, NULL, NULL);
429 CMD_802_11_RF_TX_POWER,
430 CMD_ACT_TX_POWER_OPT_GET,
431 CMD_OPTION_WAITFORRSP, 0, NULL);
432
433 if (ret) 430 if (ret)
434 goto out; 431 goto out;
435 432
436 lbs_deb_wext("tx power level %d dbm\n", priv->txpowerlevel); 433 lbs_deb_wext("tx power level %d dbm\n", curlevel);
437 vwrq->value = priv->txpowerlevel; 434
435 priv->txpower_cur = curlevel;
436 vwrq->value = curlevel;
438 vwrq->fixed = 1; 437 vwrq->fixed = 1;
439 if (priv->radioon) { 438 if (priv->radioon) {
440 vwrq->disabled = 0; 439 vwrq->disabled = 0;
441 vwrq->flags = IW_TXPOW_DBM; 440 vwrq->flags = IW_TXPOW_DBM;
442 } else { 441 } else
443 vwrq->disabled = 1; 442 vwrq->disabled = 1;
444 }
445 443
446out: 444out:
447 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 445 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
@@ -693,22 +691,12 @@ static int lbs_get_range(struct net_device *dev, struct iw_request_info *info,
693 691
694 range->sensitivity = 0; 692 range->sensitivity = 0;
695 693
696 /* 694 /* Setup the supported power level ranges */
697 * Setup the supported power level ranges
698 */
699 memset(range->txpower, 0, sizeof(range->txpower)); 695 memset(range->txpower, 0, sizeof(range->txpower));
700 range->txpower[0] = 5; 696 range->txpower_capa = IW_TXPOW_DBM | IW_TXPOW_RANGE;
701 range->txpower[1] = 7; 697 range->txpower[0] = priv->txpower_min;
702 range->txpower[2] = 9; 698 range->txpower[1] = priv->txpower_max;
703 range->txpower[3] = 11; 699 range->num_txpower = 2;
704 range->txpower[4] = 13;
705 range->txpower[5] = 15;
706 range->txpower[6] = 17;
707 range->txpower[7] = 19;
708
709 range->num_txpower = 8;
710 range->txpower_capa = IW_TXPOW_DBM;
711 range->txpower_capa |= IW_TXPOW_RANGE;
712 700
713 range->event_capa[0] = (IW_EVENT_CAPA_K_0 | 701 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
714 IW_EVENT_CAPA_MASK(SIOCGIWAP) | 702 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
@@ -1844,39 +1832,46 @@ static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
1844{ 1832{
1845 int ret = 0; 1833 int ret = 0;
1846 struct lbs_private *priv = dev->priv; 1834 struct lbs_private *priv = dev->priv;
1847 1835 s16 dbm = (s16) vwrq->value;
1848 u16 dbm;
1849 1836
1850 lbs_deb_enter(LBS_DEB_WEXT); 1837 lbs_deb_enter(LBS_DEB_WEXT);
1851 1838
1852 if (vwrq->disabled) { 1839 if (vwrq->disabled) {
1853 lbs_radio_ioctl(priv, RADIO_OFF); 1840 lbs_radio_ioctl(priv, RADIO_OFF);
1854 return 0; 1841 goto out;
1855 } 1842 }
1856 1843
1857 priv->preamble = CMD_TYPE_AUTO_PREAMBLE; 1844 if (vwrq->fixed == 0) {
1858 1845 /* Auto power control */
1859 lbs_radio_ioctl(priv, RADIO_ON); 1846 priv->preamble = CMD_TYPE_AUTO_PREAMBLE;
1847 dbm = priv->txpower_max;
1848 } else {
1849 /* Userspace check in iwrange if it should use dBm or mW,
1850 * therefore this should never happen... Jean II */
1851 if ((vwrq->flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) {
1852 ret = -EOPNOTSUPP;
1853 goto out;
1854 }
1860 1855
1861 /* Userspace check in iwrange if it should use dBm or mW, 1856 /* Validate requested power level against firmware allowed levels */
1862 * therefore this should never happen... Jean II */ 1857 if (priv->txpower_min && (dbm < priv->txpower_min)) {
1863 if ((vwrq->flags & IW_TXPOW_TYPE) == IW_TXPOW_MWATT) { 1858 ret = -EINVAL;
1864 return -EOPNOTSUPP; 1859 goto out;
1865 } else 1860 }
1866 dbm = (u16) vwrq->value;
1867 1861
1868 /* auto tx power control */ 1862 if (priv->txpower_max && (dbm > priv->txpower_max)) {
1863 ret = -EINVAL;
1864 goto out;
1865 }
1866 }
1869 1867
1870 if (vwrq->fixed == 0) 1868 lbs_radio_ioctl(priv, RADIO_ON);
1871 dbm = 0xffff;
1872 1869
1873 lbs_deb_wext("txpower set %d dbm\n", dbm); 1870 lbs_deb_wext("txpower set %d dBm\n", dbm);
1874 1871
1875 ret = lbs_prepare_and_send_command(priv, 1872 ret = lbs_set_tx_power(priv, dbm);
1876 CMD_802_11_RF_TX_POWER,
1877 CMD_ACT_TX_POWER_OPT_SET_LOW,
1878 CMD_OPTION_WAITFORRSP, 0, (void *)&dbm);
1879 1873
1874out:
1880 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); 1875 lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret);
1881 return ret; 1876 return ret;
1882} 1877}