ACPI / PM: Prevent acpi_power_get_inferred_state() from making changes
authorRafael J. Wysocki <rjw@sisk.pl>
Wed, 24 Nov 2010 23:05:17 +0000 (00:05 +0100)
committerLen Brown <len.brown@intel.com>
Wed, 12 Jan 2011 09:48:43 +0000 (04:48 -0500)
acpi_power_get_inferred_state() should not update
device->power.state behind the back of its caller, so make it return
the state via a pointer instead.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/acpi/bus.c
drivers/acpi/internal.h
drivers/acpi/power.c

index d68bd61..a9fe8e6 100644 (file)
@@ -222,7 +222,8 @@ int acpi_bus_get_power(acpi_handle handle, int *state)
                 * indirectly (via power resources).
                 */
                if (device->power.flags.power_resources) {
-                       result = acpi_power_get_inferred_state(device);
+                       result = acpi_power_get_inferred_state(device,
+                                                       &device->power.state);
                        if (result)
                                return result;
                } else if (device->power.flags.explicit_get) {
index a212bfe..2cc0148 100644 (file)
@@ -41,7 +41,7 @@ static inline int acpi_debugfs_init(void) { return 0; }
 int acpi_power_init(void);
 int acpi_device_sleep_wake(struct acpi_device *dev,
                            int enable, int sleep_state, int dev_state);
-int acpi_power_get_inferred_state(struct acpi_device *device);
+int acpi_power_get_inferred_state(struct acpi_device *device, int *state);
 int acpi_power_transition(struct acpi_device *device, int state);
 extern int acpi_power_nocheck;
 
index 4c9c2fb..9bd1b60 100644 (file)
@@ -423,19 +423,16 @@ int acpi_disable_wakeup_device_power(struct acpi_device *dev)
                              Device Power Management
    -------------------------------------------------------------------------- */
 
-int acpi_power_get_inferred_state(struct acpi_device *device)
+int acpi_power_get_inferred_state(struct acpi_device *device, int *state)
 {
        int result = 0;
        struct acpi_handle_list *list = NULL;
        int list_state = 0;
        int i = 0;
 
-
-       if (!device)
+       if (!device || !state)
                return -EINVAL;
 
-       device->power.state = ACPI_STATE_UNKNOWN;
-
        /*
         * We know a device's inferred power state when all the resources
         * required for a given D-state are 'on'.
@@ -450,13 +447,12 @@ int acpi_power_get_inferred_state(struct acpi_device *device)
                        return result;
 
                if (list_state == ACPI_POWER_RESOURCE_STATE_ON) {
-                       device->power.state = i;
+                       *state = i;
                        return 0;
                }
        }
 
-       device->power.state = ACPI_STATE_D3;
-
+       *state = ACPI_STATE_D3;
        return 0;
 }