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.

Dependency Surface

Detected Declarations

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

Implementation Notes