wifi: mt76: mt7925: refactor regulatory notifier flow

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>
This commit is contained in:
Ming Yen Hsieh 2025-10-31 17:03:49 +08:00 committed by Felix Fietkau
parent e323b84127
commit 3305100859
3 changed files with 38 additions and 17 deletions

View 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;

View 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;
}

View 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);