drivers/of/platform.c
Source file repositories/reference/linux-study-clean/drivers/of/platform.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/of/platform.c- Extension
.c- Size
- 22222 bytes
- Lines
- 794
- Domain
- Driver Families
- Bucket
- drivers/of
- 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/errno.hlinux/module.hlinux/amba/bus.hlinux/device.hlinux/dma-mapping.hlinux/slab.hlinux/of_address.hlinux/of_device.hlinux/of_irq.hlinux/of_platform.hlinux/platform_device.hlinux/sysfb.hof_private.h
Detected Declarations
function Copyrightfunction of_device_addfunction of_device_registerfunction of_device_unregisterfunction of_dev_lookupfunction of_platform_bus_createfunction for_each_child_of_node_scopedfunction of_platform_bus_probefunction for_each_child_of_node_scopedfunction of_platform_populatefunction of_platform_default_populatefunction of_platform_default_populate_initfunction for_each_node_by_typefunction for_each_node_by_typefunction of_platform_sync_state_initfunction of_platform_device_destroyfunction of_platform_depopulatefunction devm_of_platform_populate_releasefunction devm_of_platform_populatefunction devm_of_platform_matchfunction devm_of_platform_depopulatefunction of_platform_notifyfunction of_platform_register_reconfig_notifierexport of_find_device_by_nodeexport of_device_registerexport of_device_unregisterexport of_device_allocexport of_platform_device_createexport of_platform_bus_probeexport of_platform_populateexport of_platform_default_populateexport of_platform_device_destroyexport of_platform_depopulateexport devm_of_platform_populateexport devm_of_platform_depopulate
Annotated Snippet
* of_node_to_nid returns NUMA_NO_NODE. device_add will assume that this
* device is on the same node as the parent.
*/
set_dev_node(&ofdev->dev, of_node_to_nid(ofdev->dev.of_node));
return device_add(&ofdev->dev);
}
int of_device_register(struct platform_device *pdev)
{
device_initialize(&pdev->dev);
return of_device_add(pdev);
}
EXPORT_SYMBOL(of_device_register);
void of_device_unregister(struct platform_device *ofdev)
{
device_unregister(&ofdev->dev);
}
EXPORT_SYMBOL(of_device_unregister);
#ifdef CONFIG_OF_ADDRESS
static const struct of_device_id of_skipped_node_table[] = {
{ .compatible = "operating-points-v2", },
{} /* Empty terminated list */
};
/*
* The following routines scan a subtree and registers a device for
* each applicable node.
*
* Note: sparc doesn't use these routines because it has a different
* mechanism for creating devices from device tree nodes.
*/
/**
* of_device_alloc - Allocate and initialize an of_device
* @np: device node to assign to device
* @bus_id: Name to assign to the device. May be null to use default name.
* @parent: Parent device.
*/
struct platform_device *of_device_alloc(struct device_node *np,
const char *bus_id,
struct device *parent)
{
struct platform_device *dev;
int rc, i, num_reg = 0;
struct resource *res;
dev = platform_device_alloc("", PLATFORM_DEVID_NONE);
if (!dev)
return NULL;
/* count the io resources */
num_reg = of_address_count(np);
/* Populate the resource table */
if (num_reg) {
res = kzalloc_objs(*res, num_reg);
if (!res) {
platform_device_put(dev);
return NULL;
}
dev->num_resources = num_reg;
dev->resource = res;
for (i = 0; i < num_reg; i++, res++) {
rc = of_address_to_resource(np, i, res);
WARN_ON(rc);
}
}
/* setup generic device info */
device_set_node(&dev->dev, of_fwnode_handle(of_node_get(np)));
dev->dev.parent = parent ? : &platform_bus;
if (bus_id)
dev_set_name(&dev->dev, "%s", bus_id);
else
of_device_make_bus_id(&dev->dev);
return dev;
}
EXPORT_SYMBOL(of_device_alloc);
/**
* of_platform_device_create_pdata - Alloc, initialize and register an of_device
* @np: pointer to node to create device for
* @bus_id: name to assign device
* @platform_data: pointer to populate platform_data pointer with
Annotation
- Immediate include surface: `linux/errno.h`, `linux/module.h`, `linux/amba/bus.h`, `linux/device.h`, `linux/dma-mapping.h`, `linux/slab.h`, `linux/of_address.h`, `linux/of_device.h`.
- Detected declarations: `function Copyright`, `function of_device_add`, `function of_device_register`, `function of_device_unregister`, `function of_dev_lookup`, `function of_platform_bus_create`, `function for_each_child_of_node_scoped`, `function of_platform_bus_probe`, `function for_each_child_of_node_scoped`, `function of_platform_populate`.
- Atlas domain: Driver Families / drivers/of.
- 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.