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.

Dependency Surface

Detected Declarations

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

Implementation Notes