linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]: ath9k: fix bug in tx power
@ 2010-12-02 23:24 Matteo Croce
  2010-12-02 23:31 ` Luis R. Rodriguez
  0 siblings, 1 reply; 5+ messages in thread
From: Matteo Croce @ 2010-12-02 23:24 UTC (permalink / raw)
  To: Luis R Rodriguez, John W. Linville; +Cc: ath9k-devel, linux-wireless

The ath9k driver subtracts 3 dBm to the txpower as with two radios the
signal power is doubled.
The resulting value is assigned in an u16 which overflows and makes
the card to work at full power.

Signed-off-by: Matteo Croce <matteo@openwrt.org>

--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c	2010-12-02
22:39:58.982020001 +0100
+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c	2010-12-02
23:05:43.662020001 +0100
@@ -1065,15 +1065,19 @@
 	case 1:
 		break;
 	case 2:
-		scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
+		if(scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN)
+			scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
+		else
+			scaledPower = 0;
 		break;
 	case 3:
-		scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
+		if(scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN)
+			scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
+		else
+			scaledPower = 0;
 		break;
 	}

-	scaledPower = max((u16)0, scaledPower);
-
 	if (IS_CHAN_2GHZ(chan)) {
 		numCtlModes = ARRAY_SIZE(ctlModesFor11g) -
 			SUB_NUM_CTL_MODES_AT_2G_40;


-- 
Matteo Croce
OpenWrt developer
  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 KAMIKAZE (bleeding edge) ------------------
  * 10 oz Vodka       Shake well with ice and strain
  * 10 oz Triple sec  mixture into 10 shot glasses.
  * 10 oz lime juice  Salute!
 ---------------------------------------------------

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

* Re: [PATCH]: ath9k: fix bug in tx power
  2010-12-02 23:24 [PATCH]: ath9k: fix bug in tx power Matteo Croce
@ 2010-12-02 23:31 ` Luis R. Rodriguez
  2010-12-02 23:39   ` Matteo Croce
  0 siblings, 1 reply; 5+ messages in thread
From: Luis R. Rodriguez @ 2010-12-02 23:31 UTC (permalink / raw)
  To: Matteo Croce; +Cc: John W. Linville, ath9k-devel, linux-wireless

On Thu, Dec 2, 2010 at 3:24 PM, Matteo Croce <technoboy85@gmail.com> wrote:
> The ath9k driver subtracts 3 dBm to the txpower as with two radios the
> signal power is doubled.
> The resulting value is assigned in an u16 which overflows and makes
> the card to work at full power.

Thanks for the patch Matteo, can you please reword a bit better and
resubmit by first using checkpatch.pl against the patch? The branch
should be separated by a space.

  Luis

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

* Re: [PATCH]: ath9k: fix bug in tx power
  2010-12-02 23:31 ` Luis R. Rodriguez
@ 2010-12-02 23:39   ` Matteo Croce
  2010-12-02 23:51     ` [ath9k-devel] " Luis R. Rodriguez
  0 siblings, 1 reply; 5+ messages in thread
From: Matteo Croce @ 2010-12-02 23:39 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: John W. Linville, ath9k-devel, linux-wireless

The ath9k driver subtracts 3 dBm to the txpower as with two radios the
signal power is doubled.
The resulting value is assigned in an u16 which overflows and makes
the card work at full power.

Signed-off-by: Matteo Croce <matteo@openwrt.org>

--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c	2010-12-02
22:39:58.982020001 +0100
+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c	2010-12-03
00:36:23.637799002 +0100
@@ -1065,15 +1065,19 @@
 	case 1:
 		break;
 	case 2:
-		scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
+		if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN)
+			scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
+		else
+			scaledPower = 0;
 		break;
 	case 3:
-		scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
+		if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN)
+			scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
+		else
+			scaledPower = 0;
 		break;
 	}

