Thread (5 messages) 5 messages, 3 authors, 2014-05-27

Re: [PATCH V2] regdb: Generalize the mW to dBm power conversion

From: John W. Linville <hidden>
Date: 2014-05-27 15:45:09

On Mon, May 26, 2014 at 06:01:44PM +0530, chaitanya.mgit@gmail.com wrote:
quoted hunk ↗ jump to hunk
Generalize the power conversion from mW to dBm 
using log. This should fix the below compilation
error for country NO which adds a new power value
2000mW which is not handled earlier.

 CC [M]  net/wireless/wext-sme.o
 CC [M]  net/wireless/regdb.o
net/wireless/regdb.c:1130:1: error: Unknown undeclared here (not in
a function)
net/wireless/regdb.c:1130:9: error: expected } before power
make[2]: *** [net/wireless/regdb.o] Error 1
make[1]: *** [net/wireless] Error 2
make: *** [net] Error 2

Reported-By:  John Walker <redacted>
Signed-off-by: Chaitanya T K <redacted>

---
 net/wireless/genregdb.awk |   12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/net/wireless/genregdb.awk b/net/wireless/genregdb.awk
index 4119833..949ee38 100644
--- a/net/wireless/genregdb.awk
+++ b/net/wireless/genregdb.awk
@@ -68,17 +68,7 @@ function parse_reg_rule()
 	sub(/,/, "", units)
 	dfs_cac = $9
 	if (units == "mW") {
-		if (power == 100) {
-			power = 20
-		} else if (power == 200) {
-			power = 23
-		} else if (power == 500) {
-			power = 27
-		} else if (power == 1000) {
-			power = 30
-		} else {
-			print "Unknown power value in database!"
-		}
+		power = 10 * (log(power)/log(10))
 	} else {
 		dfs_cac = $8
 	}
I'm not fond of the unnecessary parenthesis.  But otherwise it seems great.

Acked-by: John W. Linville <redacted>

-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help