]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mt76: mt7925: refactor regulatory notifier flow
authorMing Yen Hsieh <mingyen.hsieh@mediatek.com>
Fri, 31 Oct 2025 09:03:49 +0000 (17:03 +0800)
committerFelix Fietkau <nbd@nbd.name>
Mon, 24 Nov 2025 13:37:55 +0000 (14:37 +0100)
Rename mt7925_regd_update() to mt7925_mcu_regd_update() to centralize
regd updates with error handling.

Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Link: https://patch.msgid.link/20251031090352.1400079-4-mingyen.hsieh@mediatek.com
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7925/pci.c
drivers/net/wireless/mediatek/mt76/mt7925/regd.c
drivers/net/wireless/mediatek/mt76/mt7925/regd.h

index c10f14386571d17fc958dbf9eae1e7e820aae6bc..c4161754c01df1ed6e3f79f95dd10f3c1a8c92b5 100644 (file)
@@ -585,7 +585,7 @@ static int _mt7925_pci_resume(struct device *device, bool restore)
        if (!pm->ds_enable)
                mt7925_mcu_set_deep_sleep(dev, false);
 
-       mt7925_regd_update(dev);
+       mt7925_mcu_regd_update(dev, mdev->alpha2, dev->country_ie_env);
 failed:
        pm->suspended = false;
 
index 9e7b468a82289a6cbbd527cde0c09de3ede2388e..b36c6a6f5da6077ded55831df535cad317355fb9 100644 (file)
@@ -111,29 +111,49 @@ mt7925_regd_channel_update(struct wiphy *wiphy, struct mt792x_dev *dev)
        }
 }
 
-void mt7925_regd_update(struct mt792x_dev *dev)
+int mt7925_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 ieee80211_hw *hw = mt76_hw(dev);
        struct wiphy *wiphy = hw->wiphy;
+       int ret = 0;
+
+       dev->regd_in_progress = true;
 
+       mt792x_mutex_acquire(dev);
        if (!dev->regd_change)
-               return;
+               goto err;
+
+       ret = mt7925_mcu_set_clc(dev, alpha2, country_ie_env);
+       if (ret < 0)
+               goto err;
 
-       mt7925_mcu_set_clc(dev, mdev->alpha2, dev->country_ie_env);
        mt7925_regd_channel_update(wiphy, dev);
-       mt7925_mcu_set_channel_domain(hw->priv);
-       mt7925_set_tx_sar_pwr(hw, NULL);
+
+       ret = mt7925_mcu_set_channel_domain(hw->priv);
+       if (ret < 0)
+               goto err;
+
+       ret = mt7925_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(mt7925_regd_update);
+EXPORT_SYMBOL_GPL(mt7925_mcu_regd_update);
 
 void mt7925_regd_notifier(struct wiphy *wiphy, struct regulatory_request *req)
 {
        struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
        struct mt792x_dev *dev = mt792x_hw_dev(hw);
-       struct mt76_dev *mdev = &dev->mt76;
        struct mt76_connac_pm *pm = &dev->pm;
+       struct mt76_dev *mdev = &dev->mt76;
 
        /* allow world regdom at the first boot only */
        if (!memcmp(req->alpha2, "00", 2) &&
@@ -148,15 +168,14 @@ void mt7925_regd_notifier(struct wiphy *wiphy, struct regulatory_request *req)
        memcpy(mdev->alpha2, req->alpha2, 2);
        mdev->region = req->dfs_region;
        dev->country_ie_env = req->country_ie_env;
+
        dev->regd_change = true;
 
        if (pm->suspended)
+               /* postpone the mcu update to resume */
                return;
 
-       dev->regd_in_progress = true;
-       mt792x_mutex_acquire(dev);
-       mt7925_regd_update(dev);
-       mt792x_mutex_release(dev);
-       dev->regd_in_progress = false;
-       wake_up(&dev->wait);
+       mt7925_mcu_regd_update(dev, req->alpha2,
+                              req->country_ie_env);
+       return;
 }
index 5977e068c1c61b0516138e919b90e2b9c1d82c39..edcda72b12b0b0bc59f673acaec6051ee66a9b91 100644 (file)
@@ -6,8 +6,10 @@
 
 #include "mt7925.h"
 
+int mt7925_mcu_regd_update(struct mt792x_dev *dev, u8 *alpha2,
+                          enum environment_cap country_ie_env);
+
 void mt7925_regd_be_ctrl(struct mt792x_dev *dev, u8 *alpha2);
-void mt7925_regd_update(struct mt792x_dev *dev);
 void mt7925_regd_notifier(struct wiphy *wiphy, struct regulatory_request *req);
 bool mt7925_regd_clc_supported(struct mt792x_dev *dev);