drivers/mmc/core/mmc_test.c
Source file repositories/reference/linux-study-clean/drivers/mmc/core/mmc_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/core/mmc_test.c- Extension
.c- Size
- 74409 bytes
- Lines
- 3276
- 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.
- 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/mmc/core.hlinux/mmc/card.hlinux/mmc/host.hlinux/mmc/mmc.hlinux/slab.hlinux/scatterlist.hlinux/list.hlinux/debugfs.hlinux/uaccess.hlinux/seq_file.hlinux/module.hcore.hcard.hhost.hbus.hmmc_ops.h
Detected Declarations
struct mmc_test_pagesstruct mmc_test_memstruct mmc_test_areastruct mmc_test_transfer_resultstruct mmc_test_general_resultstruct mmc_test_dbgfs_filestruct mmc_test_cardstruct mmc_test_multiple_rwstruct mmc_test_reqstruct mmc_test_caseenum mmc_test_prep_mediafunction mmc_test_set_blksizefunction mmc_test_prepare_sbcfunction mmc_test_prepare_mrqfunction mmc_test_busyfunction mmc_test_wait_busyfunction mmc_test_buffer_transferfunction mmc_test_free_memfunction mmc_test_map_sgfunction mmc_test_map_sg_max_scatterfunction mmc_test_ratefunction mmc_test_save_transfer_resultfunction mmc_test_print_ratefunction mmc_test_print_avg_ratefunction mmc_test_capacityfunction __mmc_test_preparefunction mmc_test_prepare_writefunction mmc_test_prepare_readfunction mmc_test_cleanupfunction mmc_test_prepare_broken_mrqfunction mmc_test_check_resultfunction mmc_test_check_broken_resultfunction mmc_test_req_resetfunction mmc_test_wait_donefunction mmc_test_start_areqfunction mmc_test_nonblock_transferfunction mmc_test_simple_transferfunction mmc_test_broken_transferfunction mmc_test_transferfunction mmc_test_basic_writefunction mmc_test_basic_readfunction mmc_test_verify_writefunction mmc_test_verify_readfunction mmc_test_multi_writefunction mmc_test_multi_readfunction mmc_test_pow2_writefunction mmc_test_pow2_readfunction mmc_test_weird_write
Annotated Snippet
static const struct file_operations mmc_test_fops_test = {
.open = mtf_test_open,
.read = seq_read,
.write = mtf_test_write,
.llseek = seq_lseek,
.release = single_release,
};
static int mtf_testlist_show(struct seq_file *sf, void *data)
{
int i;
mutex_lock(&mmc_test_lock);
seq_puts(sf, "0:\tRun all tests\n");
for (i = 0; i < ARRAY_SIZE(mmc_test_cases); i++)
seq_printf(sf, "%d:\t%s\n", i + 1, mmc_test_cases[i].name);
mutex_unlock(&mmc_test_lock);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(mtf_testlist);
static void mmc_test_free_dbgfs_file(struct mmc_card *card)
{
struct mmc_test_dbgfs_file *df, *dfs;
mutex_lock(&mmc_test_lock);
list_for_each_entry_safe(df, dfs, &mmc_test_file_test, link) {
if (card && df->card != card)
continue;
debugfs_remove(df->file);
list_del(&df->link);
kfree(df);
}
mutex_unlock(&mmc_test_lock);
}
static int __mmc_test_register_dbgfs_file(struct mmc_card *card,
const char *name, umode_t mode, const struct file_operations *fops)
{
struct dentry *file = NULL;
struct mmc_test_dbgfs_file *df;
if (card->debugfs_root)
file = debugfs_create_file(name, mode, card->debugfs_root,
card, fops);
df = kmalloc_obj(*df);
if (!df) {
debugfs_remove(file);
return -ENOMEM;
}
df->card = card;
df->file = file;
list_add(&df->link, &mmc_test_file_test);
return 0;
}
static int mmc_test_register_dbgfs_file(struct mmc_card *card)
{
int ret;
mutex_lock(&mmc_test_lock);
ret = __mmc_test_register_dbgfs_file(card, "test", 0644,
&mmc_test_fops_test);
if (ret)
goto err;
ret = __mmc_test_register_dbgfs_file(card, "testlist", 0444,
&mtf_testlist_fops);
if (ret)
goto err;
err:
mutex_unlock(&mmc_test_lock);
return ret;
}
static int mmc_test_probe(struct mmc_card *card)
{
int ret;
Annotation
- Immediate include surface: `linux/mmc/core.h`, `linux/mmc/card.h`, `linux/mmc/host.h`, `linux/mmc/mmc.h`, `linux/slab.h`, `linux/scatterlist.h`, `linux/list.h`, `linux/debugfs.h`.
- Detected declarations: `struct mmc_test_pages`, `struct mmc_test_mem`, `struct mmc_test_area`, `struct mmc_test_transfer_result`, `struct mmc_test_general_result`, `struct mmc_test_dbgfs_file`, `struct mmc_test_card`, `struct mmc_test_multiple_rw`, `struct mmc_test_req`, `struct mmc_test_case`.
- Atlas domain: Driver Families / drivers/mmc.
- Implementation status: pattern implementation candidate.
- 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.