drivers/net/wireless/ath/wil6210/wmi.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/ath/wil6210/wmi.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/ath/wil6210/wmi.c
Extension
.c
Size
113374 bytes
Lines
4049
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

struct auth_no_hdr {
	__le16 auth_alg;
	__le16 auth_transaction;
	__le16 status_code;
	/* possibly followed by Challenge text */
	u8 variable[];
} __packed;

u8 led_polarity = LED_POLARITY_LOW_ACTIVE;

/**
 * wmi_addr_remap - return AHB address for given firmware internal (linker) address
 * @x: internal address
 * If address have no valid AHB mapping, return 0
 */
static u32 wmi_addr_remap(u32 x)
{
	uint i;

	for (i = 0; i < ARRAY_SIZE(fw_mapping); i++) {
		if (fw_mapping[i].fw &&
		    ((x >= fw_mapping[i].from) && (x < fw_mapping[i].to)))
			return x + fw_mapping[i].host - fw_mapping[i].from;
	}

	return 0;
}

/**
 * wil_find_fw_mapping - find fw_mapping entry by section name
 * @section: section name
 *
 * Return pointer to section or NULL if not found
 */
struct fw_map *wil_find_fw_mapping(const char *section)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(fw_mapping); i++)
		if (fw_mapping[i].name &&
		    !strcmp(section, fw_mapping[i].name))
			return &fw_mapping[i];

	return NULL;
}

/**
 * wmi_buffer_block - Check address validity for WMI buffer; remap if needed
 * @wil: driver data
 * @ptr_: internal (linker) fw/ucode address
 * @size: if non zero, validate the block does not
 *  exceed the device memory (bar)
 *
 * Valid buffer should be DWORD aligned
 *
 * return address for accessing buffer from the host;
 * if buffer is not valid, return NULL.
 */
void __iomem *wmi_buffer_block(struct wil6210_priv *wil, __le32 ptr_, u32 size)
{
	u32 off;
	u32 ptr = le32_to_cpu(ptr_);

	if (ptr % 4)
		return NULL;

	ptr = wmi_addr_remap(ptr);
	if (ptr < WIL6210_FW_HOST_OFF)
		return NULL;

	off = HOSTADDR(ptr);
	if (off > wil->bar_size - 4)
		return NULL;
	if (size && ((off + size > wil->bar_size) || (off + size < off)))
		return NULL;

	return wil->csr + off;
}

void __iomem *wmi_buffer(struct wil6210_priv *wil, __le32 ptr_)
{
	return wmi_buffer_block(wil, ptr_, 0);
}

/* Check address validity */
void __iomem *wmi_addr(struct wil6210_priv *wil, u32 ptr)
{
	u32 off;

	if (ptr % 4)

Annotation

Implementation Notes