]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: mt76: mt7921: refactor regulatory notifier flow
authorJB Tsai <jb.tsai@mediatek.com>
Tue, 3 Mar 2026 05:36:35 +0000 (13:36 +0800)
committerFelix Fietkau <nbd@nbd.name>
Tue, 9 Jun 2026 10:20:44 +0000 (10:20 +0000)
Rename mt7921_regd_update() to mt7921_mcu_regd_update() to centralize
regd updates with error handling.

Co-developed-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: JB Tsai <jb.tsai@mediatek.com>
Link: https://patch.msgid.link/20260303053637.465465-3-jb.tsai@mediatek.com
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7921/main.c
drivers/net/wireless/mediatek/mt76/mt7921/pci.c
drivers/net/wireless/mediatek/mt76/mt7921/regd.c
drivers/net/wireless/mediatek/mt76/mt7921/regd.h

index 4ac26391a721782eab67b66bb773a7ee97c3d8ca..55ffd8eb8c6a66860f13c4d0f957a2865f06e9eb 100644 (file)
@@ -802,7 +802,7 @@ mt7921_regd_set_6ghz_power_type(struct ieee80211_vif *vif, bool is_add)
 
 out:
        if (vif->bss_conf.chanreq.oper.chan->band == NL80211_BAND_6GHZ)
-               mt7921_regd_update(dev);
+               mt7921_mcu_regd_update(dev, dev->mt76.alpha2, dev->country_ie_env);
 }
 
 int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,
index 7ac0ca07278d46dd50a1ccec86640a785741c5a7..7728c5ae67914562a195878faecef09f8fb2f4bd 100644 (file)
@@ -589,7 +589,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;
index 94334298496533cba7fde3f3981e5c597a7ee8c2..fa753e8e041de2e417fb7fc0d60e963f0d63511f 100644 (file)
@@ -71,18 +71,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)
@@ -105,12 +130,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);
 }
index ece85feb7a23d5fc1f535188c2c1ee4220a0e776..c7dcf747843cf9a792ded2a29ae18649fe1c0112 100644 (file)
@@ -8,7 +8,8 @@ struct mt792x_dev;
 struct wiphy;
 struct regulatory_request;
 
-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);