2013-10-29 18:34:37

by Luis Chamberlain

[permalink] [raw]
Subject: [PATCH 0/3] wireless: fix usage of freq_reg_info()

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



2013-10-30 09:11:06

by Arend van Spriel

[permalink] [raw]
Subject: Re: [PATCH 2/3] brcm80211: fix usage of freq_reg_info()

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 <[email protected]>
> Cc: Peter Senna Tschudin <[email protected]>
> Cc: Seth Forshee <[email protected]>

Acked-by: Arend van Spriel <[email protected]>

> Reported-by: Mihir Shete <[email protected]>
> Signed-off-by: Luis R. Rodriguez <[email protected]>
> ---
> 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;
>
>



2013-10-29 18:34:39

by Luis Chamberlain

[permalink] [raw]
Subject: [PATCH 1/3] ath: fix usage of freq_reg_info()

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 <[email protected]>
Cc: Peter Senna Tschudin <[email protected]>
Reported-by: Mihir Shete <[email protected]>
Signed-off-by: Luis R. Rodriguez <[email protected]>
---
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


2013-10-29 18:56:24

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH 3/3] rtlwifi: fix usage of freq_reg_info()

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 <[email protected]>
> Cc: Peter Senna Tschudin <[email protected]>
> Cc: Larry Finger <[email protected]>
> Reported-by: Mihir Shete <[email protected]>
> Signed-off-by: Luis R. Rodriguez <[email protected]>
> ---

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 <[email protected]>

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


2013-10-29 18:34:41

by Luis Chamberlain

[permalink] [raw]
Subject: [PATCH 2/3] brcm80211: fix usage of freq_reg_info()

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 <[email protected]>
Cc: Peter Senna Tschudin <[email protected]>
Cc: Seth Forshee <[email protected]>
Cc: Arend van Spriel <[email protected]>
Reported-by: Mihir Shete <[email protected]>
Signed-off-by: Luis R. Rodriguez <[email protected]>
---
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


2013-10-29 18:34:43

by Luis Chamberlain

[permalink] [raw]
Subject: [PATCH 3/3] rtlwifi: fix usage of freq_reg_info()

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 <[email protected]>
Cc: Peter Senna Tschudin <[email protected]>
Cc: Larry Finger <[email protected]>
Reported-by: Mihir Shete <[email protected]>
Signed-off-by: Luis R. Rodriguez <[email protected]>
---
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