drivers/net/wireless/ath/ath5k/debug.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/ath/ath5k/debug.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/ath/ath5k/debug.c
Extension
.c
Size
33235 bytes
Lines
1104
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 fops_beacon = {
	.read = read_file_beacon,
	.write = write_file_beacon,
	.open = simple_open,
	.owner = THIS_MODULE,
	.llseek = default_llseek,
};


/* debugfs: reset */

static ssize_t write_file_reset(struct file *file,
				 const char __user *userbuf,
				 size_t count, loff_t *ppos)
{
	struct ath5k_hw *ah = file->private_data;
	ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "debug file triggered reset\n");
	ieee80211_queue_work(ah->hw, &ah->reset_work);
	return count;
}

static const struct file_operations fops_reset = {
	.write = write_file_reset,
	.open = simple_open,
	.owner = THIS_MODULE,
	.llseek = noop_llseek,
};


/* debugfs: debug level */

static const struct {
	enum ath5k_debug_level level;
	const char *name;
	const char *desc;
} dbg_info[] = {
	{ ATH5K_DEBUG_RESET,	"reset",	"reset and initialization" },
	{ ATH5K_DEBUG_INTR,	"intr",		"interrupt handling" },
	{ ATH5K_DEBUG_MODE,	"mode",		"mode init/setup" },
	{ ATH5K_DEBUG_XMIT,	"xmit",		"basic xmit operation" },
	{ ATH5K_DEBUG_BEACON,	"beacon",	"beacon handling" },
	{ ATH5K_DEBUG_CALIBRATE, "calib",	"periodic calibration" },
	{ ATH5K_DEBUG_TXPOWER,	"txpower",	"transmit power setting" },
	{ ATH5K_DEBUG_LED,	"led",		"LED management" },
	{ ATH5K_DEBUG_DUMPBANDS, "dumpbands",	"dump bands" },
	{ ATH5K_DEBUG_DMA,	"dma",		"dma start/stop" },
	{ ATH5K_DEBUG_ANI,	"ani",		"adaptive noise immunity" },
	{ ATH5K_DEBUG_DESC,	"desc",		"descriptor chains" },
	{ ATH5K_DEBUG_ANY,	"all",		"show all debug levels" },
};

static ssize_t read_file_debug(struct file *file, char __user *user_buf,
				   size_t count, loff_t *ppos)
{
	struct ath5k_hw *ah = file->private_data;
	char buf[700];
	unsigned int len = 0;
	unsigned int i;

	len += scnprintf(buf + len, sizeof(buf) - len,
		"DEBUG LEVEL: 0x%08x\n\n", ah->debug.level);

	for (i = 0; i < ARRAY_SIZE(dbg_info) - 1; i++) {
		len += scnprintf(buf + len, sizeof(buf) - len,
			"%10s %c 0x%08x - %s\n", dbg_info[i].name,
			ah->debug.level & dbg_info[i].level ? '+' : ' ',
			dbg_info[i].level, dbg_info[i].desc);
	}
	len += scnprintf(buf + len, sizeof(buf) - len,
		"%10s %c 0x%08x - %s\n", dbg_info[i].name,
		ah->debug.level == dbg_info[i].level ? '+' : ' ',
		dbg_info[i].level, dbg_info[i].desc);

	if (len > sizeof(buf))
		len = sizeof(buf);

	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
}

static ssize_t write_file_debug(struct file *file,
				 const char __user *userbuf,
				 size_t count, loff_t *ppos)
{
	struct ath5k_hw *ah = file->private_data;
	unsigned int i;
	char buf[20];

	count = min_t(size_t, count, sizeof(buf) - 1);
	if (copy_from_user(buf, userbuf, count))
		return -EFAULT;

Annotation

Implementation Notes