drivers/usb/mon/mon_text.c
Source file repositories/reference/linux-study-clean/drivers/usb/mon/mon_text.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/mon/mon_text.c- Extension
.c- Size
- 19469 bytes
- Lines
- 754
- Domain
- Driver Families
- Bucket
- drivers/usb
- 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/kernel.hlinux/list.hlinux/usb.hlinux/slab.hlinux/sched/signal.hlinux/time.hlinux/ktime.hlinux/export.hlinux/mutex.hlinux/debugfs.hlinux/scatterlist.hlinux/uaccess.husb_mon.h
Detected Declarations
struct mon_iso_descstruct mon_event_textstruct mon_reader_textstruct mon_text_ptrfunction mon_text_get_setupfunction mon_text_get_datafunction mon_get_timestampfunction mon_text_eventfunction mon_text_submitfunction mon_text_completefunction mon_text_errorfunction mon_text_openfunction mon_text_copy_to_userfunction mon_text_read_tfunction mon_text_read_ufunction mon_text_read_head_tfunction mon_text_read_head_ufunction mon_text_read_statsetfunction mon_text_read_intstatfunction mon_text_read_isostatfunction mon_text_read_isodescfunction mon_text_read_datafunction mon_text_releasefunction mon_text_addfunction mon_text_delfunction mon_text_ctorfunction mon_text_initfunction mon_text_exit
Annotated Snippet
static const struct file_operations mon_fops_text_t = {
.owner = THIS_MODULE,
.open = mon_text_open,
.read = mon_text_read_t,
.release = mon_text_release,
};
static const struct file_operations mon_fops_text_u = {
.owner = THIS_MODULE,
.open = mon_text_open,
.read = mon_text_read_u,
.release = mon_text_release,
};
int mon_text_add(struct mon_bus *mbus, const struct usb_bus *ubus)
{
enum { NAMESZ = 12 };
char name[NAMESZ];
int busnum = ubus? ubus->busnum: 0;
if (mon_dir == NULL)
return 0;
if (ubus != NULL) {
scnprintf(name, NAMESZ, "%dt", busnum);
mbus->dent_t = debugfs_create_file(name, 0600, mon_dir, mbus,
&mon_fops_text_t);
}
scnprintf(name, NAMESZ, "%du", busnum);
mbus->dent_u = debugfs_create_file(name, 0600, mon_dir, mbus,
&mon_fops_text_u);
scnprintf(name, NAMESZ, "%ds", busnum);
mbus->dent_s = debugfs_create_file(name, 0600, mon_dir, mbus,
&mon_fops_stat);
return 1;
}
void mon_text_del(struct mon_bus *mbus)
{
debugfs_remove(mbus->dent_u);
debugfs_remove(mbus->dent_t);
debugfs_remove(mbus->dent_s);
}
/*
* Slab interface: constructor.
*/
static void mon_text_ctor(void *mem)
{
/*
* Nothing to initialize. No, really!
* So, we fill it with garbage to emulate a reused object.
*/
memset(mem, 0xe5, sizeof(struct mon_event_text));
}
int __init mon_text_init(void)
{
mon_dir = debugfs_create_dir("usbmon", usb_debug_root);
return 0;
}
void mon_text_exit(void)
{
debugfs_remove(mon_dir);
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/list.h`, `linux/usb.h`, `linux/slab.h`, `linux/sched/signal.h`, `linux/time.h`, `linux/ktime.h`, `linux/export.h`.
- Detected declarations: `struct mon_iso_desc`, `struct mon_event_text`, `struct mon_reader_text`, `struct mon_text_ptr`, `function mon_text_get_setup`, `function mon_text_get_data`, `function mon_get_timestamp`, `function mon_text_event`, `function mon_text_submit`, `function mon_text_complete`.
- Atlas domain: Driver Families / drivers/usb.
- 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.