drivers/net/wireless/broadcom/b43/debugfs.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/broadcom/b43/debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/broadcom/b43/debugfs.c- Extension
.c- Size
- 17393 bytes
- Lines
- 768
- 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.hb43.hmain.hdebugfs.hdma.hxmit.h
Detected Declarations
struct b43_debugfs_fopsfunction shm16read__read_filefunction shm16read__write_filefunction shm16write__write_filefunction shm32read__read_filefunction shm32read__write_filefunction shm32write__write_filefunction mmio16read__read_filefunction mmio16read__write_filefunction mmio16write__write_filefunction mmio32read__read_filefunction mmio32read__write_filefunction mmio32write__write_filefunction txstat_read_filefunction restart_write_filefunction calc_expire_secsfunction loctls_read_filefunction b43_debugfs_readfunction b43_debugfs_writefunction b43_debugfunction b43_add_dynamic_debugfunction b43_debugfs_add_devicefunction b43_debugfs_remove_devicefunction b43_debugfs_log_txstatfunction b43_debugfs_initfunction b43_debugfs_exit
Annotated Snippet
struct b43_debugfs_fops {
ssize_t (*read)(struct b43_wldev *dev, char *buf, size_t bufsize);
int (*write)(struct b43_wldev *dev, const char *buf, size_t count);
/* Offset of struct b43_dfs_file in struct b43_dfsentry */
size_t file_struct_offset;
};
static inline
struct b43_dfs_file *fops_to_dfs_file(struct b43_wldev *dev,
const struct b43_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 "b43: fappend overflow\n"); \
} while (0)
/* The biggest address values for SHM access from the debugfs files. */
#define B43_MAX_SHM_ROUTING 4
#define B43_MAX_SHM_ADDR 0xFFFF
static ssize_t shm16read__read_file(struct b43_wldev *dev,
char *buf, size_t bufsize)
{
ssize_t count = 0;
unsigned int routing, addr;
u16 val;
routing = dev->dfsentry->shm16read_routing_next;
addr = dev->dfsentry->shm16read_addr_next;
if ((routing > B43_MAX_SHM_ROUTING) ||
(addr > B43_MAX_SHM_ADDR))
return -EDESTADDRREQ;
val = b43_shm_read16(dev, routing, addr);
fappend("0x%04X\n", val);
return count;
}
static int shm16read__write_file(struct b43_wldev *dev,
const char *buf, size_t count)
{
unsigned int routing, addr;
int res;
res = sscanf(buf, "0x%X 0x%X", &routing, &addr);
if (res != 2)
return -EINVAL;
if (routing > B43_MAX_SHM_ROUTING)
return -EADDRNOTAVAIL;
if (addr > B43_MAX_SHM_ADDR)
return -EADDRNOTAVAIL;
if (routing == B43_SHM_SHARED) {
if ((addr % 2) != 0)
return -EADDRNOTAVAIL;
}
dev->dfsentry->shm16read_routing_next = routing;
dev->dfsentry->shm16read_addr_next = addr;
return 0;
}
static int shm16write__write_file(struct b43_wldev *dev,
const char *buf, size_t count)
{
unsigned int routing, addr, mask, set;
u16 val;
int res;
res = sscanf(buf, "0x%X 0x%X 0x%X 0x%X",
&routing, &addr, &mask, &set);
if (res != 4)
return -EINVAL;
if (routing > B43_MAX_SHM_ROUTING)
Annotation
- Immediate include surface: `linux/fs.h`, `linux/debugfs.h`, `linux/slab.h`, `linux/netdevice.h`, `linux/pci.h`, `linux/mutex.h`, `b43.h`, `main.h`.
- Detected declarations: `struct b43_debugfs_fops`, `function shm16read__read_file`, `function shm16read__write_file`, `function shm16write__write_file`, `function shm32read__read_file`, `function shm32read__write_file`, `function shm32write__write_file`, `function mmio16read__read_file`, `function mmio16read__write_file`, `function mmio16write__write_file`.
- 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.