drivers/net/wireless/broadcom/b43legacy/debugfs.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/broadcom/b43legacy/debugfs.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/broadcom/b43legacy/debugfs.c
Extension
.c
Size
10205 bytes
Lines
448
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 b43legacy_debugfs_fops {
	ssize_t (*read)(struct b43legacy_wldev *dev, char *buf, size_t bufsize);
	int (*write)(struct b43legacy_wldev *dev, const char *buf, size_t count);
	/* Offset of struct b43legacy_dfs_file in struct b43legacy_dfsentry */
	size_t file_struct_offset;
	/* Take wl->irq_lock before calling read/write? */
	bool take_irqlock;
};

static inline
struct b43legacy_dfs_file * fops_to_dfs_file(struct b43legacy_wldev *dev,
				       const struct b43legacy_debugfs_fops *dfops)
{
	void *p;

	p = dev->dfsentry;
	p += dfops->file_struct_offset;

	return p;
}


#define fappend(fmt, x...)	\
	do {							\
		if (bufsize - count)				\
			count += scnprintf(buf + count,		\
					  bufsize - count,	\
					  fmt , ##x);		\
		else						\
			printk(KERN_ERR "b43legacy: fappend overflow\n"); \
	} while (0)


/* wl->irq_lock is locked */
static ssize_t tsf_read_file(struct b43legacy_wldev *dev, char *buf, size_t bufsize)
{
	ssize_t count = 0;
	u64 tsf;

	b43legacy_tsf_read(dev, &tsf);
	fappend("0x%08x%08x\n",
		(unsigned int)((tsf & 0xFFFFFFFF00000000ULL) >> 32),
		(unsigned int)(tsf & 0xFFFFFFFFULL));

	return count;
}

/* wl->irq_lock is locked */
static int tsf_write_file(struct b43legacy_wldev *dev, const char *buf, size_t count)
{
	u64 tsf;

	if (sscanf(buf, "%llu", (unsigned long long *)(&tsf)) != 1)
		return -EINVAL;
	b43legacy_tsf_write(dev, tsf);

	return 0;
}

/* wl->irq_lock is locked */
static ssize_t ucode_regs_read_file(struct b43legacy_wldev *dev, char *buf, size_t bufsize)
{
	ssize_t count = 0;
	int i;

	for (i = 0; i < 64; i++) {
		fappend("r%d = 0x%04x\n", i,
			b43legacy_shm_read16(dev, B43legacy_SHM_WIRELESS, i));
	}

	return count;
}

/* wl->irq_lock is locked */
static ssize_t shm_read_file(struct b43legacy_wldev *dev, char *buf, size_t bufsize)
{
	ssize_t count = 0;
	int i;
	u16 tmp;
	__le16 *le16buf = (__le16 *)buf;

	for (i = 0; i < 0x1000; i++) {
		if (bufsize < sizeof(tmp))
			break;
		tmp = b43legacy_shm_read16(dev, B43legacy_SHM_SHARED, 2 * i);
		le16buf[i] = cpu_to_le16(tmp);
		count += sizeof(tmp);
		bufsize -= sizeof(tmp);
	}

Annotation

Implementation Notes