[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250418-ath12k-6g-lp-vlp-v1-3-c869c86cad60@quicinc.com>
Date: Fri, 18 Apr 2025 10:55:36 +0800
From: Baochen Qiang <quic_bqiang@...cinc.com>
To: Johannes Berg <johannes@...solutions.net>,
Jeff Johnson
<jjohnson@...nel.org>
CC: <linux-wireless@...r.kernel.org>, <ath12k@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>,
Baochen Qiang <quic_bqiang@...cinc.com>
Subject: [PATCH ath-next 03/15] wifi: ath12k: refactor
ath12k_reg_build_regd()
Currently we pass intersect flag to tell ath12k_reg_build_regd() whether
regulatory rulse are intersected. This flag is determined in
ath12k_reg_handle_chan_list() and has no other users.
Move related logic into ath12k_reg_build_regd() to make code clear. Also
relocate ath12k_reg_is_world_alpha() to avoid forward declaration, and
refine it for code simplicity.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Signed-off-by: Baochen Qiang <quic_bqiang@...cinc.com>
---
drivers/net/wireless/ath/ath12k/reg.c | 43 +++++++++++++----------------------
drivers/net/wireless/ath/ath12k/reg.h | 3 +--
2 files changed, 17 insertions(+), 29 deletions(-)
diff --git a/drivers/net/wireless/ath/ath12k/reg.c b/drivers/net/wireless/ath/ath12k/reg.c
index 21c5a8312a9e55a458aab5151ff9c017808659d7..86e3b426d5f9de525a22850140cbc8acac0b6fcf 100644
--- a/drivers/net/wireless/ath/ath12k/reg.c
+++ b/drivers/net/wireless/ath/ath12k/reg.c
@@ -710,9 +710,15 @@ static void ath12k_reg_update_freq_range(struct ath12k_reg_freq *reg_freq,
reg_freq->end_freq = reg_rule->end_freq;
}
+static bool ath12k_reg_is_world_alpha(char *alpha)
+{
+ return (alpha[0] == '0' && alpha[1] == '0') ||
+ (alpha[0] == 'n' && alpha[1] == 'a');
+}
+
struct ieee80211_regdomain *
ath12k_reg_build_regd(struct ath12k_base *ab,
- struct ath12k_reg_info *reg_info, bool intersect)
+ struct ath12k_reg_info *reg_info)
{
struct ieee80211_regdomain *tmp_regd, *default_regd, *new_regd = NULL;
struct ath12k_reg_rule *reg_rule;
@@ -842,9 +848,14 @@ ath12k_reg_build_regd(struct ath12k_base *ab,
tmp_regd->n_reg_rules = i;
- if (intersect) {
- default_regd = ab->default_regd[reg_info->phy_id];
-
+ /* Intersect new rules with default regd if a new country setting was
+ * requested, i.e a default regd was already set during initialization
+ * and the regd coming from this event has a valid country info.
+ */
+ default_regd = ab->default_regd[reg_info->phy_id];
+ if (default_regd &&
+ !ath12k_reg_is_world_alpha((char *)default_regd->alpha2) &&
+ !ath12k_reg_is_world_alpha((char *)reg_info->alpha2)) {
/* Get a new regd by intersecting the received regd with
* our default regd.
*/
@@ -899,22 +910,10 @@ void ath12k_reg_reset_reg_info(struct ath12k_reg_info *reg_info)
}
}
-static bool ath12k_reg_is_world_alpha(char *alpha)
-{
- if (alpha[0] == '0' && alpha[1] == '0')
- return true;
-
- if (alpha[0] == 'n' && alpha[1] == 'a')
- return true;
-
- return false;
-}
-
int ath12k_reg_handle_chan_list(struct ath12k_base *ab,
struct ath12k_reg_info *reg_info)
{
struct ieee80211_regdomain *regd = NULL;
- bool intersect = false;
struct ath12k *ar;
int pdev_idx;
@@ -948,17 +947,7 @@ int ath12k_reg_handle_chan_list(struct ath12k_base *ab,
reg_info->alpha2, 2))
return 0;
- /* Intersect new rules with default regd if a new country setting was
- * requested, i.e a default regd was already set during initialization
- * and the regd coming from this event has a valid country info.
- */
- if (ab->default_regd[pdev_idx] &&
- !ath12k_reg_is_world_alpha((char *)
- ab->default_regd[pdev_idx]->alpha2) &&
- !ath12k_reg_is_world_alpha((char *)reg_info->alpha2))
- intersect = true;
-
- regd = ath12k_reg_build_regd(ab, reg_info, intersect);
+ regd = ath12k_reg_build_regd(ab, reg_info);
if (!regd)
return -EINVAL;
diff --git a/drivers/net/wireless/ath/ath12k/reg.h b/drivers/net/wireless/ath/ath12k/reg.h
index f65cfaca7404cd72a9978c0ae6ca98be9d5f6b70..41230092f77bc9f133313dd334825409f0599fd2 100644
--- a/drivers/net/wireless/ath/ath12k/reg.h
+++ b/drivers/net/wireless/ath/ath12k/reg.h
@@ -96,8 +96,7 @@ void ath12k_reg_init(struct ieee80211_hw *hw);
void ath12k_reg_free(struct ath12k_base *ab);
void ath12k_regd_update_work(struct work_struct *work);
struct ieee80211_regdomain *ath12k_reg_build_regd(struct ath12k_base *ab,
- struct ath12k_reg_info *reg_info,
- bool intersect);
+ struct ath12k_reg_info *reg_info);
int ath12k_regd_update(struct ath12k *ar, bool init);
int ath12k_reg_update_chan_list(struct ath12k *ar, bool wait);
--
2.34.1
Powered by blists - more mailing lists