drivers/usb/mtu3/mtu3_debugfs.c
Source file repositories/reference/linux-study-clean/drivers/usb/mtu3/mtu3_debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/mtu3/mtu3_debugfs.c- Extension
.c- Size
- 13388 bytes
- Lines
- 516
- 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/string_choices.hlinux/uaccess.hmtu3.hmtu3_dr.hmtu3_debug.h
Detected Declarations
function mtu3_link_state_showfunction mtu3_ep_used_showfunction mtu3_debugfs_regsetfunction mtu3_debugfs_ep_regsetfunction mtu3_ep_info_showfunction mtu3_fifo_showfunction mtu3_qmu_ring_showfunction mtu3_qmu_gpd_showfunction mtu3_ep_openfunction mtu3_probe_showfunction mtu3_probe_openfunction mtu3_probe_writefunction mtu3_debugfs_create_prb_filesfunction mtu3_debugfs_create_ep_dirfunction mtu3_debugfs_create_ep_dirsfunction ssusb_dev_debugfs_initfunction ssusb_mode_showfunction ssusb_mode_openfunction ssusb_mode_writefunction ssusb_vbus_showfunction ssusb_vbus_openfunction ssusb_vbus_writefunction ssusb_dr_debugfs_initfunction ssusb_debugfs_create_rootfunction ssusb_debugfs_remove_root
Annotated Snippet
static const struct file_operations mtu3_ep_fops = {
.open = mtu3_ep_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static const struct debugfs_reg32 mtu3_prb_regs[] = {
dump_prb_reg("enable", U3D_SSUSB_PRB_CTRL0),
dump_prb_reg("byte-sell", U3D_SSUSB_PRB_CTRL1),
dump_prb_reg("byte-selh", U3D_SSUSB_PRB_CTRL2),
dump_prb_reg("module-sel", U3D_SSUSB_PRB_CTRL3),
dump_prb_reg("sw-out", U3D_SSUSB_PRB_CTRL4),
dump_prb_reg("data", U3D_SSUSB_PRB_CTRL5),
};
static int mtu3_probe_show(struct seq_file *sf, void *unused)
{
struct mtu3 *mtu = sf->private;
const struct debugfs_reg32 *regs = debugfs_get_aux(sf->file);
seq_printf(sf, "0x%04x - 0x%08x\n", (u32)regs->offset,
mtu3_readl(mtu->ippc_base, (u32)regs->offset));
return 0;
}
static int mtu3_probe_open(struct inode *inode, struct file *file)
{
return single_open(file, mtu3_probe_show, inode->i_private);
}
static ssize_t mtu3_probe_write(struct file *file, const char __user *ubuf,
size_t count, loff_t *ppos)
{
struct seq_file *sf = file->private_data;
struct mtu3 *mtu = sf->private;
const struct debugfs_reg32 *regs = debugfs_get_aux(file);
char buf[32];
u32 val;
if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
return -EFAULT;
if (kstrtou32(buf, 0, &val))
return -EINVAL;
mtu3_writel(mtu->ippc_base, (u32)regs->offset, val);
return count;
}
static const struct file_operations mtu3_probe_fops = {
.open = mtu3_probe_open,
.write = mtu3_probe_write,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static void mtu3_debugfs_create_prb_files(struct mtu3 *mtu)
{
struct ssusb_mtk *ssusb = mtu->ssusb;
const struct debugfs_reg32 *regs;
struct dentry *dir_prb;
int i;
dir_prb = debugfs_create_dir("probe", ssusb->dbgfs_root);
for (i = 0; i < ARRAY_SIZE(mtu3_prb_regs); i++) {
regs = &mtu3_prb_regs[i];
debugfs_create_file_aux(regs->name, 0644, dir_prb,
mtu, regs, &mtu3_probe_fops);
}
mtu3_debugfs_regset(mtu, mtu->ippc_base, mtu3_prb_regs,
ARRAY_SIZE(mtu3_prb_regs), "regs", dir_prb);
}
static void mtu3_debugfs_create_ep_dir(struct mtu3_ep *mep,
struct dentry *parent)
{
const struct mtu3_file_map *files;
struct dentry *dir_ep;
int i;
dir_ep = debugfs_create_dir(mep->name, parent);
mtu3_debugfs_ep_regset(mep->mtu, mep, dir_ep);
for (i = 0; i < ARRAY_SIZE(mtu3_ep_files); i++) {
Annotation
- Immediate include surface: `linux/string_choices.h`, `linux/uaccess.h`, `mtu3.h`, `mtu3_dr.h`, `mtu3_debug.h`.
- Detected declarations: `function mtu3_link_state_show`, `function mtu3_ep_used_show`, `function mtu3_debugfs_regset`, `function mtu3_debugfs_ep_regset`, `function mtu3_ep_info_show`, `function mtu3_fifo_show`, `function mtu3_qmu_ring_show`, `function mtu3_qmu_gpd_show`, `function mtu3_ep_open`, `function mtu3_probe_show`.
- 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.