drivers/acpi/acpi_platform.c
Source file repositories/reference/linux-study-clean/drivers/acpi/acpi_platform.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/acpi_platform.c- Extension
.c- Size
- 5576 bytes
- Lines
- 201
- Domain
- Driver Families
- Bucket
- drivers/acpi
- 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/acpi.hlinux/bits.hlinux/device.hlinux/err.hlinux/kernel.hlinux/module.hlinux/dma-mapping.hlinux/pci.hlinux/platform_device.hinternal.h
Detected Declarations
function acpi_platform_device_remove_notifyfunction acpi_platform_fill_resourcefunction acpi_platform_resource_countfunction acpi_platform_initexport acpi_create_platform_device
Annotated Snippet
if (match->driver_data & ACPI_ALLOW_WO_RESOURCES) {
bool has_resources = false;
acpi_walk_resources(adev->handle, METHOD_NAME__CRS,
acpi_platform_resource_count, &has_resources);
if (has_resources)
return ERR_PTR(-EINVAL);
} else {
return ERR_PTR(-EINVAL);
}
}
if (adev->device_type == ACPI_BUS_TYPE_DEVICE) {
LIST_HEAD(resource_list);
count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
if (count < 0)
return ERR_PTR(-ENODATA);
if (count > 0) {
struct resource_entry *rentry;
resources = kzalloc_objs(*resources, count);
if (!resources) {
acpi_dev_free_resource_list(&resource_list);
return ERR_PTR(-ENOMEM);
}
count = 0;
list_for_each_entry(rentry, &resource_list, node)
acpi_platform_fill_resource(adev, rentry->res,
&resources[count++]);
acpi_dev_free_resource_list(&resource_list);
}
}
memset(&pdevinfo, 0, sizeof(pdevinfo));
/*
* If the ACPI node has a parent and that parent has a physical device
* attached to it, that physical device should be the parent of the
* platform device we are about to create.
*/
pdevinfo.parent = parent ? acpi_get_first_physical_node(parent) : NULL;
pdevinfo.name = dev_name(&adev->dev);
pdevinfo.id = PLATFORM_DEVID_NONE;
pdevinfo.res = resources;
pdevinfo.num_res = count;
pdevinfo.fwnode = acpi_fwnode_handle(adev);
pdevinfo.properties = properties;
if (acpi_dma_supported(adev))
pdevinfo.dma_mask = DMA_BIT_MASK(32);
else
pdevinfo.dma_mask = 0;
pdev = platform_device_register_full(&pdevinfo);
if (IS_ERR(pdev))
dev_err(&adev->dev, "platform device creation failed: %ld\n",
PTR_ERR(pdev));
else {
set_dev_node(&pdev->dev, acpi_get_node(adev->handle));
dev_dbg(&adev->dev, "created platform device %s\n",
dev_name(&pdev->dev));
}
kfree(resources);
return pdev;
}
EXPORT_SYMBOL_GPL(acpi_create_platform_device);
void __init acpi_platform_init(void)
{
acpi_reconfig_notifier_register(&acpi_platform_notifier);
}
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/bits.h`, `linux/device.h`, `linux/err.h`, `linux/kernel.h`, `linux/module.h`, `linux/dma-mapping.h`, `linux/pci.h`.
- Detected declarations: `function acpi_platform_device_remove_notify`, `function acpi_platform_fill_resource`, `function acpi_platform_resource_count`, `function acpi_platform_init`, `export acpi_create_platform_device`.
- Atlas domain: Driver Families / drivers/acpi.
- 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.