# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.1130  -> 1.1131 
#	drivers/acpi/power.c	1.6     -> 1.7    
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/10/20	len.brown@intel.com	1.1131
# [ACPI] Broken fan detection prevents booting (Shaohua David Li)
#   http://bugme.osdl.org/show_bug.cgi?id=1185
# --------------------------------------------
#
diff -Nru a/drivers/acpi/power.c b/drivers/acpi/power.c
--- a/drivers/acpi/power.c	Mon Oct 20 23:53:44 2003
+++ b/drivers/acpi/power.c	Mon Oct 20 23:53:44 2003
@@ -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, 
