aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2010-11-24 18:08:36 -0500
committerLen Brown <len.brown@intel.com>2011-01-12 04:48:44 -0500
commitade3e7fef794781c0798d0cf0f046123842ba550 (patch)
treeda022d17787e9b79012fae0fabf6e7bf612b3edd /drivers/acpi
parent5e6d4fe4296782f1f095575b8213a97c3e925a16 (diff)
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')
-rw-r--r--drivers/acpi/bus.c25
-rw-r--r--drivers/acpi/internal.h1
-rw-r--r--drivers/acpi/scan.c5
3 files changed, 27 insertions, 4 deletions
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 9657abc4a7fb..453451090502 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)
364 364
365EXPORT_SYMBOL(acpi_bus_set_power); 365EXPORT_SYMBOL(acpi_bus_set_power);
366 366
367
368int acpi_bus_init_power(struct acpi_device *device)
369{
370 int state;
371 int result;
372
373 if (!device)
374 return -EINVAL;
375
376 device->power.state = ACPI_STATE_UNKNOWN;
377
378 result = __acpi_bus_get_power(device, &state);
379 if (result)
380 return result;
381
382 if (device->power.flags.power_resources)
383 result = acpi_power_on_resources(device, state);
384
385 if (!result)
386 device->power.state = state;
387
388 return result;
389}
390
391
367bool acpi_bus_power_manageable(acpi_handle handle) 392bool acpi_bus_power_manageable(acpi_handle handle)
368{ 393{
369 struct acpi_device *device; 394 struct acpi_device *device;
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 433a8ee8ac2c..7493e6c7a003 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -44,6 +44,7 @@ int acpi_device_sleep_wake(struct acpi_device *dev,
44int acpi_power_get_inferred_state(struct acpi_device *device, int *state); 44int acpi_power_get_inferred_state(struct acpi_device *device, int *state);
45int acpi_power_on_resources(struct acpi_device *device, int state); 45int acpi_power_on_resources(struct acpi_device *device, int state);
46int acpi_power_transition(struct acpi_device *device, int state); 46int acpi_power_transition(struct acpi_device *device, int state);
47int acpi_bus_init_power(struct acpi_device *device);
47extern int acpi_power_nocheck; 48extern int acpi_power_nocheck;
48 49
49int acpi_wakeup_device_init(void); 50int acpi_wakeup_device_init(void);
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 29ef505c487b..ef8e659771e1 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -901,10 +901,7 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
901 device->power.states[ACPI_STATE_D3].flags.valid = 1; 901 device->power.states[ACPI_STATE_D3].flags.valid = 1;
902 device->power.states[ACPI_STATE_D3].power = 0; 902 device->power.states[ACPI_STATE_D3].power = 0;
903 903
904 /* TBD: System wake support and resource requirements. */ 904 acpi_bus_init_power(device);
905
906 device->power.state = ACPI_STATE_UNKNOWN;
907 acpi_bus_get_power(device->handle, &(device->power.state));
908 905
909 return 0; 906 return 0;
910} 907}