/** * apmt_add_platform_device() - Allocate a platform device for APMT node * @node: Pointer to device ACPI APMT node * @fwnode: fwnode associated with the APMT node * * Returns: 0 on success, <0 failure
*/ staticint __init apmt_add_platform_device(struct acpi_apmt_node *node, struct fwnode_handle *fwnode)
{ struct platform_device *pdev; int ret, count; struct resource res[DEV_MAX_RESOURCE_COUNT];
pdev = platform_device_alloc(DEV_NAME, PLATFORM_DEVID_AUTO); if (!pdev) return -ENOMEM;
memset(res, 0, sizeof(res));
count = apmt_init_resources(res, node);
ret = platform_device_add_resources(pdev, res, count); if (ret) goto dev_put;
/* * Add a copy of APMT node pointer to platform_data to be used to * retrieve APMT data information.
*/
ret = platform_device_add_data(pdev, &node, sizeof(node)); if (ret) goto dev_put;
/* * apmt_table and apmt both point to the start of APMT table, but * have different struct types
*/
apmt = (struct acpi_table_apmt *)apmt_table;
offset = sizeof(*apmt);
end = apmt->header.length;
fwnode = acpi_alloc_fwnode_static(); if (!fwnode) return -ENOMEM;
ret = apmt_add_platform_device(apmt_node, fwnode); if (ret) {
acpi_free_fwnode_static(fwnode); return ret;
}
offset += apmt_node->length;
}
return 0;
}
void __init acpi_apmt_init(void)
{
acpi_status status; int ret;
/** * APMT table nodes will be used at runtime after the apmt init, * so we don't need to call acpi_put_table() to release * the APMT table mapping.
*/
status = acpi_get_table(ACPI_SIG_APMT, 0, &apmt_table);
if (ACPI_FAILURE(status)) { if (status != AE_NOT_FOUND) { constchar *msg = acpi_format_exception(status);
pr_err("Failed to get APMT table, %s\n", msg);
}
return;
}
ret = apmt_init_platform_devices(); if (ret) {
pr_err("Failed to initialize APMT platform devices, ret: %d\n", ret);
acpi_put_table(apmt_table);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.