linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] wireless: fix usage of freq_reg_info()
@ 2013-10-29 18:34 Luis R. Rodriguez
  2013-10-29 18:34 ` [PATCH 1/3] ath: " Luis R. Rodriguez
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Luis R. Rodriguez @ 2013-10-29 18:34 UTC (permalink / raw)
  To: linville, johannes; +Cc: linux-wireless, Luis R. Rodriguez

Mihir reported freq_reg_info() was being used incorrectly on
ath/regd.c, I spotted this was true for years, and given that
a few vendors copied the same behaviour it meant other drivers
also had this broken. This fixes this issue accross 3 drivers.

These patches depend on the no-ir patches, and depending
on what tree that goes in this may be desirable to be merged
there.

The fix is represented with the Coccinelle SmPL grammar:

@@
struct ieee80211_channel *ch;
struct wiphy *wiphy;
const struct ieee80211_reg_rule *rule;
@@

-rule = freq_reg_info(wiphy, ch->center_freq);
+rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));

Luis R. Rodriguez (3):
  ath: fix usage of freq_reg_info()
  brcm80211: fix usage of freq_reg_info()
  rtlwifi: fix usage of freq_reg_info()

 drivers/net/wireless/ath/regd.c                   | 2 +-
 drivers/net/wireless/brcm80211/brcmsmac/channel.c | 3 ++-
 drivers/net/wireless/rtlwifi/regd.c               | 7 ++++---
 3 files changed, 7 insertions(+), 5 deletions(-)

-- 
1.8.4.rc3


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

* [PATCH 1/3] ath: fix usage of freq_reg_info()
  2013-10-29 18:34 [PATCH 0/3] wireless: fix usage of freq_reg_info() Luis R. Rodriguez
@ 2013-10-29 18:34 ` Luis R. Rodriguez
  2013-10-29 18:34 ` [PATCH 2/3] brcm80211: " Luis R. Rodriguez
  2013-10-29 18:34 ` [PATCH 3/3] rtlwifi: " Luis R. Rodriguez
  2 siblings, 0 replies; 6+ messages in thread
From: Luis R. Rodriguez @ 2013-10-29 18:34 UTC (permalink / raw)
  To: linville, johannes
  Cc: linux-wireless, Luis R. Rodriguez, Julia Lawall,
	Peter Senna Tschudin

freq_reg_info() expects KHz and not MHz, fix this. In
this case we'll now be getting the no-ir flags cleared
on channels for any channel when the country IE trusts
that channel.

@@
struct ieee80211_channel *ch;
struct wiphy *wiphy;
const struct ieee80211_reg_rule *rule;
@@

-rule = freq_reg_info(wiphy, ch->center_freq);
+rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));

Generated-by: Coccinelle SmPL
Cc: Julia Lawall <julia.lawall@lip6.fr>
Cc: Peter Senna Tschudin <peter.senna@gmail.com>
Reported-by: Mihir Shete <smihir@qti.qualcomm.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 drivers/net/wireless/ath/regd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
index a258283..bc9ba78 100644
--- a/drivers/net/wireless/ath/regd.c
+++ b/drivers/net/wireless/ath/regd.c
@@ -182,7 +182,7 @@ static void ath_force_clear_no_ir_chan(struct wiphy *wiphy,
 {
 	const struct ieee80211_reg_rule *reg_rule;
 
-	reg_rule = freq_reg_info(wiphy, ch->center_freq);
+	reg_rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));
 	if (IS_ERR(reg_rule))
 		return;
 
-- 
1.8.4.rc3


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

* [PATCH 2/3] brcm80211: fix usage of freq_reg_info()
  2013-10-29 18:34 [PATCH 0/3] wireless: fix usage of freq_reg_info() Luis R. Rodriguez
  2013-10-29 18:34 ` [PATCH 1/3] ath: " Luis R. Rodriguez
@ 2013-10-29 18:34 ` Luis R. Rodriguez
  2013-10-30  9:10   ` Arend van Spriel
  2013-10-29 18:34 ` [PATCH 3/3] rtlwifi: " Luis R. Rodriguez
  2 siblings, 1 reply; 6+ messages in thread
From: Luis R. Rodriguez @ 2013-10-29 18:34 UTC (permalink / raw)
  To: linville, johannes
  Cc: linux-wireless, Luis R. Rodriguez, Julia Lawall,
	Peter Senna Tschudin, Seth Forshee, Arend van Spriel

freq_reg_info() expects KHz and not MHz, fix this. In
this case we'll now be getting the no-ir flags cleared
on channels for any channel when the country IE trusts
that channel.

@@
struct ieee80211_channel *ch;
struct wiphy *wiphy;
const struct ieee80211_reg_rule *rule;
@@

-rule = freq_reg_info(wiphy, ch->center_freq);
+rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));

