aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/bus.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2010-11-25 00:08:36 +0100
committerLen Brown <len.brown@intel.com>2011-01-12 04:48:44 -0500
commitade3e7fef794781c0798d0cf0f046123842ba550 (patch)
treeda022d17787e9b79012fae0fabf6e7bf612b3edd /drivers/acpi/bus.c
parent5e6d4fe4296782f1f095575b8213a97c3e925a16 (diff)
downloadkernel_samsung_smdk4412-ade3e7fef794781c0798d0cf0f046123842ba550.zip
kernel_samsung_smdk4412-ade3e7fef794781c0798d0cf0f046123842ba550.tar.gz
kernel_samsung_smdk4412-ade3e7fef794781c0798d0cf0f046123842ba550.tar.bz2
ACPI / PM: Add function for device power state initialization
Add function acpi_bus_init_power() for getting the initial power state of an ACPI device and reference counting its power resources as appropriate. Make acpi_bus_get_power_flags() use the new function instead of acpi_bus_get_power() that updates device->power.state without reference counting the device's power resources. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/bus.c')
-rw-r--r--drivers/acpi/bus.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 9657abc..4534510 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -364,6 +364,31 @@ int acpi_bus_set_power(acpi_handle handle, int state)
EXPORT_SYMBOL(acpi_bus_set_power);
+
+int acpi_bus_init_power(struct acpi_device *device)
+{
+ int state;
+ int result;
+
+ if (!device)
+ return -EINVAL;
+
+ device->power.state = ACPI_STATE_UNKNOWN;
+
+ result = __acpi_bus_get_power(device, &state);
+ if (result)
+ return result;
+
+ if (device->power.flags.power_resources)
+ result = acpi_power_on_resources(device, state);
+
+ if (!result)
+ device->power.state = state;
+
+ return result;
+}
+
+
bool acpi_bus_power_manageable(acpi_handle handle)
{
struct acpi_device *device;