From: JB Tsai <jb.tsai@mediatek.com>
To: <nbd@nbd.name>, <lorenzo@kernel.org>
Cc: <linux-wireless@vger.kernel.org>,
<linux-mediatek@lists.infradead.org>, <Deren.Wu@mediatek.com>,
<Sean.Wang@mediatek.com>, <Quan.Zhou@mediatek.com>,
<Ryder.Lee@mediatek.com>, <Leon.Yen@mediatek.com>,
<litien.chang@mediatek.com>, <jb.tsai@mediatek.com>
Subject: [PATCH 2/5] wifi: mt76: mt7921: refactor CLC support check flow
Date: Mon, 23 Feb 2026 15:38:51 +0800 [thread overview]
Message-ID: <20260223073854.2464232-2-jb.tsai@mediatek.com> (raw)
In-Reply-To: <20260223073854.2464232-1-jb.tsai@mediatek.com>
Move the disable_clc module parameter to regd.c and introduce
mt7925_regd_clc_supported() to centralize CLC support checks.
Signed-off-by: JB Tsai <jb.tsai@mediatek.com>
---
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 14 ++++++++------
drivers/net/wireless/mediatek/mt76/mt7921/regd.c | 13 +++++++++++++
drivers/net/wireless/mediatek/mt76/mt7921/regd.h | 1 +
3 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index 8442dbd2ee23..1e2afa736cdf 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -4,6 +4,7 @@
#include <linux/fs.h>
#include <linux/firmware.h>
#include "mt7921.h"
+#include "regd.h"
#include "mcu.h"
#include "../mt76_connac2_mac.h"
#include "../mt792x_trace.h"
@@ -11,10 +12,6 @@
#define MT_STA_BFER BIT(0)
#define MT_STA_BFEE BIT(1)
-static bool mt7921_disable_clc;
-module_param_named(disable_clc, mt7921_disable_clc, bool, 0644);
-MODULE_PARM_DESC(disable_clc, "disable CLC support");
-
int mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd,
struct sk_buff *skb, int seq)
{
@@ -422,8 +419,7 @@ static int mt7921_load_clc(struct mt792x_dev *dev, const char *fw_name)
u8 *clc_base = NULL, hw_encap = 0;
dev->phy.clc_chan_conf = 0xff;
- if (mt7921_disable_clc ||
- mt76_is_usb(&dev->mt76))
+ if (!mt7921_regd_clc_supported(dev))
return 0;
if (mt76_is_mmio(&dev->mt76)) {
@@ -470,6 +466,9 @@ static int mt7921_load_clc(struct mt792x_dev *dev, const char *fw_name)
for (offset = 0; offset < len; offset += le32_to_cpu(clc->len)) {
clc = (const struct mt7921_clc *)(clc_base + offset);
+ if (clc->idx >= ARRAY_SIZE(phy->clc))
+ break;
+
/* do not init buf again if chip reset triggered */
if (phy->clc[clc->idx])
continue;
@@ -1403,6 +1402,9 @@ int mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
struct mt792x_phy *phy = (struct mt792x_phy *)&dev->phy;
int i, ret;
+ if (!ARRAY_SIZE(phy->clc))
+ return -ESRCH;
+
/* submit all clc config */
for (i = 0; i < ARRAY_SIZE(phy->clc); i++) {
ret = __mt7921_mcu_set_clc(dev, alpha2, env_cap,
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/regd.c b/drivers/net/wireless/mediatek/mt76/mt7921/regd.c
index 6e6c81189222..70440ab8ba82 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/regd.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/regd.c
@@ -7,6 +7,19 @@
#include "regd.h"
#include "mcu.h"
+static bool mt7921_disable_clc;
+module_param_named(disable_clc, mt7921_disable_clc, bool, 0644);
+MODULE_PARM_DESC(disable_clc, "disable CLC support");
+
+bool mt7921_regd_clc_supported(struct mt792x_dev *dev)
+{
+ if (mt7921_disable_clc ||
+ mt76_is_usb(&dev->mt76))
+ return false;
+
+ return true;
+}
+
static void
mt7921_regd_channel_update(struct wiphy *wiphy, struct mt792x_dev *dev)
{
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/regd.h b/drivers/net/wireless/mediatek/mt76/mt7921/regd.h
index 0ba6161e1919..74bc2fdd532c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/regd.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/regd.h
@@ -9,5 +9,6 @@
void mt7921_regd_update(struct mt792x_dev *dev);
void mt7921_regd_notifier(struct wiphy *wiphy,
struct regulatory_request *request);
+bool mt7921_regd_clc_supported(struct mt792x_dev *dev);
#endif
--
2.45.2
next prev parent reply other threads:[~2026-02-23 7:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 7:38 [PATCH 1/5] wifi: mt76: mt7921: refactor regulatory domain handling to regd.[ch] JB Tsai
2026-02-23 7:38 ` JB Tsai [this message]
2026-02-23 22:41 ` [PATCH 2/5] wifi: mt76: mt7921: refactor CLC support check flow Sean Wang
2026-02-23 7:38 ` [PATCH 3/5] wifi: mt76: mt7921: refactor regulatory notifier flow JB Tsai
2026-02-23 23:17 ` Sean Wang
2026-02-23 7:38 ` [PATCH 4/5] wifi: mt76: mt7921: add auto regdomain switch support JB Tsai
2026-02-23 23:45 ` Sean Wang
2026-02-23 7:38 ` [PATCH 5/5] wifi: mt76: mt7921: disable auto regd changes after user set JB Tsai
2026-02-23 20:38 ` [PATCH 1/5] wifi: mt76: mt7921: refactor regulatory domain handling to regd.[ch] Sean Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260223073854.2464232-2-jb.tsai@mediatek.com \
--to=jb.tsai@mediatek.com \
--cc=Deren.Wu@mediatek.com \
--cc=Leon.Yen@mediatek.com \
--cc=Quan.Zhou@mediatek.com \
--cc=Ryder.Lee@mediatek.com \
--cc=Sean.Wang@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=litien.chang@mediatek.com \
--cc=lorenzo@kernel.org \
--cc=nbd@nbd.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox