drivers/net/wireless/silabs/wfx/debug.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/silabs/wfx/debug.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/silabs/wfx/debug.c- Extension
.c- Size
- 8801 bytes
- Lines
- 332
- 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.
- 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/debugfs.hlinux/seq_file.hlinux/crc32.hdebug.hwfx.hsta.hmain.hhif_tx.hhif_tx_mib.htraces.h
Detected Declarations
struct dbgfs_hif_msgfunction wfx_counters_showfunction wfx_rx_stats_showfunction wfx_tx_power_loop_showfunction wfx_send_pds_writefunction wfx_send_hif_msg_writefunction wfx_send_hif_msg_readfunction wfx_send_hif_msg_openfunction wfx_send_hif_msg_releasefunction wfx_debug_init
Annotated Snippet
static const struct file_operations wfx_send_pds_fops = {
.open = simple_open,
.write = wfx_send_pds_write,
};
struct dbgfs_hif_msg {
struct wfx_dev *wdev;
struct completion complete;
u8 reply[1024];
int ret;
};
static ssize_t wfx_send_hif_msg_write(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos)
{
struct dbgfs_hif_msg *context = file->private_data;
struct wfx_dev *wdev = context->wdev;
struct wfx_hif_msg *request;
if (completion_done(&context->complete)) {
dev_dbg(wdev->dev, "read previous result before start a new one\n");
return -EBUSY;
}
if (count < sizeof(struct wfx_hif_msg))
return -EINVAL;
/* wfx_cmd_send() checks that reply buffer is wide enough, but does not return precise
* length read. User have to know how many bytes should be read. Filling reply buffer with a
* memory pattern may help user.
*/
memset(context->reply, 0xFF, sizeof(context->reply));
request = memdup_user(user_buf, count);
if (IS_ERR(request))
return PTR_ERR(request);
if (le16_to_cpu(request->len) != count) {
kfree(request);
return -EINVAL;
}
context->ret = wfx_cmd_send(wdev, request, context->reply, sizeof(context->reply), false);
kfree(request);
complete(&context->complete);
return count;
}
static ssize_t wfx_send_hif_msg_read(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
struct dbgfs_hif_msg *context = file->private_data;
int ret;
if (count > sizeof(context->reply))
return -EINVAL;
ret = wait_for_completion_interruptible(&context->complete);
if (ret)
return ret;
if (context->ret < 0)
return context->ret;
/* Be careful, write() is waiting for a full message while read() only returns a payload */
if (copy_to_user(user_buf, context->reply, count))
return -EFAULT;
return count;
}
static int wfx_send_hif_msg_open(struct inode *inode, struct file *file)
{
struct dbgfs_hif_msg *context = kzalloc_obj(*context);
if (!context)
return -ENOMEM;
context->wdev = inode->i_private;
init_completion(&context->complete);
file->private_data = context;
return 0;
}
static int wfx_send_hif_msg_release(struct inode *inode, struct file *file)
{
struct dbgfs_hif_msg *context = file->private_data;
kfree(context);
return 0;
}
static const struct file_operations wfx_send_hif_msg_fops = {
.open = wfx_send_hif_msg_open,
.release = wfx_send_hif_msg_release,
.write = wfx_send_hif_msg_write,
.read = wfx_send_hif_msg_read,
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/seq_file.h`, `linux/crc32.h`, `debug.h`, `wfx.h`, `sta.h`, `main.h`, `hif_tx.h`.
- Detected declarations: `struct dbgfs_hif_msg`, `function wfx_counters_show`, `function wfx_rx_stats_show`, `function wfx_tx_power_loop_show`, `function wfx_send_pds_write`, `function wfx_send_hif_msg_write`, `function wfx_send_hif_msg_read`, `function wfx_send_hif_msg_open`, `function wfx_send_hif_msg_release`, `function wfx_debug_init`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.