drivers/mmc/host/of_mmc_spi.c
Source file repositories/reference/linux-study-clean/drivers/mmc/host/of_mmc_spi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/host/of_mmc_spi.c- Extension
.c- Size
- 2390 bytes
- Lines
- 99
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/kernel.hlinux/module.hlinux/device.hlinux/slab.hlinux/irq.hlinux/of.hlinux/of_irq.hlinux/spi/spi.hlinux/spi/mmc_spi.hlinux/mmc/core.hlinux/mmc/host.h
Detected Declarations
struct of_mmc_spifunction of_mmc_spi_initfunction of_mmc_spi_exitfunction mmc_spi_put_pdataexport mmc_spi_get_pdataexport mmc_spi_put_pdata
Annotated Snippet
struct of_mmc_spi {
struct mmc_spi_platform_data pdata;
int detect_irq;
};
static struct of_mmc_spi *to_of_mmc_spi(struct device *dev)
{
return container_of(dev->platform_data, struct of_mmc_spi, pdata);
}
static int of_mmc_spi_init(struct device *dev,
irqreturn_t (*irqhandler)(int, void *), void *mmc)
{
struct of_mmc_spi *oms = to_of_mmc_spi(dev);
return request_threaded_irq(oms->detect_irq, NULL, irqhandler,
IRQF_ONESHOT, dev_name(dev), mmc);
}
static void of_mmc_spi_exit(struct device *dev, void *mmc)
{
struct of_mmc_spi *oms = to_of_mmc_spi(dev);
free_irq(oms->detect_irq, mmc);
}
struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi)
{
struct mmc_host *mmc = dev_get_drvdata(&spi->dev);
struct device *dev = &spi->dev;
struct of_mmc_spi *oms;
if (dev->platform_data || !dev_fwnode(dev))
return dev->platform_data;
oms = kzalloc_obj(*oms);
if (!oms)
return NULL;
if (mmc_of_parse_voltage(mmc, &oms->pdata.ocr_mask) < 0)
goto err_ocr;
oms->detect_irq = spi->irq;
if (oms->detect_irq > 0) {
oms->pdata.init = of_mmc_spi_init;
oms->pdata.exit = of_mmc_spi_exit;
} else {
oms->pdata.caps |= MMC_CAP_NEEDS_POLL;
}
if (device_property_read_bool(dev, "cap-sd-highspeed"))
oms->pdata.caps |= MMC_CAP_SD_HIGHSPEED;
if (device_property_read_bool(dev, "cap-mmc-highspeed"))
oms->pdata.caps |= MMC_CAP_MMC_HIGHSPEED;
dev->platform_data = &oms->pdata;
return dev->platform_data;
err_ocr:
kfree(oms);
return NULL;
}
EXPORT_SYMBOL(mmc_spi_get_pdata);
void mmc_spi_put_pdata(struct spi_device *spi)
{
struct device *dev = &spi->dev;
struct of_mmc_spi *oms = to_of_mmc_spi(dev);
if (!dev->platform_data || !dev_fwnode(dev))
return;
kfree(oms);
dev->platform_data = NULL;
}
EXPORT_SYMBOL(mmc_spi_put_pdata);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/device.h`, `linux/slab.h`, `linux/irq.h`, `linux/of.h`, `linux/of_irq.h`, `linux/spi/spi.h`.
- Detected declarations: `struct of_mmc_spi`, `function of_mmc_spi_init`, `function of_mmc_spi_exit`, `function mmc_spi_put_pdata`, `export mmc_spi_get_pdata`, `export mmc_spi_put_pdata`.
- Atlas domain: Driver Families / drivers/mmc.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.