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 3/5] wifi: mt76: mt7921: refactor regulatory notifier flow
Date: Mon, 23 Feb 2026 15:38:52 +0800 [thread overview]
Message-ID: <20260223073854.2464232-3-jb.tsai@mediatek.com> (raw)
In-Reply-To: <20260223073854.2464232-1-jb.tsai@mediatek.com>
Rename mt7921_regd_update() to mt7921_mcu_regd_update() to centralize
regd updates with error handling.
Signed-off-by: JB Tsai <jb.tsai@mediatek.com>
---
.../net/wireless/mediatek/mt76/mt7921/pci.c | 2 +-
.../net/wireless/mediatek/mt76/mt7921/regd.c | 45 +++++++++++++------
.../net/wireless/mediatek/mt76/mt7921/regd.h | 3 +-
3 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
index a173a61f2b49..3fdf55c056a6 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
@@ -545,7 +545,7 @@ static int mt7921_pci_resume(struct device *device)
if (err < 0)
goto failed;
- mt7921_regd_update(dev);
+ mt7921_mcu_regd_update(dev, mdev->alpha2, dev->country_ie_env);
err = mt7921_mcu_radio_led_ctrl(dev, EXT_CMD_RADIO_ON_LED);
failed:
pm->suspended = false;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/regd.c b/drivers/net/wireless/mediatek/mt76/mt7921/regd.c
index 70440ab8ba82..f795ee2eb446 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/regd.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/regd.c
@@ -72,18 +72,43 @@ mt7921_regd_channel_update(struct wiphy *wiphy, struct mt792x_dev *dev)
}
}
-void mt7921_regd_update(struct mt792x_dev *dev)
+int mt7921_mcu_regd_update(struct mt792x_dev *dev, u8 *alpha2,
+ enum environment_cap country_ie_env)
{
struct mt76_dev *mdev = &dev->mt76;
struct ieee80211_hw *hw = mdev->hw;
struct wiphy *wiphy = hw->wiphy;
+ int ret = 0;
+
+ dev->regd_in_progress = true;
+
+ mt792x_mutex_acquire(dev);
+ if (!dev->regd_change)
+ goto err;
+
+ ret = mt7921_mcu_set_clc(dev, alpha2, country_ie_env);
+ if (ret < 0)
+ goto err;
- mt7921_mcu_set_clc(dev, mdev->alpha2, dev->country_ie_env);
mt7921_regd_channel_update(wiphy, dev);
- mt76_connac_mcu_set_channel_domain(hw->priv);
- mt7921_set_tx_sar_pwr(hw, NULL);
+
+ ret = mt76_connac_mcu_set_channel_domain(hw->priv);
+ if (ret < 0)
+ goto err;
+
+ ret = mt7921_set_tx_sar_pwr(hw, NULL);
+ if (ret < 0)
+ goto err;
+
+err:
+ mt792x_mutex_release(dev);
+ dev->regd_change = false;
+ dev->regd_in_progress = false;
+ wake_up(&dev->wait);
+
+ return ret;
}
-EXPORT_SYMBOL_GPL(mt7921_regd_update);
+EXPORT_SYMBOL_GPL(mt7921_mcu_regd_update);
void mt7921_regd_notifier(struct wiphy *wiphy,
struct regulatory_request *request)
@@ -106,12 +131,6 @@ void mt7921_regd_notifier(struct wiphy *wiphy,
if (pm->suspended)
return;
- dev->regd_in_progress = true;
-
- mt792x_mutex_acquire(dev);
- mt7921_regd_update(dev);
- mt792x_mutex_release(dev);
-
- dev->regd_in_progress = false;
- wake_up(&dev->wait);
+ mt7921_mcu_regd_update(dev, request->alpha2,
+ request->country_ie_env);
}
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/regd.h b/drivers/net/wireless/mediatek/mt76/mt7921/regd.h
index 74bc2fdd532c..da5bd4450312 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/regd.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/regd.h
@@ -6,7 +6,8 @@
#include "mt7921.h"
-void mt7921_regd_update(struct mt792x_dev *dev);
+int mt7921_mcu_regd_update(struct mt792x_dev *dev, u8 *alpha2,
+ enum environment_cap country_ie_env);
void mt7921_regd_notifier(struct wiphy *wiphy,
struct regulatory_request *request);
bool mt7921_regd_clc_supported(struct mt792x_dev *dev);
--
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 ` [PATCH 2/5] wifi: mt76: mt7921: refactor CLC support check flow JB Tsai
2026-02-23 22:41 ` Sean Wang
2026-02-23 7:38 ` JB Tsai [this message]
2026-02-23 23:17 ` [PATCH 3/5] wifi: mt76: mt7921: refactor regulatory notifier flow 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-3-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