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.
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/debugfs.hlinux/slab.hlinux/netdevice.hlinux/pci.hlinux/mutex.hb43legacy.hmain.hdebugfs.hdma.hpio.hxmit.h
Detected Declarations
struct b43legacy_debugfs_fopsfunction fops_to_dfs_filefunction tsf_read_filefunction tsf_write_filefunction ucode_regs_read_filefunction shm_read_filefunction txstat_read_filefunction restart_write_filefunction b43legacy_debugfs_readfunction b43legacy_debugfs_writefunction b43legacy_debugfunction b43legacy_add_dynamic_debugfunction b43legacy_debugfs_add_devicefunction b43legacy_debugfs_remove_devicefunction b43legacy_debugfs_log_txstatfunction b43legacy_debugfs_initfunction b43legacy_debugfs_exit
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
- Immediate include surface: `linux/fs.h`, `linux/debugfs.h`, `linux/slab.h`, `linux/netdevice.h`, `linux/pci.h`, `linux/mutex.h`, `b43legacy.h`, `main.h`.
- Detected declarations: `struct b43legacy_debugfs_fops`, `function fops_to_dfs_file`, `function tsf_read_file`, `function tsf_write_file`, `function ucode_regs_read_file`, `function shm_read_file`, `function txstat_read_file`, `function restart_write_file`, `function b43legacy_debugfs_read`, `function b43legacy_debugfs_write`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.