]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/acpi/bus.c
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[karo-tx-linux.git] / drivers / acpi / bus.c
index d59175efc428e58c8602b3c91730bf5cb99764d6..1f0d457ecbcf851a1805916f01ea931672146420 100644 (file)
@@ -257,7 +257,15 @@ static int __acpi_bus_get_power(struct acpi_device *device, int *state)
 }
 
 
-static int __acpi_bus_set_power(struct acpi_device *device, int state)
+/**
+ * acpi_device_set_power - Set power state of an ACPI device.
+ * @device: Device to set the power state of.
+ * @state: New power state to set.
+ *
+ * Callers must ensure that the device is power manageable before using this
+ * function.
+ */
+int acpi_device_set_power(struct acpi_device *device, int state)
 {
        int result = 0;
        acpi_status status = AE_OK;
@@ -298,6 +306,12 @@ static int __acpi_bus_set_power(struct acpi_device *device, int state)
         * a lower-powered state.
         */
        if (state < device->power.state) {
+               if (device->power.state >= ACPI_STATE_D3_HOT &&
+                   state != ACPI_STATE_D0) {
+                       printk(KERN_WARNING PREFIX
+                             "Cannot transition to non-D0 state from D3\n");
+                       return -ENODEV;
+               }
                if (device->power.flags.power_resources) {
                        result = acpi_power_transition(device, state);
                        if (result)
@@ -341,6 +355,7 @@ static int __acpi_bus_set_power(struct acpi_device *device, int state)
 
        return result;
 }
+EXPORT_SYMBOL(acpi_device_set_power);
 
 
 int acpi_bus_set_power(acpi_handle handle, int state)
@@ -359,7 +374,7 @@ int acpi_bus_set_power(acpi_handle handle, int state)
                return -ENODEV;
        }
 
-       return __acpi_bus_set_power(device, state);
+       return acpi_device_set_power(device, state);
 }
 EXPORT_SYMBOL(acpi_bus_set_power);
 
@@ -402,7 +417,7 @@ int acpi_bus_update_power(acpi_handle handle, int *state_p)
        if (result)
                return result;
 
-       result = __acpi_bus_set_power(device, state);
+       result = acpi_device_set_power(device, state);
        if (!result && state_p)
                *state_p = state;