Generated-by: Coccinelle SmPL
Cc: Julia Lawall <julia.lawall@lip6.fr>
Cc: Peter Senna Tschudin <peter.senna@gmail.com>
Cc: Seth Forshee <seth.forshee@canonical.com>
Cc: Arend van Spriel <arend@broadcom.com>
Reported-by: Mihir Shete <smihir@qti.qualcomm.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 drivers/net/wireless/brcm80211/brcmsmac/channel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/brcm80211/brcmsmac/channel.c b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
index c99364f..8272570 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/channel.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
@@ -678,7 +678,8 @@ brcms_reg_apply_beaconing_flags(struct wiphy *wiphy,
 				continue;
 
 			if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
-				rule = freq_reg_info(wiphy, ch->center_freq);
+				rule = freq_reg_info(wiphy,
+						     MHZ_TO_KHZ(ch->center_freq));
 				if (IS_ERR(rule))
 					continue;
 
-- 
1.8.4.rc3


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

* [PATCH 3/3] rtlwifi: fix usage of freq_reg_info()
  2013-10-29 18:34 [PATCH 0/3] wireless: fix usage of freq_reg_info() Luis R. Rodriguez
  2013-10-29 18:34 ` [PATCH 1/3] ath: " Luis R. Rodriguez
  2013-10-29 18:34 ` [PATCH 2/3] brcm80211: " Luis R. Rodriguez
@ 2013-10-29 18:34 ` Luis R. Rodriguez
  2013-10-29 18:56   ` Larry Finger
  2 siblings, 1 reply; 6+ messages in thread
From: Luis R. Rodriguez @ 2013-10-29 18:34 UTC (permalink / raw)
  To: linville, johannes
  Cc: linux-wireless, Luis R. Rodriguez, Julia Lawall,
	Peter Senna Tschudin, Larry Finger

freq_reg_info() expects KHz and not MHz, fix this. In
this case we'll now be getting the no-ir flags cleared
on channels for any channel when the country IE trusts
that channel.

@@
struct ieee80211_channel *ch;
struct wiphy *wiphy;
const struct ieee80211_reg_rule *rule;
@@

-rule = freq_reg_info(wiphy, ch->center_freq);
+rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));

Generated-by: Coccinelle SmPL
Cc: Julia Lawall <julia.lawall@lip6.fr>
Cc: Peter Senna Tschudin <peter.senna@gmail.com>
Cc: Larry Finger <Larry.Finger@lwfinger.net>
Reported-by: Mihir Shete <smihir@qti.qualcomm.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
---
 drivers/net/wireless/rtlwifi/regd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/regd.c b/drivers/net/wireless/rtlwifi/regd.c
index 2e1642c..29d2813 100644
--- a/drivers/net/wireless/rtlwifi/regd.c
+++ b/drivers/net/wireless/rtlwifi/regd.c
@@ -169,7 +169,8 @@ static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy,
 			    (ch->flags & IEEE80211_CHAN_RADAR))
 				continue;
 			if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
-				reg_rule = freq_reg_info(wiphy, ch->center_freq);
+				reg_rule = freq_reg_info(wiphy,
+							 MHZ_TO_KHZ(ch->center_freq));
 				if (IS_ERR(reg_rule))
 					continue;
 
@@ -228,7 +229,7 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy,
 	 */
 
 	ch = &sband->channels[11];	/* CH 12 */
-	reg_rule = freq_reg_info(wiphy, ch->center_freq);
+	reg_rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));
 	if (!IS_ERR(reg_rule)) {
 		if (!(reg_rule->flags & NL80211_RRF_NO_IR))
 			if (ch->flags & IEEE80211_CHAN_NO_IR)
@@ -236,7 +237,7 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy,
 	}
 
 	ch = &sband->channels[12];	/* CH 13 */
-	reg_rule = freq_reg_info(wiphy, ch->center_freq);
+	reg_rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));
 	if (!IS_ERR(reg_rule)) {
 		if (!(reg_rule->flags & NL80211_RRF_NO_IR))
 			if (ch->flags & IEEE80211_CHAN_NO_IR)
-- 
1.8.4.rc3


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

* Re: [PATCH 3/3] rtlwifi: fix usage of freq_reg_info()
  2013-10-29 18:34 ` [PATCH 3/3] rtlwifi: " Luis R. Rodriguez
@ 2013-10-29 18:56   ` Larry Finger
  0 siblings, 0 replies; 6+ messages in thread
From: Larry Finger @ 2013-10-29 18:56 UTC (permalink / raw)
  To: Luis R. Rodriguez, linville, johannes
  Cc: linux-wireless, Julia Lawall, Peter Senna Tschudin

On 10/29/2013 01:34 PM, Luis R. Rodriguez wrote:
> freq_reg_info() expects KHz and not MHz, fix this. In
> this case we'll now be getting the no-ir flags cleared
> on channels for any channel when the country IE trusts
> that channel.
>
> @@
> struct ieee80211_channel *ch;
> struct wiphy *wiphy;
> const struct ieee80211_reg_rule *rule;
> @@
>
> -rule = freq_reg_info(wiphy, ch->center_freq);
> +rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));
>
> Generated-by: Coccinelle SmPL
> Cc: Julia Lawall <julia.lawall@lip6.fr>
> Cc: Peter Senna Tschudin <peter.senna@gmail.com>
> Cc: Larry Finger <Larry.Finger@lwfinger.net>
> Reported-by: Mihir Shete <smihir@qti.qualcomm.com>
> Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
> ---

