aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/platform.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-11-20 18:21:59 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-11-20 18:21:59 -0500
commit863f9f30e6c1e30cb19a0cd17c5cf8879257dfd7 (patch)
tree774ce5240f210f60fe20c3454bc5a8520633d8ba /drivers/base/platform.c
parent95f8a082b9b1ead0c2859f2a7b1ac91ff63d8765 (diff)
ACPI / platform: Initialize ACPI handles of platform devices in advance
The current platform device creation and registration code in acpi_create_platform_device() is quite convoluted. This function takes an ACPI device node as an argument and eventually calls platform_device_register_resndata() to create and register a platform device object on the basis of the information contained in that code. However, it doesn't associate the new platform device with the ACPI node directly, but instead it relies on acpi_platform_notify(), called from within device_add(), to find that ACPI node again with the help of acpi_platform_find_device() and acpi_platform_match() and then attach the new platform device to it. This causes an additional ACPI namespace walk to happen and is clearly suboptimal. Use the observation that it is now possible to initialize the ACPI handle of a device before calling device_add() for it to make this code more straightforward. Namely, add a new field to struct platform_device_info allowing us to pass the ACPI handle of interest to platform_device_register_full(), which will then use it to initialize the new device's ACPI handle before registering it. This will cause acpi_platform_notify() to use the ACPI handle from the device structure directly instead of using the .find_device() routine provided by the device's bus type. In consequence, acpi_platform_bus, acpi_platform_find_device(), and acpi_platform_match() are not necessary any more, so remove them. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/platform.c')
-rw-r--r--drivers/base/platform.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 7de29ebfce7f..49fd96e23460 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -437,6 +437,7 @@ struct platform_device *platform_device_register_full(
437 goto err_alloc; 437 goto err_alloc;
438 438
439 pdev->dev.parent = pdevinfo->parent; 439 pdev->dev.parent = pdevinfo->parent;
440 ACPI_HANDLE_SET(&pdev->dev, pdevinfo->acpi_node.handle);
440 441
441 if (pdevinfo->dma_mask) { 442 if (pdevinfo->dma_mask) {
442 /* 443 /*
@@ -467,6 +468,7 @@ struct platform_device *platform_device_register_full(
467 ret = platform_device_add(pdev); 468 ret = platform_device_add(pdev);
468 if (ret) { 469 if (ret) {
469err: 470err:
471 ACPI_HANDLE_SET(&pdev->dev, NULL);
470 kfree(pdev->dev.dma_mask); 472 kfree(pdev->dev.dma_mask);
471 473
472err_alloc: 474err_alloc: