patch-2.4.23 linux-2.4.23/drivers/acpi/power.c

Next file: linux-2.4.23/drivers/acpi/resources/rsaddr.c
Previous file: linux-2.4.23/drivers/acpi/pci_root.c
Back to the patch index
Back to the overall index

diff -urN linux-2.4.22/drivers/acpi/power.c linux-2.4.23/drivers/acpi/power.c
@@ -323,6 +323,9 @@
 	if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3))
 		return_VALUE(-EINVAL);
 
+	if ((device->power.state < ACPI_STATE_D0) || (device->power.state > ACPI_STATE_D3))
+		return_VALUE(-ENODEV);
+
 	cl = &device->power.states[device->power.state].resources;
 	tl = &device->power.states[state].resources;
 
@@ -345,8 +348,6 @@
 			goto end;
 	}
 
-	device->power.state = state;
-
 	/*
 	 * Then we dereference all power resources used in the current list.
 	 */
@@ -356,6 +357,8 @@
 			goto end;
 	}
 
+	/* We shouldn't change the state till all above operations succeed */
+	device->power.state = state;
 end:
 	if (result)
 		ACPI_DEBUG_PRINT((ACPI_DB_WARN, 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)