drivers/mcb/mcb-core.c
Source file repositories/reference/linux-study-clean/drivers/mcb/mcb-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/mcb/mcb-core.c- Extension
.c- Size
- 11058 bytes
- Lines
- 520
- Domain
- Driver Families
- Bucket
- drivers/mcb
- 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/kernel.hlinux/module.hlinux/slab.hlinux/types.hlinux/idr.hlinux/mcb.h
Detected Declarations
function mcb_matchfunction mcb_ueventfunction mcb_probefunction mcb_removefunction mcb_shutdownfunction revision_showfunction model_showfunction minor_showfunction name_showfunction __mcb_register_driverfunction mcb_unregister_driverfunction mcb_release_devfunction mcb_device_registerfunction mcb_free_busfunction mcb_alloc_busfunction __mcb_devices_unregisterfunction mcb_devices_unregisterfunction mcb_release_busfunction mcb_bus_getfunction mcb_bus_putfunction mcb_alloc_devfunction mcb_free_devfunction __mcb_bus_add_devicesfunction mcb_bus_add_devicesfunction mcb_get_resourcefunction mcb_request_memfunction mcb_release_memfunction __mcb_get_irqfunction mcb_get_irqfunction mcb_initfunction mcb_exitmodule init mcb_init
Annotated Snippet
static int mcb_match(struct device *dev, const struct device_driver *drv)
{
const struct mcb_driver *mdrv = to_mcb_driver(drv);
struct mcb_device *mdev = to_mcb_device(dev);
const struct mcb_device_id *found_id;
found_id = mcb_match_id(mdrv->id_table, mdev);
if (found_id)
return 1;
return 0;
}
static int mcb_uevent(const struct device *dev, struct kobj_uevent_env *env)
{
const struct mcb_device *mdev = to_mcb_device(dev);
int ret;
ret = add_uevent_var(env, "MODALIAS=mcb:16z%03d", mdev->id);
if (ret)
return -ENOMEM;
return 0;
}
static int mcb_probe(struct device *dev)
{
struct mcb_driver *mdrv = to_mcb_driver(dev->driver);
struct mcb_device *mdev = to_mcb_device(dev);
const struct mcb_device_id *found_id;
struct module *carrier_mod;
int ret;
found_id = mcb_match_id(mdrv->id_table, mdev);
if (!found_id)
return -ENODEV;
carrier_mod = mdev->dev.parent->driver->owner;
if (!try_module_get(carrier_mod))
return -EINVAL;
get_device(dev);
ret = mdrv->probe(mdev, found_id);
if (ret) {
module_put(carrier_mod);
put_device(dev);
}
return ret;
}
static void mcb_remove(struct device *dev)
{
struct mcb_driver *mdrv = to_mcb_driver(dev->driver);
struct mcb_device *mdev = to_mcb_device(dev);
struct module *carrier_mod;
if (mdrv->remove)
mdrv->remove(mdev);
carrier_mod = mdev->dev.parent->driver->owner;
module_put(carrier_mod);
put_device(&mdev->dev);
}
static void mcb_shutdown(struct device *dev)
{
struct mcb_driver *mdrv = to_mcb_driver(dev->driver);
struct mcb_device *mdev = to_mcb_device(dev);
if (mdrv && mdrv->shutdown)
mdrv->shutdown(mdev);
}
static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct mcb_bus *bus = to_mcb_bus(dev);
return sysfs_emit(buf, "%d\n", bus->revision);
}
static DEVICE_ATTR_RO(revision);
static ssize_t model_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct mcb_bus *bus = to_mcb_bus(dev);
return sysfs_emit(buf, "%c\n", bus->model);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/types.h`, `linux/idr.h`, `linux/mcb.h`.
- Detected declarations: `function mcb_match`, `function mcb_uevent`, `function mcb_probe`, `function mcb_remove`, `function mcb_shutdown`, `function revision_show`, `function model_show`, `function minor_show`, `function name_show`, `function __mcb_register_driver`.
- Atlas domain: Driver Families / drivers/mcb.
- 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.