* [PATCH V2] regdb: Generalize the mW to dBm power conversion
@ 2014-05-26 12:31 chaitanya.mgit
2014-05-27 15:31 ` John W. Linville
2014-05-27 15:57 ` Johannes Berg
0 siblings, 2 replies; 5+ messages in thread
From: chaitanya.mgit @ 2014-05-26 12:31 UTC (permalink / raw)
To: linville, mcgrof; +Cc: linux-wireless, Chaitanya T K
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 <john@x109.net>
Signed-off-by: Chaitanya T K <chaitanya.mgit@gmail.com>
---
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
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH V2] regdb: Generalize the mW to dBm power conversion
2014-05-26 12:31 [PATCH V2] regdb: Generalize the mW to dBm power conversion chaitanya.mgit
@ 2014-05-27 15:31 ` John W. Linville
2014-05-27 15:57 ` Johannes Berg
1 sibling, 0 replies; 5+ messages in thread
From: John W. Linville @ 2014-05-27 15:31 UTC (permalink / raw)
To: chaitanya.mgit; +Cc: mcgrof, linux-wireless
On Mon, May 26, 2014 at 06:01:44PM +0530, chaitanya.mgit@gmail.com wrote:
> 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 <john@x109.net>
> Signed-off-by: Chaitanya T K <chaitanya.mgit@gmail.com>
>
> ---
> 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 <linville@tuxdriver.com>
--
John W. Linville Someday the world will need a hero, and you
linville@tuxdriver.com might be all we have. Be ready.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] regdb: Generalize the mW to dBm power conversion
2014-05-26 12:31 [PATCH V2] regdb: Generalize the mW to dBm power conversion chaitanya.mgit
2014-05-27 15:31 ` John W. Linville
@ 2014-05-27 15:57 ` Johannes Berg
2014-05-27 16:11 ` Krishna Chaitanya
1 sibling, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2014-05-27 15:57 UTC (permalink / raw)
To: chaitanya.mgit; +Cc: linville, mcgrof, linux-wireless
On Mon, 2014-05-26 at 18:01 +0530, chaitanya.mgit@gmail.com wrote:
> 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 <john@x109.net>
> Signed-off-by: Chaitanya T K <chaitanya.mgit@gmail.com>
>
> ---
> 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))
This patch is wrong :-)
Bonus points for those who can figure it out without looking at the one
I'm committing ;-)
johannes
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] regdb: Generalize the mW to dBm power conversion
2014-05-27 15:57 ` Johannes Berg
@ 2014-05-27 16:11 ` Krishna Chaitanya
2014-05-27 16:42 ` Johannes Berg
0 siblings, 1 reply; 5+ messages in thread
From: Krishna Chaitanya @ 2014-05-27 16:11 UTC (permalink / raw)
To: Johannes Berg; +Cc: John Linville, Luis Rodriguez, linux-wireless
On Tue, May 27, 2014 at 9:27 PM, Johannes Berg
<johannes@sipsolutions.net> wrote:
>
> On Mon, 2014-05-26 at 18:01 +0530, chaitanya.mgit@gmail.com wrote:
> > 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 <john@x109.net>
> > Signed-off-by: Chaitanya T K <chaitanya.mgit@gmail.com>
> >
> > ---
> > 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))
>
> This patch is wrong :-)
> Bonus points for those who can figure it out without looking at the one
> I'm committing ;-)
>
Forgot to handle the print to the file. (Looked at the commit :-))
Thanks Johannes and John.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V2] regdb: Generalize the mW to dBm power conversion
2014-05-27 16:11 ` Krishna Chaitanya
@ 2014-05-27 16:42 ` Johannes Berg
0 siblings, 0 replies; 5+ messages in thread
From: Johannes Berg @ 2014-05-27 16:42 UTC (permalink / raw)
To: Krishna Chaitanya; +Cc: John Linville, Luis Rodriguez, linux-wireless
On Tue, 2014-05-27 at 21:41 +0530, Krishna Chaitanya wrote:
> On Tue, May 27, 2014 at 9:27 PM, Johannes Berg
> <johannes@sipsolutions.net> wrote:
> >
> > On Mon, 2014-05-26 at 18:01 +0530, chaitanya.mgit@gmail.com wrote:
> > > 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 <john@x109.net>
> > > Signed-off-by: Chaitanya T K <chaitanya.mgit@gmail.com>
> > >
> > > ---
> > > 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))
> >
> > This patch is wrong :-)
> > Bonus points for those who can figure it out without looking at the one
> > I'm committing ;-)
> >
> Forgot to handle the print to the file. (Looked at the commit :-))
No, the print worked - the difference is that %.0f rounds, and %d
truncates (so that for power=500 it comes out wrong for %d)
johannes
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-05-27 16:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-26 12:31 [PATCH V2] regdb: Generalize the mW to dBm power conversion chaitanya.mgit
2014-05-27 15:31 ` John W. Linville
2014-05-27 15:57 ` Johannes Berg
2014-05-27 16:11 ` Krishna Chaitanya
2014-05-27 16:42 ` Johannes Berg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.