ACPI: Allow ACPI handles of devices to be initialized in advance
commitf3fd0c8a7fc1e4f3107a09a75e622781d3007b56
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 20 Nov 2012 23:21:39 +0000 (21 00:21 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 20 Nov 2012 23:21:39 +0000 (21 00:21 +0100)
treed63af1d6106032a1fdbc788ef9b7805f01a05a0a
parent8a66790b7850a6669129af078768a1d42076a0ef
ACPI: Allow ACPI handles of devices to be initialized in advance

Currently, the ACPI handles of devices are initialized from within
device_add(), by acpi_bind_one() called from acpi_platform_notify()
which first uses the .find_device() routine provided by the device's
bus type to find the matching device node in the ACPI namespace.
This is a source of some computational overhead and, moreover, the
correctness of the result depends on the implementation of
.find_device() which is known to fail occasionally for some bus types
(e.g. PCI).  In some cases, however, the corresponding ACPI device
node is known already before calling device_add() for the given
struct device object and the whole .find_device() dance in
acpi_platform_notify() is then simply unnecessary.

For this reason, make it possible to initialize the ACPI handles of
devices before calling device_add() for them.  Modify
acpi_platform_notify() to call acpi_bind_one() in advance to check
the device's existing ACPI handle and skip the .find_device()
search if that is successful.  Change acpi_bind_one() accordingly.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/acpi/glue.c