drivers/net/wireless/ath/carl9170/debug.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/ath/carl9170/debug.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/ath/carl9170/debug.c- Extension
.c- Size
- 23725 bytes
- Lines
- 883
- 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/slab.hlinux/module.hlinux/seq_file.hlinux/vmalloc.hcarl9170.hcmd.h
Detected Declarations
struct carl9170_debugfs_fopsfunction carl9170_debugfs_readfunction carl9170_debugfs_writefunction carl9170_debugfs_format_framefunction skb_queue_walkfunction carl9170_debugfs_queue_dumpfunction carl9170_debugfs_hw_ioread32_writefunction carl9170_debugfs_bug_writefunction carl9170_debugfs_erp_writefunction carl9170_debugfs_hw_iowrite32_writefunction carl9170_debugfs_registerfunction carl9170_debugfs_unregister
Annotated Snippet
struct carl9170_debugfs_fops {
unsigned int read_bufsize;
umode_t attr;
char *(*read)(struct ar9170 *ar, char *buf, size_t bufsize,
ssize_t *len);
ssize_t (*write)(struct ar9170 *aru, const char *buf, size_t size);
enum carl9170_device_state req_dev_state;
};
static ssize_t carl9170_debugfs_read(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos)
{
const struct carl9170_debugfs_fops *dfops;
struct ar9170 *ar;
char *buf = NULL, *res_buf = NULL;
ssize_t ret = 0;
int err = 0;
if (!count)
return 0;
ar = file->private_data;
if (!ar)
return -ENODEV;
dfops = debugfs_get_aux(file);
if (!dfops->read)
return -ENOSYS;
if (dfops->read_bufsize) {
buf = vmalloc(dfops->read_bufsize);
if (!buf)
return -ENOMEM;
}
mutex_lock(&ar->mutex);
if (!CHK_DEV_STATE(ar, dfops->req_dev_state)) {
err = -ENODEV;
res_buf = buf;
goto out_free;
}
res_buf = dfops->read(ar, buf, dfops->read_bufsize, &ret);
if (ret > 0)
err = simple_read_from_buffer(userbuf, count, ppos,
res_buf, ret);
else
err = ret;
WARN_ON_ONCE(dfops->read_bufsize && (res_buf != buf));
out_free:
vfree(res_buf);
mutex_unlock(&ar->mutex);
return err;
}
static ssize_t carl9170_debugfs_write(struct file *file,
const char __user *userbuf, size_t count, loff_t *ppos)
{
const struct carl9170_debugfs_fops *dfops;
struct ar9170 *ar;
char *buf = NULL;
int err = 0;
if (!count)
return 0;
if (count > PAGE_SIZE)
return -E2BIG;
ar = file->private_data;
if (!ar)
return -ENODEV;
dfops = debugfs_get_aux(file);
if (!dfops->write)
return -ENOSYS;
buf = vmalloc(count);
if (!buf)
return -ENOMEM;
if (copy_from_user(buf, userbuf, count)) {
err = -EFAULT;
goto out_free;
Annotation
- Immediate include surface: `linux/slab.h`, `linux/module.h`, `linux/seq_file.h`, `linux/vmalloc.h`, `carl9170.h`, `cmd.h`.
- Detected declarations: `struct carl9170_debugfs_fops`, `function carl9170_debugfs_read`, `function carl9170_debugfs_write`, `function carl9170_debugfs_format_frame`, `function skb_queue_walk`, `function carl9170_debugfs_queue_dump`, `function carl9170_debugfs_hw_ioread32_write`, `function carl9170_debugfs_bug_write`, `function carl9170_debugfs_erp_write`, `function carl9170_debugfs_hw_iowrite32_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.