linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mac80211: make use of regulatory tx power settings on change of tx power
@ 2008-10-22 20:13 Luis R. Rodriguez
  2008-10-23  6:22 ` Johannes Berg
  0 siblings, 1 reply; 3+ messages in thread
From: Luis R. Rodriguez @ 2008-10-22 20:13 UTC (permalink / raw)
  To: johannes, johannes, linville; +Cc: Luis R. Rodriguez, linux-wireless

We do not know what max power to allow until a device is targeting
a channel, therefore only allow changing tx power if a channel is defined.
Also make use of the channel's max power setting as defined by
regulatory rules before allowing the user to use the requested power
setting. If the user asked us to figure it out we use the max allowed
by regulatory.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
---
 net/mac80211/wext.c |   18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/net/mac80211/wext.c b/net/mac80211/wext.c
index 31d2e74..c6167d2 100644
--- a/net/mac80211/wext.c
+++ b/net/mac80211/wext.c
@@ -656,6 +656,7 @@ static int ieee80211_ioctl_siwtxpower(struct net_device *dev,
 				      union iwreq_data *data, char *extra)
 {
 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
+	struct ieee80211_channel* chan = local->hw.conf.channel;
 	u32 reconf_flags = 0;
 	int new_power_level;
 
@@ -663,20 +664,13 @@ static int ieee80211_ioctl_siwtxpower(struct net_device *dev,
 		return -EINVAL;
 	if (data->txpower.flags & IW_TXPOW_RANGE)
 		return -EINVAL;
+	if (!chan)
+		return -EINVAL;
 
-	if (data->txpower.fixed) {
-		new_power_level = data->txpower.value;
-	} else {
-		/*
-		 * Automatic power level. Use maximum power for the current
-		 * channel. Should be part of rate control.
-		 */
-		struct ieee80211_channel* chan = local->hw.conf.channel;
-		if (!chan)
-			return -EINVAL;
-
+	if (data->txpower.fixed)
+		new_power_level = min(data->txpower.value, chan->max_power);
+	else /* Automatic power level setting */
 		new_power_level = chan->max_power;
-	}
 
 	if (local->hw.conf.power_level != new_power_level) {
 		local->hw.conf.power_level = new_power_level;
-- 
1.5.6.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-10-23 19:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-22 20:13 [PATCH] mac80211: make use of regulatory tx power settings on change of tx power Luis R. Rodriguez
2008-10-23  6:22 ` Johannes Berg
2008-10-23 12:03   ` Luis R. Rodriguez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).