Skip to content

Commit b45acf2

Browse files
Zong-Zhe YangPing-Ke Shih
authored andcommitted
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 <[email protected]> Signed-off-by: Ping-Ke Shih <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 79a36fc commit b45acf2

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

drivers/net/wireless/realtek/rtw89/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5303,7 +5303,7 @@ static int rtw89_core_register_hw(struct rtw89_dev *rtwdev)
53035303
goto err_free_supported_band;
53045304
}
53055305

5306-
ret = rtw89_regd_init(rtwdev, rtw89_regd_notifier);
5306+
ret = rtw89_regd_init_hint(rtwdev);
53075307
if (ret) {
53085308
rtw89_err(rtwdev, "failed to init regd\n");
53095309
goto err_unregister_hw;

drivers/net/wireless/realtek/rtw89/core.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7163,9 +7163,7 @@ void rtw89_chip_cfg_txpwr_ul_tb_offset(struct rtw89_dev *rtwdev,
71637163
struct rtw89_vif_link *rtwvif_link);
71647164
bool rtw89_ra_report_to_bitrate(struct rtw89_dev *rtwdev, u8 rpt_rate, u16 *bitrate);
71657165
int rtw89_regd_setup(struct rtw89_dev *rtwdev);
7166-
int rtw89_regd_init(struct rtw89_dev *rtwdev,
7167-
void (*reg_notifier)(struct wiphy *wiphy, struct regulatory_request *request));
7168-
void rtw89_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request);
7166+
int rtw89_regd_init_hint(struct rtw89_dev *rtwdev);
71697167
void rtw89_traffic_stats_init(struct rtw89_dev *rtwdev,
71707168
struct rtw89_traffic_stats *stats);
71717169
int rtw89_wait_for_cond(struct rtw89_wait_info *wait, unsigned int cond);

drivers/net/wireless/realtek/rtw89/regd.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#include "ps.h"
88
#include "util.h"
99

10+
static
11+
void rtw89_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request);
12+
1013
#define COUNTRY_REGD(_alpha2, _rule_2ghz, _rule_5ghz, _rule_6ghz, _fmap) \
1114
{ \
1215
.alpha2 = _alpha2, \
@@ -598,6 +601,8 @@ int rtw89_regd_setup(struct rtw89_dev *rtwdev)
598601
regulatory->ctrl.map = rtw89_regd_map;
599602
}
600603

604+
regulatory->reg_6ghz_power = RTW89_REG_6GHZ_POWER_DFLT;
605+
601606
if (!wiphy)
602607
return -EINVAL;
603608

@@ -608,17 +613,12 @@ int rtw89_regd_setup(struct rtw89_dev *rtwdev)
608613
return 0;
609614
}
610615

611-
int rtw89_regd_init(struct rtw89_dev *rtwdev,
612-
void (*reg_notifier)(struct wiphy *wiphy,
613-
struct regulatory_request *request))
616+
int rtw89_regd_init_hint(struct rtw89_dev *rtwdev)
614617
{
615-
struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
616618
const struct rtw89_regd *chip_regd;
617619
struct wiphy *wiphy = rtwdev->hw->wiphy;
618620
int ret;
619621

620-
regulatory->reg_6ghz_power = RTW89_REG_6GHZ_POWER_DFLT;
621-
622622
if (!wiphy)
623623
return -EINVAL;
624624

@@ -738,6 +738,7 @@ static void rtw89_regd_notifier_apply(struct rtw89_dev *rtwdev,
738738
rtw89_regd_apply_policy_6ghz(rtwdev, wiphy);
739739
}
740740

741+
static
741742
void rtw89_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request)
742743
{
743744
struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);

0 commit comments

Comments
 (0)