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

Source file repositories/reference/linux-study-clean/drivers/net/wireless/realtek/rtw89/regd.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/realtek/rtw89/regd.c
Extension
.c
Size
39639 bytes
Lines
1211
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (memcmp("EU", country->alpha2, 2) != 0) {
			__rtw89_regd_setup_policy_6ghz(rtwdev, to_block,
						       country->alpha2);
			continue;
		}

		for (j = 0; j < ARRAY_SIZE(rtw89_alpha2_list_eu); j++)
			__rtw89_regd_setup_policy_6ghz(rtwdev, to_block,
						       rtw89_alpha2_list_eu[j]);
	}

out:
	kfree(ptr);
}

static void rtw89_regd_setup_policy_6ghz_sp(struct rtw89_dev *rtwdev)
{
	struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
	bool skip_acpi_dsm = rtwdev->hci.type == RTW89_HCI_TYPE_USB;
	const struct rtw89_acpi_policy_6ghz_sp *ptr;
	struct rtw89_acpi_dsm_result res = {};
	bool enable;
	u8 index;
	int ret;

	if (skip_acpi_dsm)
		return;

	ret = rtw89_acpi_evaluate_dsm(rtwdev, RTW89_ACPI_DSM_FUNC_6GHZ_SP_SUP, &res);
	if (ret) {
		rtw89_debug(rtwdev, RTW89_DBG_REGD,
			    "acpi: cannot eval policy 6ghz-sp: %d\n", ret);
		return;
	}

	ptr = res.u.policy_6ghz_sp;

	switch (ptr->override) {
	default:
		rtw89_debug(rtwdev, RTW89_DBG_REGD,
			    "%s: unknown override case: %d\n", __func__,
			    ptr->override);
		fallthrough;
	case 0:
		goto out;
	case 1:
		break;
	}

	bitmap_fill(regulatory->block_6ghz_sp, RTW89_REGD_MAX_COUNTRY_NUM);

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

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

static void rtw89_regd_setup_policy_6ghz_vlp(struct rtw89_dev *rtwdev)
{
	struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory;
	bool skip_acpi_dsm = rtwdev->hci.type == RTW89_HCI_TYPE_USB;
	const struct rtw89_acpi_policy_6ghz_vlp *ptr = NULL;
	struct rtw89_acpi_dsm_result res = {};
	bool enable;
	u8 index;
	int ret;
	u8 val;

	if (skip_acpi_dsm)
		return;

	/* By default, allow 6 GHz VLP on all countries except US and CA. */
	val = ~(RTW89_ACPI_CONF_6GHZ_VLP_US | RTW89_ACPI_CONF_6GHZ_VLP_CA);

	ret = rtw89_acpi_evaluate_dsm(rtwdev, RTW89_ACPI_DSM_FUNC_6GHZ_VLP_SUP, &res);
	if (ret) {
		rtw89_debug(rtwdev, RTW89_DBG_REGD,
			    "acpi: cannot eval policy 6ghz-vlp: %d\n", ret);
		goto bottom;
	}

	ptr = res.u.policy_6ghz_vlp;

Annotation

Implementation Notes