drivers/nvmem/layouts.c
Source file repositories/reference/linux-study-clean/drivers/nvmem/layouts.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvmem/layouts.c- Extension
.c- Size
- 5168 bytes
- Lines
- 217
- Domain
- Driver Families
- Bucket
- drivers/nvmem
- 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/device.hlinux/dma-mapping.hlinux/nvmem-consumer.hlinux/nvmem-provider.hlinux/of.hlinux/of_device.hlinux/of_irq.hinternals.h
Detected Declarations
function Copyrightfunction nvmem_layout_bus_probefunction nvmem_layout_bus_removefunction nvmem_layout_bus_ueventfunction __nvmem_layout_driver_registerfunction nvmem_layout_driver_unregisterfunction nvmem_layout_release_devicefunction nvmem_layout_create_devicefunction nvmem_layout_bus_populatefunction nvmem_populate_layoutfunction nvmem_destroy_layoutfunction nvmem_layout_bus_registerfunction nvmem_layout_bus_unregisterexport __nvmem_layout_driver_registerexport nvmem_layout_driver_unregisterexport of_nvmem_layout_get_container
Annotated Snippet
static int nvmem_layout_bus_match(struct device *dev, const struct device_driver *drv)
{
return of_driver_match_device(dev, drv);
}
static int nvmem_layout_bus_probe(struct device *dev)
{
struct nvmem_layout_driver *drv = to_nvmem_layout_driver(dev->driver);
struct nvmem_layout *layout = to_nvmem_layout_device(dev);
if (!drv->probe || !drv->remove)
return -EINVAL;
return drv->probe(layout);
}
static void nvmem_layout_bus_remove(struct device *dev)
{
struct nvmem_layout_driver *drv = to_nvmem_layout_driver(dev->driver);
struct nvmem_layout *layout = to_nvmem_layout_device(dev);
return drv->remove(layout);
}
static int nvmem_layout_bus_uevent(const struct device *dev,
struct kobj_uevent_env *env)
{
int ret;
ret = of_device_uevent_modalias(dev, env);
if (ret != -ENODEV)
return ret;
return 0;
}
static const struct bus_type nvmem_layout_bus_type = {
.name = "nvmem-layout",
.match = nvmem_layout_bus_match,
.probe = nvmem_layout_bus_probe,
.remove = nvmem_layout_bus_remove,
.uevent = nvmem_layout_bus_uevent,
};
int __nvmem_layout_driver_register(struct nvmem_layout_driver *drv,
struct module *owner)
{
drv->driver.bus = &nvmem_layout_bus_type;
drv->driver.owner = owner;
return driver_register(&drv->driver);
}
EXPORT_SYMBOL_GPL(__nvmem_layout_driver_register);
void nvmem_layout_driver_unregister(struct nvmem_layout_driver *drv)
{
driver_unregister(&drv->driver);
}
EXPORT_SYMBOL_GPL(nvmem_layout_driver_unregister);
static void nvmem_layout_release_device(struct device *dev)
{
struct nvmem_layout *layout = to_nvmem_layout_device(dev);
of_node_put(layout->dev.of_node);
kfree(layout);
}
static int nvmem_layout_create_device(struct nvmem_device *nvmem,
struct device_node *np)
{
struct nvmem_layout *layout;
struct device *dev;
int ret;
layout = kzalloc_obj(*layout);
if (!layout)
return -ENOMEM;
/* Create a bidirectional link */
layout->nvmem = nvmem;
nvmem->layout = layout;
/* Device model registration */
dev = &layout->dev;
device_initialize(dev);
dev->parent = &nvmem->dev;
dev->bus = &nvmem_layout_bus_type;
dev->release = nvmem_layout_release_device;
dev->coherent_dma_mask = DMA_BIT_MASK(32);
Annotation
- Immediate include surface: `linux/device.h`, `linux/dma-mapping.h`, `linux/nvmem-consumer.h`, `linux/nvmem-provider.h`, `linux/of.h`, `linux/of_device.h`, `linux/of_irq.h`, `internals.h`.
- Detected declarations: `function Copyright`, `function nvmem_layout_bus_probe`, `function nvmem_layout_bus_remove`, `function nvmem_layout_bus_uevent`, `function __nvmem_layout_driver_register`, `function nvmem_layout_driver_unregister`, `function nvmem_layout_release_device`, `function nvmem_layout_create_device`, `function nvmem_layout_bus_populate`, `function nvmem_populate_layout`.
- Atlas domain: Driver Families / drivers/nvmem.
- 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.