This patch got some fuzz on my system in hunks 2 & 3 and failed "git am". With 
patch, it yielded correct code despite the fuzz.

Acked-by: Larry Finger <Larry.Finger@lwfinger.net>

Larry

>   drivers/net/wireless/rtlwifi/regd.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/wireless/rtlwifi/regd.c b/drivers/net/wireless/rtlwifi/regd.c
> index 2e1642c..29d2813 100644
> --- a/drivers/net/wireless/rtlwifi/regd.c
> +++ b/drivers/net/wireless/rtlwifi/regd.c
> @@ -169,7 +169,8 @@ static void _rtl_reg_apply_beaconing_flags(struct wiphy *wiphy,
>   			    (ch->flags & IEEE80211_CHAN_RADAR))
>   				continue;
>   			if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
> -				reg_rule = freq_reg_info(wiphy, ch->center_freq);
> +				reg_rule = freq_reg_info(wiphy,
> +							 MHZ_TO_KHZ(ch->center_freq));
>   				if (IS_ERR(reg_rule))
>   					continue;
>
> @@ -228,7 +229,7 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy,
>   	 */
>
>   	ch = &sband->channels[11];	/* CH 12 */
> -	reg_rule = freq_reg_info(wiphy, ch->center_freq);
> +	reg_rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));
>   	if (!IS_ERR(reg_rule)) {
>   		if (!(reg_rule->flags & NL80211_RRF_NO_IR))
>   			if (ch->flags & IEEE80211_CHAN_NO_IR)
> @@ -236,7 +237,7 @@ static void _rtl_reg_apply_active_scan_flags(struct wiphy *wiphy,
>   	}
>
>   	ch = &sband->channels[12];	/* CH 13 */
> -	reg_rule = freq_reg_info(wiphy, ch->center_freq);
> +	reg_rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));
>   	if (!IS_ERR(reg_rule)) {
>   		if (!(reg_rule->flags & NL80211_RRF_NO_IR))
>   			if (ch->flags & IEEE80211_CHAN_NO_IR)
>


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

* Re: [PATCH 2/3] brcm80211: fix usage of freq_reg_info()
  2013-10-29 18:34 ` [PATCH 2/3] brcm80211: " Luis R. Rodriguez
@ 2013-10-30  9:10   ` Arend van Spriel
  0 siblings, 0 replies; 6+ messages in thread
From: Arend van Spriel @ 2013-10-30  9:10 UTC (permalink / raw)
  To: Luis R. Rodriguez, linville, johannes
  Cc: linux-wireless, Julia Lawall, Peter Senna Tschudin, Seth Forshee

On 10/29/2013 07:34 PM, Luis R. Rodriguez wrote:
> freq_reg_info() expects KHz and not MHz, fix this. In
> this case we'll now be getting the no-ir flags cleared
> on channels for any channel when the country IE trusts
> that channel.
>
> @@
> struct ieee80211_channel *ch;
> struct wiphy *wiphy;
> const struct ieee80211_reg_rule *rule;
> @@
>
> -rule = freq_reg_info(wiphy, ch->center_freq);
> +rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));
>
> Generated-by: Coccinelle SmPL
> Cc: Julia Lawall <julia.lawall@lip6.fr>
> Cc: Peter Senna Tschudin <peter.senna@gmail.com>
> Cc: Seth Forshee <seth.forshee@canonical.com>

Acked-by: Arend van Spriel <arend@broadcom.com>

> Reported-by: Mihir Shete <smihir@qti.qualcomm.com>
> Signed-off-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
> ---
>   drivers/net/wireless/brcm80211/brcmsmac/channel.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/channel.c b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
> index c99364f..8272570 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/channel.c
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
> @@ -678,7 +678,8 @@ brcms_reg_apply_beaconing_flags(struct wiphy *wiphy,
>   				continue;
>
>   			if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE) {
> -				rule = freq_reg_info(wiphy, ch->center_freq);
> +				rule = freq_reg_info(wiphy,
> +						     MHZ_TO_KHZ(ch->center_freq));
>   				if (IS_ERR(rule))
>   					continue;
>
>



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

end of thread, other threads:[~2013-10-30  9:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-29 18:34 [PATCH 0/3] wireless: fix usage of freq_reg_info() Luis R. Rodriguez
2013-10-29 18:34 ` [PATCH 1/3] ath: " Luis R. Rodriguez
2013-10-29 18:34 ` [PATCH 2/3] brcm80211: " Luis R. Rodriguez
2013-10-30  9:10   ` Arend van Spriel
2013-10-29 18:34 ` [PATCH 3/3] rtlwifi: " Luis R. Rodriguez
2013-10-29 18:56   ` Larry Finger

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