aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi
diff options
context:
space:
mode:
authorWey-Yi Guy <wey-yi.w.guy@intel.com>2009-08-21 16:34:17 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-08-28 14:40:37 -0400
commit5eadd94bd4006aacf12052c447bcc997bf6ecd28 (patch)
tree5998d219547e16445e8eb78300de14fceeb341a6 /drivers/net/wireless/iwlwifi
parentdc1b09733215e19f6a0f676be2744fe2f5471d85 (diff)
iwlwifi: error checking for setting tx_power in sysfs
Perform error checking and report failure when setting tx power from sysfs. If fail to set the tx power, do not update the local copy, so user will not see the incorrect tx power in sysfs Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c13
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c28
2 files changed, 30 insertions, 11 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 2232b1794e76..533b393e8cf6 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -2477,10 +2477,15 @@ static ssize_t store_tx_power(struct device *d,
2477 ret = strict_strtoul(buf, 10, &val); 2477 ret = strict_strtoul(buf, 10, &val);
2478 if (ret) 2478 if (ret)
2479 IWL_INFO(priv, "%s is not in decimal form.\n", buf); 2479 IWL_INFO(priv, "%s is not in decimal form.\n", buf);
2480 else 2480 else {
2481 iwl_set_tx_power(priv, val, false); 2481 ret = iwl_set_tx_power(priv, val, false);
2482 2482 if (ret)
2483 return count; 2483 IWL_ERR(priv, "failed setting tx power (0x%d).\n",
2484 ret);
2485 else
2486 ret = count;
2487 }
2488 return ret;
2484} 2489}
2485 2490
2486static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power); 2491static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, show_tx_power, store_tx_power);
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 82dadd043b8f..c62c081cfbb7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -1701,6 +1701,8 @@ EXPORT_SYMBOL(iwl_init_drv);
1701int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) 1701int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
1702{ 1702{
1703 int ret = 0; 1703 int ret = 0;
1704 s8 prev_tx_power = priv->tx_power_user_lmt;
1705
1704 if (tx_power < IWL_TX_POWER_TARGET_POWER_MIN) { 1706 if (tx_power < IWL_TX_POWER_TARGET_POWER_MIN) {
1705 IWL_WARN(priv, "Requested user TXPOWER %d below lower limit %d.\n", 1707 IWL_WARN(priv, "Requested user TXPOWER %d below lower limit %d.\n",
1706 tx_power, 1708 tx_power,
@@ -1718,15 +1720,27 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force)
1718 if (priv->tx_power_user_lmt != tx_power) 1720 if (priv->tx_power_user_lmt != tx_power)
1719 force = true; 1721 force = true;
1720 1722
1721 priv->tx_power_user_lmt = tx_power;
1722
1723 /* if nic is not up don't send command */ 1723 /* if nic is not up don't send command */
1724 if (!iwl_is_ready_rf(priv)) 1724 if (iwl_is_ready_rf(priv)) {
1725 return ret; 1725 priv->tx_power_user_lmt = tx_power;
1726 1726 if (force && priv->cfg->ops->lib->send_tx_power)
1727 if (force && priv->cfg->ops->lib->send_tx_power) 1727 ret = priv->cfg->ops->lib->send_tx_power(priv);
1728 ret = priv->cfg->ops->lib->send_tx_power(priv); 1728 else if (!priv->cfg->ops->lib->send_tx_power)
1729 ret = -EOPNOTSUPP;
1730 /*
1731 * if fail to set tx_power, restore the orig. tx power
1732 */
1733 if (ret)
1734 priv->tx_power_user_lmt = prev_tx_power;
1735 }
1729 1736
1737 /*
1738 * Even this is an async host command, the command
1739 * will always report success from uCode
1740 * So once driver can placing the command into the queue
1741 * successfully, driver can use priv->tx_power_user_lmt
1742 * to reflect the current tx power
1743 */
1730 return ret; 1744 return ret;
1731} 1745}
1732EXPORT_SYMBOL(iwl_set_tx_power); 1746EXPORT_SYMBOL(iwl_set_tx_power);