wifi: rtw89: regd: refactor init/setup flow and prototype

The regulatory and wiphy setup should be done in rtw89_regd_setup(). And,
what rtw89_regd_init() should do is to initialize target regulatory domain
(regd), if and only if one is programmed in efuse. Since HW is registered
after rtw89_regd_setup() and before rtw89_regd_init(), do not fill fields
of regulatory in rtw89_regd_init(). So, move the regulatory->reg_6ghz_power
assignment into rtw89_regd_setup().

Besides, rtw89_regd_notifier is assigned in rtw89_regd_setup() instead of
rtw89_regd_init(). To reduce confusion, stop passing rtw89_regd_notifier to
rtw89_regd_init(). And, rename rtw89_regd_init() to rtw89_regd_init_hint().

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250120032723.19042-4-pkshih@realtek.com
This commit is contained in:
Zong-Zhe Yang 2025-01-20 11:27:23 +08:00 committed by Ping-Ke Shih
parent 79a36fc56b
commit b45acf2455
3 changed files with 9 additions and 10 deletions

View File

@ -5303,7 +5303,7 @@ static int rtw89_core_register_hw(struct rtw89_dev *rtwdev)
goto err_free_supported_band;
}
ret = rtw89_regd_init(rtwdev, rtw89_regd_notifier);
ret = rtw89_regd_init_hint(rtwdev);
if (ret) {
rtw89_err(rtwdev, "failed to init regd\n");
goto err_unregister_hw;

View File

@ -7163,9 +7163,7 @@ void rtw89_chip_cfg_txpwr_ul_tb_offset(struct rtw89_dev *rtwdev,
struct rtw89_vif_link *rtwvif_link);
bool rtw89_ra_report_to_bitrate(struct rtw89_dev *rtwdev, u8 rpt_rate, u16 *bitrate);
int rtw89_regd_setup(struct rtw89_dev *rtwdev);
int rtw89_regd_init(struct rtw89_dev *rtwdev,
void (*reg_notifier)(struct wiphy *wiphy, struct regulatory_request *request));
void rtw89_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request);
int rtw89_regd_init_hint(struct rtw89_dev *rtwdev);
void rtw89_traffic_stats_init(struct rtw89_dev *rtwdev,
struct rtw89_traffic_stats *stats);
int rtw89_wait_for_cond(struct rtw89_wait_info *wait, unsigned int cond);

View File

@ -7,6 +7,9 @@
#include "ps.h"
#include "util.h"
static
void rtw89_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request);
#define COUNTRY_REGD(_alpha2, _rule_2ghz, _rule_5ghz, _rule_6ghz, _fmap) \
{ \
.alpha2 = _alpha2, \
@ -598,6 +601,8 @@ int rtw89_regd_setup(struct rtw89_dev *rtwdev)
regulatory->ctrl.map = rtw89_regd_map;
}
regulatory->reg_6ghz_power = RTW89_REG_6GHZ_POWER_DFLT;
if (!wiphy)
return -EINVAL;
@ -608,17 +613,12 @@ int rtw89_regd_setup(struct rtw89_dev *rtwdev)
return 0;
}
int rtw89_regd_init(struct rtw89_dev *rtwdev,
void (*reg_notifier)(struct wiphy *wiphy,
struct regulatory_request *request))
int rtw89_regd_init_hint(struct rtw89_dev *rtwdev)
{
struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
const struct rtw89_regd *chip_regd;
struct wiphy *wiphy = rtwdev->hw->wiphy;
int ret;
regulatory->reg_6ghz_power = RTW89_REG_6GHZ_POWER_DFLT;
if (!wiphy)
return -EINVAL;
@ -738,6 +738,7 @@ static void rtw89_regd_notifier_apply(struct rtw89_dev *rtwdev,
rtw89_regd_apply_policy_6ghz(rtwdev, wiphy);
}
static
void rtw89_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request)
{
struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);