drivers/mmc/core/debugfs.c
Source file repositories/reference/linux-study-clean/drivers/mmc/core/debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/core/debugfs.c- Extension
.c- Size
- 9178 bytes
- Lines
- 406
- Domain
- Driver Families
- Bucket
- drivers/mmc
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/moduleparam.hlinux/export.hlinux/debugfs.hlinux/fs.hlinux/seq_file.hlinux/slab.hlinux/stat.hlinux/fault-inject.hlinux/time.hlinux/mmc/card.hlinux/mmc/host.hlinux/mmc/mmc.hlinux/mmc/sd.hcore.hcard.hhost.hmmc_ops.h
Detected Declarations
function mmc_ios_showfunction mmc_clock_opt_getfunction mmc_clock_opt_setfunction mmc_err_state_getfunction mmc_err_stats_showfunction mmc_err_stats_openfunction mmc_err_stats_writefunction mmc_caps_getfunction mmc_caps_setfunction mmc_caps2_setfunction mmc_add_host_debugfsfunction mmc_remove_host_debugfsfunction mmc_add_card_debugfsfunction mmc_remove_card_debugfs
Annotated Snippet
static const struct file_operations mmc_err_stats_fops = {
.open = mmc_err_stats_open,
.read = seq_read,
.write = mmc_err_stats_write,
.release = single_release,
};
static int mmc_caps_get(void *data, u64 *val)
{
*val = *(u32 *)data;
return 0;
}
static int mmc_caps_set(void *data, u64 val)
{
u32 *caps = data;
u32 diff = *caps ^ val;
u32 allowed = MMC_CAP_AGGRESSIVE_PM |
MMC_CAP_SD_HIGHSPEED |
MMC_CAP_MMC_HIGHSPEED |
MMC_CAP_UHS |
MMC_CAP_DDR |
MMC_CAP_4_BIT_DATA |
MMC_CAP_8_BIT_DATA |
MMC_CAP_CMD23;
if (diff & ~allowed)
return -EINVAL;
*caps = val;
return 0;
}
static int mmc_caps2_set(void *data, u64 val)
{
u32 allowed = MMC_CAP2_HSX00_1_8V |
MMC_CAP2_HSX00_1_2V |
MMC_CAP2_CQE |
MMC_CAP2_CQE_DCMD;
u32 *caps = data;
u32 diff = *caps ^ val;
if (diff & ~allowed)
return -EINVAL;
*caps = val;
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(mmc_caps_fops, mmc_caps_get, mmc_caps_set,
"0x%08llx\n");
DEFINE_DEBUGFS_ATTRIBUTE(mmc_caps2_fops, mmc_caps_get, mmc_caps2_set,
"0x%08llx\n");
void mmc_add_host_debugfs(struct mmc_host *host)
{
struct dentry *root;
root = debugfs_create_dir(mmc_hostname(host), NULL);
host->debugfs_root = root;
debugfs_create_file("ios", 0400, root, host, &mmc_ios_fops);
debugfs_create_file("caps", 0600, root, &host->caps, &mmc_caps_fops);
debugfs_create_file("caps2", 0600, root, &host->caps2,
&mmc_caps2_fops);
debugfs_create_file_unsafe("clock", 0600, root, host,
&mmc_clock_fops);
debugfs_create_file_unsafe("err_state", 0600, root, host,
&mmc_err_state);
debugfs_create_file("err_stats", 0600, root, host,
&mmc_err_stats_fops);
#ifdef CONFIG_FAIL_MMC_REQUEST
if (fail_request)
setup_fault_attr(&fail_default_attr, fail_request);
host->fail_mmc_request = fail_default_attr;
fault_create_debugfs_attr("fail_mmc_request", root,
&host->fail_mmc_request);
#endif
}
void mmc_remove_host_debugfs(struct mmc_host *host)
{
debugfs_remove_recursive(host->debugfs_root);
}
void mmc_add_card_debugfs(struct mmc_card *card)
Annotation
- Immediate include surface: `linux/moduleparam.h`, `linux/export.h`, `linux/debugfs.h`, `linux/fs.h`, `linux/seq_file.h`, `linux/slab.h`, `linux/stat.h`, `linux/fault-inject.h`.
- Detected declarations: `function mmc_ios_show`, `function mmc_clock_opt_get`, `function mmc_clock_opt_set`, `function mmc_err_state_get`, `function mmc_err_stats_show`, `function mmc_err_stats_open`, `function mmc_err_stats_write`, `function mmc_caps_get`, `function mmc_caps_set`, `function mmc_caps2_set`.
- Atlas domain: Driver Families / drivers/mmc.
- Implementation status: pattern implementation candidate.
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.