Skip to contentSkip to conversation

wireless: fix usage of freq_reg_info()

PATCH In review Luis R. Rodriguez 3 participants 6 messages Oct 29, 2013 – Oct 30, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover 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(-)
Signature · 1 line
1.8.4.rc3
#1 lore raw

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]>
---
 drivers/net/wireless/ath/regd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/regd.c +1 -1
index a258283..bc9ba78 100644
@@ -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;
 
Signature · 1 line
1.8.4.rc3
#2 lore raw

PATCH 2/3 brcm80211: fix usage of freq_reg_info()

In reply to Luis R. Rodriguez

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]>
---
 drivers/net/wireless/brcm80211/brcmsmac/channel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/brcm80211/brcmsmac/channel.c +2 -1
index c99364f..8272570 100644
@@ -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;
 
Signature · 1 line
1.8.4.rc3
Acked-by on v1 2/3
#3 lore raw

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

Quoted 14 lines · Luis R. Rodriguez

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;
@@

(quoted diff) +1 -1
-rule = freq_reg_info(wiphy, ch->center_freq);
+rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));
Quoted 4 lines

Generated-by: Coccinelle SmPL
Cc: Julia Lawall <[email protected]>
Cc: Peter Senna Tschudin <[email protected]>
Cc: Seth Forshee <[email protected]>

Quoted 21 lines
---
  drivers/net/wireless/brcm80211/brcmsmac/channel.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/brcm80211/brcmsmac/channel.c +2 -1
index c99364f..8272570 100644
@@ -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;
 
#4 lore raw

PATCH 3/3 rtlwifi: fix usage of freq_reg_info()

In reply to Luis R. Rodriguez

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]>
---
 drivers/net/wireless/rtlwifi/regd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/rtlwifi/regd.c +4 -3
index 2e1642c..29d2813 100644
@@ -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)
Signature · 1 line
1.8.4.rc3
Acked-by on v1 3/3
#5 lore raw

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

Quoted 14 lines · Luis R. Rodriguez

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;
@@

(quoted diff) +1 -1
-rule = freq_reg_info(wiphy, ch->center_freq);
+rule = freq_reg_info(wiphy, MHZ_TO_KHZ(ch->center_freq));
Quoted 7 lines
Generated-by Coccinelle SmPL
Cc Julia Lawall <[email protected]>
Cc Peter Senna Tschudin <[email protected]>
Cc Larry Finger <[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.

Larry

Quoted 36 lines
  drivers/net/wireless/rtlwifi/regd.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/rtlwifi/regd.c +4 -3
index 2e1642c..29d2813 100644
@@ -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)