drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c
Extension
.c
Size
78259 bytes
Lines
2384
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern 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

static const struct file_operations iwl_dbgfs_##name##_ops = {          \
	.read = iwl_dbgfs_##name##_read,				\
	.open = simple_open,						\
	.llseek = generic_file_llseek,					\
};

#define DEBUGFS_WRITE_FILE_OPS(name)                                    \
static const struct file_operations iwl_dbgfs_##name##_ops = {          \
	.write = iwl_dbgfs_##name##_write,                              \
	.open = simple_open,						\
	.llseek = generic_file_llseek,					\
};


#define DEBUGFS_READ_WRITE_FILE_OPS(name)                               \
static const struct file_operations iwl_dbgfs_##name##_ops = {          \
	.write = iwl_dbgfs_##name##_write,                              \
	.read = iwl_dbgfs_##name##_read,                                \
	.open = simple_open,						\
	.llseek = generic_file_llseek,					\
};

static ssize_t iwl_dbgfs_sram_read(struct file *file,
					char __user *user_buf,
					size_t count, loff_t *ppos)
{
	u32 val = 0;
	char *buf;
	ssize_t ret;
	int i = 0;
	bool device_format = false;
	int offset = 0;
	int len = 0;
	int pos = 0;
	int sram;
	struct iwl_priv *priv = file->private_data;
	const struct fw_img *img;
	size_t bufsz;

	if (!iwl_is_ready_rf(priv))
		return -EAGAIN;

	/* default is to dump the entire data segment */
	if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) {
		priv->dbgfs_sram_offset = 0x800000;
		if (!priv->ucode_loaded)
			return -EINVAL;
		img = &priv->fw->img[priv->cur_ucode];
		priv->dbgfs_sram_len = img->sec[IWL_UCODE_SECTION_DATA].len;
	}
	len = priv->dbgfs_sram_len;

	if (len == -4) {
		device_format = true;
		len = 4;
	}

	bufsz =  50 + len * 4;
	buf = kmalloc(bufsz, GFP_KERNEL);
	if (!buf)
		return -ENOMEM;

	pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n",
			 len);
	pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n",
			priv->dbgfs_sram_offset);

	/* adjust sram address since reads are only on even u32 boundaries */
	offset = priv->dbgfs_sram_offset & 0x3;
	sram = priv->dbgfs_sram_offset & ~0x3;

	/* read the first u32 from sram */
	val = iwl_trans_read_mem32(priv->trans, sram);

	for (; len; len--) {
		/* put the address at the start of every line */
		if (i == 0)
			pos += scnprintf(buf + pos, bufsz - pos,
				"%08X: ", sram + offset);

		if (device_format)
			pos += scnprintf(buf + pos, bufsz - pos,
				"%02x", (val >> (8 * (3 - offset))) & 0xff);
		else
			pos += scnprintf(buf + pos, bufsz - pos,
				"%02x ", (val >> (8 * offset)) & 0xff);

		/* if all bytes processed, read the next u32 from sram */
		if (++offset == 4) {
			sram += 4;

Annotation

Implementation Notes