drivers/mmc/core/mmc_ops.c
Source file repositories/reference/linux-study-clean/drivers/mmc/core/mmc_ops.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/core/mmc_ops.c- Extension
.c- Size
- 27872 bytes
- Lines
- 1152
- Domain
- Driver Families
- Bucket
- drivers/mmc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/slab.hlinux/export.hlinux/types.hlinux/scatterlist.hlinux/mmc/host.hlinux/mmc/card.hlinux/mmc/mmc.hcore.hcard.hhost.hmmc_ops.h
Detected Declarations
struct mmc_busy_datastruct mmc_op_cond_busy_datafunction __mmc_send_statusfunction mmc_send_statusfunction _mmc_select_cardfunction mmc_select_cardfunction mmc_deselect_cardsfunction mmc_set_dsrfunction __mmc_go_idlefunction mmc_go_idlefunction __mmc_send_op_cond_cbfunction mmc_send_op_condfunction mmc_set_relative_addrfunction mmc_send_cxd_nativefunction mmc_send_adtc_datafunction mmc_spi_send_cxdfunction mmc_send_csdfunction mmc_send_cidfunction mmc_get_ext_csdfunction mmc_spi_read_ocrfunction mmc_spi_set_crcfunction mmc_switch_status_errorfunction mmc_switch_statusfunction mmc_busy_cbfunction __mmc_poll_for_busyfunction mmc_poll_for_busyfunction mmc_prepare_busy_cmdfunction __mmc_switchfunction mmc_switchfunction mmc_send_tuningfunction mmc_send_abort_tuningfunction mmc_send_bus_testfunction mmc_bus_testfunction mmc_send_hpi_cmdfunction mmc_interrupt_hpifunction mmc_card_can_ext_csdfunction mmc_read_bkops_statusfunction mmc_run_bkopsfunction mmc_cmdq_switchfunction mmc_cmdq_enablefunction mmc_cmdq_disablefunction mmc_sanitizefunction mmc_read_tuningexport __mmc_send_statusexport mmc_send_statusexport mmc_get_ext_csdexport __mmc_poll_for_busyexport mmc_poll_for_busy
Annotated Snippet
struct mmc_busy_data {
struct mmc_card *card;
bool retry_crc_err;
enum mmc_busy_cmd busy_cmd;
};
struct mmc_op_cond_busy_data {
struct mmc_host *host;
u32 ocr;
struct mmc_command *cmd;
};
int __mmc_send_status(struct mmc_card *card, u32 *status, unsigned int retries)
{
int err;
struct mmc_command cmd = {};
cmd.opcode = MMC_SEND_STATUS;
if (!mmc_host_is_spi(card->host))
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC;
err = mmc_wait_for_cmd(card->host, &cmd, retries);
if (err)
return err;
/* NOTE: callers are required to understand the difference
* between "native" and SPI format status words!
*/
if (status)
*status = cmd.resp[0];
return 0;
}
EXPORT_SYMBOL_GPL(__mmc_send_status);
int mmc_send_status(struct mmc_card *card, u32 *status)
{
return __mmc_send_status(card, status, MMC_CMD_RETRIES);
}
EXPORT_SYMBOL_GPL(mmc_send_status);
static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card)
{
struct mmc_command cmd = {};
cmd.opcode = MMC_SELECT_CARD;
if (card) {
cmd.arg = card->rca << 16;
cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
} else {
cmd.arg = 0;
cmd.flags = MMC_RSP_NONE | MMC_CMD_AC;
}
return mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
}
int mmc_select_card(struct mmc_card *card)
{
return _mmc_select_card(card->host, card);
}
int mmc_deselect_cards(struct mmc_host *host)
{
return _mmc_select_card(host, NULL);
}
/*
* Write the value specified in the device tree or board code into the optional
* 16 bit Driver Stage Register. This can be used to tune raise/fall times and
* drive strength of the DAT and CMD outputs. The actual meaning of a given
* value is hardware dependant.
* The presence of the DSR register can be determined from the CSD register,
* bit 76.
*/
int mmc_set_dsr(struct mmc_host *host)
{
struct mmc_command cmd = {};
cmd.opcode = MMC_SET_DSR;
cmd.arg = (host->dsr << 16) | 0xffff;
cmd.flags = MMC_RSP_NONE | MMC_CMD_AC;
return mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES);
}
Annotation
- Immediate include surface: `linux/slab.h`, `linux/export.h`, `linux/types.h`, `linux/scatterlist.h`, `linux/mmc/host.h`, `linux/mmc/card.h`, `linux/mmc/mmc.h`, `core.h`.
- Detected declarations: `struct mmc_busy_data`, `struct mmc_op_cond_busy_data`, `function __mmc_send_status`, `function mmc_send_status`, `function _mmc_select_card`, `function mmc_select_card`, `function mmc_deselect_cards`, `function mmc_set_dsr`, `function __mmc_go_idle`, `function mmc_go_idle`.
- Atlas domain: Driver Families / drivers/mmc.
- Implementation status: integration 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.