drivers/net/wireless/ti/wl1251/debugfs.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/ti/wl1251/debugfs.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/ti/wl1251/debugfs.c
Extension
.c
Size
15927 bytes
Lines
477
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 name## _ops = {			\
	.read = name## _read,						\
	.open = simple_open,						\
	.llseek	= generic_file_llseek,					\
};

#define DEBUGFS_ADD(name, parent)					\
	wl->debugfs.name = debugfs_create_file(#name, 0400, parent,	\
					       wl, &name## _ops)	\

#define DEBUGFS_DEL(name)						\
	do {								\
		debugfs_remove(wl->debugfs.name);			\
		wl->debugfs.name = NULL;				\
	} while (0)

#define DEBUGFS_FWSTATS_FILE(sub, name, buflen, fmt)			\
static ssize_t sub## _ ##name## _read(struct file *file,		\
				      char __user *userbuf,		\
				      size_t count, loff_t *ppos)	\
{									\
	struct wl1251 *wl = file->private_data;				\
	char buf[buflen];						\
	int res;							\
									\
	wl1251_debugfs_update_stats(wl);				\
									\
	res = scnprintf(buf, buflen, fmt "\n",				\
			wl->stats.fw_stats->sub.name);			\
	return simple_read_from_buffer(userbuf, count, ppos, buf, res);	\
}									\
									\
static const struct file_operations sub## _ ##name## _ops = {		\
	.read = sub## _ ##name## _read,					\
	.open = simple_open,						\
	.llseek	= generic_file_llseek,					\
};

#define DEBUGFS_FWSTATS_ADD(sub, name)				\
	DEBUGFS_ADD(sub## _ ##name, wl->debugfs.fw_statistics)

#define DEBUGFS_FWSTATS_DEL(sub, name)				\
	DEBUGFS_DEL(sub## _ ##name)

static void wl1251_debugfs_update_stats(struct wl1251 *wl)
{
	int ret;

	mutex_lock(&wl->mutex);

	ret = wl1251_ps_elp_wakeup(wl);
	if (ret < 0)
		goto out;

	if (wl->state == WL1251_STATE_ON &&
	    time_after(jiffies, wl->stats.fw_stats_update +
		       msecs_to_jiffies(WL1251_DEBUGFS_STATS_LIFETIME))) {
		wl1251_acx_statistics(wl, wl->stats.fw_stats);
		wl->stats.fw_stats_update = jiffies;
	}

	wl1251_ps_elp_sleep(wl);

out:
	mutex_unlock(&wl->mutex);
}

DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, 20, "%u");

DEBUGFS_FWSTATS_FILE(rx, out_of_mem, 20, "%u");
DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, 20, "%u");
DEBUGFS_FWSTATS_FILE(rx, hw_stuck, 20, "%u");
DEBUGFS_FWSTATS_FILE(rx, dropped, 20, "%u");
DEBUGFS_FWSTATS_FILE(rx, fcs_err, 20, "%u");
DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, 20, "%u");
DEBUGFS_FWSTATS_FILE(rx, path_reset, 20, "%u");
DEBUGFS_FWSTATS_FILE(rx, reset_counter, 20, "%u");

DEBUGFS_FWSTATS_FILE(dma, rx_requested, 20, "%u");
DEBUGFS_FWSTATS_FILE(dma, rx_errors, 20, "%u");
DEBUGFS_FWSTATS_FILE(dma, tx_requested, 20, "%u");
DEBUGFS_FWSTATS_FILE(dma, tx_errors, 20, "%u");

DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, 20, "%u");
DEBUGFS_FWSTATS_FILE(isr, fiqs, 20, "%u");
DEBUGFS_FWSTATS_FILE(isr, rx_headers, 20, "%u");
DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, 20, "%u");
DEBUGFS_FWSTATS_FILE(isr, rx_rdys, 20, "%u");
DEBUGFS_FWSTATS_FILE(isr, irqs, 20, "%u");
DEBUGFS_FWSTATS_FILE(isr, tx_procs, 20, "%u");

Annotation

Implementation Notes