-	scaledPower = max((u16)0, scaledPower);
-
 	if (IS_CHAN_2GHZ(chan)) {
 		numCtlModes = ARRAY_SIZE(ctlModesFor11g) -
 			SUB_NUM_CTL_MODES_AT_2G_40;

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

* Re: [ath9k-devel] [PATCH]: ath9k: fix bug in tx power
  2010-12-02 23:39   ` Matteo Croce
@ 2010-12-02 23:51     ` Luis R. Rodriguez
  2010-12-03  1:25       ` Matteo Croce
  0 siblings, 1 reply; 5+ messages in thread
From: Luis R. Rodriguez @ 2010-12-02 23:51 UTC (permalink / raw)
  To: Matteo Croce
  Cc: Luis R. Rodriguez, ath9k-devel@lists.ath9k.org,
	linux-wireless@vger.kernel.org, John W. Linville

On Thu, Dec 02, 2010 at 03:39:49PM -0800, Matteo Croce wrote:
> The ath9k driver subtracts 3 dBm to the txpower as with two radios the
> signal power is doubled.
> The resulting value is assigned in an u16 which overflows and makes
> the card work at full power.

Sorry can you also add:

Cc: stable@kernel.org

Right above your Signed-off-by, this is a regulatory fix,
thanks.
 
  Luis
> 
> Signed-off-by: Matteo Croce <matteo@openwrt.org>
> 
> --- a/drivers/net/wireless/ath/ath9k/eeprom_def.c	2010-12-02
> 22:39:58.982020001 +0100
> +++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c	2010-12-03
> 00:36:23.637799002 +0100
> @@ -1065,15 +1065,19 @@
>  	case 1:
>  		break;
>  	case 2:
> -		scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
> +		if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN)
> +			scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
> +		else
> +			scaledPower = 0;
>  		break;
>  	case 3:
> -		scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
> +		if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN)
> +			scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
> +		else
> +			scaledPower = 0;
>  		break;
>  	}
> 
> -	scaledPower = max((u16)0, scaledPower);
> -
>  	if (IS_CHAN_2GHZ(chan)) {
>  		numCtlModes = ARRAY_SIZE(ctlModesFor11g) -
>  			SUB_NUM_CTL_MODES_AT_2G_40;
> _______________________________________________
> ath9k-devel mailing list
> ath9k-devel@lists.ath9k.org
> https://lists.ath9k.org/mailman/listinfo/ath9k-devel

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

* Re: [ath9k-devel] [PATCH]: ath9k: fix bug in tx power
  2010-12-02 23:51     ` [ath9k-devel] " Luis R. Rodriguez
@ 2010-12-03  1:25       ` Matteo Croce
  0 siblings, 0 replies; 5+ messages in thread
From: Matteo Croce @ 2010-12-03  1:25 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: Luis R. Rodriguez, ath9k-devel@lists.ath9k.org,
	linux-wireless@vger.kernel.org, John W. Linville

The ath9k driver subtracts 3 dBm to the txpower as with two radios the
signal power is doubled.
The resulting value is assigned in an u16 which overflows and makes
the card work at full power.

Cc: stable@kernel.org
Signed-off-by: Matteo Croce <matteo@openwrt.org>

--- a/drivers/net/wireless/ath/ath9k/eeprom_def.c	2010-12-02
22:39:58.982020001 +0100
+++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c	2010-12-03
00:36:23.637799002 +0100
@@ -1065,15 +1065,19 @@
 	case 1:
 		break;
 	case 2:
-		scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
+		if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN)
+			scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
+		else
+			scaledPower = 0;
 		break;
 	case 3:
-		scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
+		if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN)
+			scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
+		else
+			scaledPower = 0;
 		break;
 	}

-	scaledPower = max((u16)0, scaledPower);
-
 	if (IS_CHAN_2GHZ(chan)) {
 		numCtlModes = ARRAY_SIZE(ctlModesFor11g) -
 			SUB_NUM_CTL_MODES_AT_2G_40;

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

end of thread, other threads:[~2010-12-03  1:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-02 23:24 [PATCH]: ath9k: fix bug in tx power Matteo Croce
2010-12-02 23:31 ` Luis R. Rodriguez
2010-12-02 23:39   ` Matteo Croce
2010-12-02 23:51     ` [ath9k-devel] " Luis R. Rodriguez
2010-12-03  1:25       ` Matteo Croce

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).