drivers/mmc/core/bus.c
Source file repositories/reference/linux-study-clean/drivers/mmc/core/bus.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mmc/core/bus.c- Extension
.c- Size
- 9408 bytes
- Lines
- 430
- 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.
- 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/export.hlinux/device.hlinux/err.hlinux/slab.hlinux/stat.hlinux/of.hlinux/pm_runtime.hlinux/sysfs.hlinux/mmc/card.hlinux/mmc/host.hlinux/mmc/mmc.hcore.hcard.hhost.hsdio_cis.hbus.h
Detected Declarations
function Copyrightfunction mmc_bus_ueventfunction mmc_bus_probefunction mmc_bus_removefunction mmc_bus_shutdownfunction mmc_bus_suspendfunction mmc_bus_resumefunction mmc_runtime_suspendfunction mmc_runtime_resumefunction mmc_register_busfunction mmc_unregister_busfunction mmc_register_driverfunction mmc_unregister_driverfunction mmc_release_cardfunction mmc_add_cardfunction mmc_remove_cardexport mmc_register_driverexport mmc_unregister_driver
Annotated Snippet
static const struct bus_type mmc_bus_type = {
.name = "mmc",
.dev_groups = mmc_dev_groups,
.uevent = mmc_bus_uevent,
.probe = mmc_bus_probe,
.remove = mmc_bus_remove,
.shutdown = mmc_bus_shutdown,
.pm = &mmc_bus_pm_ops,
};
int mmc_register_bus(void)
{
return bus_register(&mmc_bus_type);
}
void mmc_unregister_bus(void)
{
bus_unregister(&mmc_bus_type);
}
/**
* mmc_register_driver - register a media driver
* @drv: MMC media driver
*/
int mmc_register_driver(struct mmc_driver *drv)
{
drv->drv.bus = &mmc_bus_type;
return driver_register(&drv->drv);
}
EXPORT_SYMBOL(mmc_register_driver);
/**
* mmc_unregister_driver - unregister a media driver
* @drv: MMC media driver
*/
void mmc_unregister_driver(struct mmc_driver *drv)
{
drv->drv.bus = &mmc_bus_type;
driver_unregister(&drv->drv);
}
EXPORT_SYMBOL(mmc_unregister_driver);
static void mmc_release_card(struct device *dev)
{
struct mmc_card *card = mmc_dev_to_card(dev);
sdio_free_common_cis(card);
kfree(card->info);
kfree(card);
}
/*
* Allocate and initialise a new MMC card structure.
*/
struct mmc_card *mmc_alloc_card(struct mmc_host *host, const struct device_type *type)
{
struct mmc_card *card;
card = kzalloc_obj(struct mmc_card);
if (!card)
return ERR_PTR(-ENOMEM);
card->host = host;
device_initialize(&card->dev);
card->dev.parent = mmc_classdev(host);
card->dev.bus = &mmc_bus_type;
card->dev.release = mmc_release_card;
card->dev.type = type;
return card;
}
/*
* Register a new MMC card with the driver model.
*/
int mmc_add_card(struct mmc_card *card)
{
int ret;
const char *type;
const char *speed_mode = "";
const char *uhs_bus_speed_mode = "";
static const char *const uhs_speeds[] = {
[UHS_SDR12_BUS_SPEED] = "SDR12 ",
[UHS_SDR25_BUS_SPEED] = "SDR25 ",
Annotation
- Immediate include surface: `linux/export.h`, `linux/device.h`, `linux/err.h`, `linux/slab.h`, `linux/stat.h`, `linux/of.h`, `linux/pm_runtime.h`, `linux/sysfs.h`.
- Detected declarations: `function Copyright`, `function mmc_bus_uevent`, `function mmc_bus_probe`, `function mmc_bus_remove`, `function mmc_bus_shutdown`, `function mmc_bus_suspend`, `function mmc_bus_resume`, `function mmc_runtime_suspend`, `function mmc_runtime_resume`, `function mmc_register_bus`.
- 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.