]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: rtw89: regd/acpi: support country CA by BIT(1) in 6 GHz SP conf
authorZong-Zhe Yang <kevin_yang@realtek.com>
Wed, 9 Jul 2025 06:50:03 +0000 (14:50 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Tue, 15 Jul 2025 01:11:37 +0000 (09:11 +0800)
ACPI DSM function 7 is used to decide whether 6 GHz Standard Power
(SP) is allowed on given countries. Now, add BIT(1) for country CA.
Besides, for searching country index, replace for-loop with index
getter function.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250709065006.32028-2-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/acpi.h
drivers/net/wireless/realtek/rtw89/regd.c

index 8c918ee02d2edbad8a8a04a137596f181d5bac5b..8217cdfbbc49894faaa7c65a076724e910446ac8 100644 (file)
@@ -56,6 +56,7 @@ struct rtw89_acpi_policy_6ghz {
 
 enum rtw89_acpi_conf_6ghz_sp {
        RTW89_ACPI_CONF_6GHZ_SP_US = BIT(0),
+       RTW89_ACPI_CONF_6GHZ_SP_CA = BIT(1),
 };
 
 struct rtw89_acpi_policy_6ghz_sp {
index 3ad14cab1f587045d846c8a38e167ed885539257..c91a86332b17c9855a25e67dc4ac30057b7c5a42 100644 (file)
@@ -490,12 +490,11 @@ out:
 static void rtw89_regd_setup_policy_6ghz_sp(struct rtw89_dev *rtwdev)
 {
        struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
-       const struct rtw89_regd_ctrl *regd_ctrl = &regulatory->ctrl;
        const struct rtw89_acpi_policy_6ghz_sp *ptr;
        struct rtw89_acpi_dsm_result res = {};
-       bool enable_by_us;
+       bool enable;
+       u8 index;
        int ret;
-       int i;
 
        ret = rtw89_acpi_evaluate_dsm(rtwdev, RTW89_ACPI_DSM_FUNC_6GHZ_SP_SUP, &res);
        if (ret) {
@@ -520,14 +519,15 @@ static void rtw89_regd_setup_policy_6ghz_sp(struct rtw89_dev *rtwdev)
 
        bitmap_fill(regulatory->block_6ghz_sp, RTW89_REGD_MAX_COUNTRY_NUM);
 
-       enable_by_us = u8_get_bits(ptr->conf, RTW89_ACPI_CONF_6GHZ_SP_US);
+       index = rtw89_regd_get_index_by_name(rtwdev, "US");
+       enable = u8_get_bits(ptr->conf, RTW89_ACPI_CONF_6GHZ_SP_US);
+       if (enable && index != RTW89_REGD_MAX_COUNTRY_NUM)
+               clear_bit(index, regulatory->block_6ghz_sp);
 
-       for (i = 0; i < regd_ctrl->nr; i++) {
-               const struct rtw89_regd *tmp = &regd_ctrl->map[i];
-
-               if (enable_by_us && memcmp(tmp->alpha2, "US", 2) == 0)
-                       clear_bit(i, regulatory->block_6ghz_sp);
-       }
+       index = rtw89_regd_get_index_by_name(rtwdev, "CA");
+       enable = u8_get_bits(ptr->conf, RTW89_ACPI_CONF_6GHZ_SP_CA);
+       if (enable && index != RTW89_REGD_MAX_COUNTRY_NUM)
+               clear_bit(index, regulatory->block_6ghz_sp);
 
 out:
        kfree(ptr);