wifi: rtw89: regd: refactor init/setup flow and prototype
authorZong-Zhe Yang <kevin_yang@realtek.com>
Mon, 20 Jan 2025 03:27:23 +0000 (11:27 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Mon, 3 Feb 2025 02:07:59 +0000 (10:07 +0800)
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
drivers/net/wireless/realtek/rtw89/core.c
drivers/net/wireless/realtek/rtw89/core.h
drivers/net/wireless/realtek/rtw89/regd.c

index b730f70c82aa9457e072fa3d2b04c4d2d0281eb6..37002cfe832594f1b1e6f99e16b935033949f4d6 100644 (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;
index 4328b3acca45ff31585be8965766079441ce1a2e..505a645e7a88efa17cd514bbe9e9c745a9704fd4 100644 (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);
index 50a7f6ff4b5bfe38764a27726ff7d714b1c6c674..5b9d3b78c24e2b556b1a36475fda4bbd533c4a98 100644 (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);