patch-2.4.1 linux/drivers/acpi/sys.c

Next file: linux/drivers/acpi/table.c
Previous file: linux/drivers/acpi/resources/rsxface.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0/linux/drivers/acpi/sys.c linux/drivers/acpi/sys.c
@@ -27,18 +27,13 @@
 #define _COMPONENT	OS_DEPENDENT
 	MODULE_NAME	("sys")
 
-#define ACPI_SLP_TYP(typa, typb)	(((int)(typa) << 8) | (int)(typb))
-#define ACPI_SLP_TYPA(value)		((value) >> 8)
-#define ACPI_SLP_TYPB(value)		((value) & 0xff)
-
 struct acpi_enter_sx_ctx
 {
 	wait_queue_head_t wait;
 	unsigned int      state;
 };
 
-volatile acpi_sstate_t acpi_sleep_state = ACPI_S0;
-static unsigned long acpi_slptyp[ACPI_S5 + 1] = {ACPI_INVALID,};
+volatile acpi_sstate_t acpi_sleep_state = ACPI_STATE_S0;
 
 /*
  * Enter system sleep state
@@ -50,56 +45,32 @@
 	ACPI_OBJECT_LIST arg_list;
 	ACPI_OBJECT arg;
 
-	/*
-         * _PSW methods could be run here to enable wake-on keyboard, LAN, etc.
-	 */
-
-	// run the _PTS method
-	memset(&arg_list, 0, sizeof(arg_list));
-	arg_list.count = 1;
-	arg_list.pointer = &arg;
+	acpi_enter_sleep_state(ctx->state);
 
-	memset(&arg, 0, sizeof(arg));
-	arg.type = ACPI_TYPE_NUMBER;
-	arg.number.value = ctx->state;
-
-	acpi_evaluate_object(NULL, "\\_PTS", &arg_list, NULL);
-	
-	// clear wake status by writing a 1
-	acpi_hw_register_bit_access(ACPI_WRITE, ACPI_MTX_LOCK, WAK_STS, 1);
-		
-	acpi_sleep_state = ctx->state;
-
-	// set ACPI_SLP_TYPA/b and ACPI_SLP_EN
-	acpi_hw_register_bit_access(ACPI_WRITE, ACPI_MTX_LOCK, SLP_TYPE_A,
-		ACPI_SLP_TYPA(acpi_slptyp[ctx->state]));
-	acpi_hw_register_bit_access(ACPI_WRITE, ACPI_MTX_LOCK, SLP_TYPE_B,
-		ACPI_SLP_TYPB(acpi_slptyp[ctx->state]));
-	acpi_hw_register_bit_access(ACPI_WRITE, ACPI_MTX_LOCK, SLP_EN, 1);
-	
-	if (ctx->state != ACPI_S1) {
-		/* we should have just shut off - what are we doing here? */
-		printk(KERN_ERR "ACPI: S%d failed\n", ctx->state);
+	/* either we are in S1, or the transition failed, as the other states resume
+           from the waking vector */
+	if (ctx->state != ACPI_STATE_S1) {
+		printk(KERN_ERR "Could not enter S%d\n", ctx->state);
 		goto out;
 	}
 
-	// wait until S1 is entered
+	/* wait until S1 is entered */
 	while (!(acpi_hw_register_bit_access(ACPI_READ, ACPI_MTX_LOCK, WAK_STS)))
 		safe_halt();
 
-	// run the _WAK method
+	/* run the _WAK method */
 	memset(&arg_list, 0, sizeof(arg_list));
 	arg_list.count = 1;
 	arg_list.pointer = &arg;
 
 	memset(&arg, 0, sizeof(arg));
-	arg.type = ACPI_TYPE_NUMBER;
-	arg.number.value = ctx->state;
+	arg.type = ACPI_TYPE_INTEGER;
+	arg.integer.value = ctx->state;
 
 	acpi_evaluate_object(NULL, "\\_WAK", &arg_list, NULL);
 
  out:
-	acpi_sleep_state = ACPI_S0;
+	acpi_sleep_state = ACPI_STATE_S0;
 
 	if (waitqueue_active(&ctx->wait))
 		wake_up_interruptible(&ctx->wait);
@@ -112,13 +83,9 @@
 acpi_power_off(void)
 {
 	struct acpi_enter_sx_ctx ctx;
-
-	if ((STRNCMP(acpi_fadt.header.signature, ACPI_FADT_SIGNATURE, ACPI_SIG_LEN) != 0)
-	    || acpi_slptyp[ACPI_S5] == ACPI_INVALID)
-		return;
 	
 	init_waitqueue_head(&ctx.wait);
-	ctx.state = ACPI_S5;
+	ctx.state = ACPI_STATE_S5;
 	acpi_enter_sx_async(&ctx);
 }
 
@@ -132,10 +99,6 @@
 	DECLARE_WAITQUEUE(wait, current);
 	int ret = 0;
 
-	if ((STRNCMP(acpi_fadt.header.signature, ACPI_FADT_SIGNATURE, ACPI_SIG_LEN) != 0)
-	    || acpi_slptyp[state] == ACPI_INVALID)
-		return -EINVAL;
-	
 	init_waitqueue_head(&ctx.wait);
 	ctx.state = state;
 
@@ -166,18 +129,13 @@
 
 	printk(KERN_INFO "ACPI: System firmware supports:");
 
-	for (sx = ACPI_S0; sx <= ACPI_S5; sx++) {
-		int ca_sx = (sx <= ACPI_S4) ? sx : (sx + 1);
+	for (sx = ACPI_STATE_S0; sx <= ACPI_STATE_S5; sx++) {
 		if (ACPI_SUCCESS(
-			   acpi_hw_obtain_sleep_type_register_data(ca_sx,
+			   acpi_hw_obtain_sleep_type_register_data(sx,
 								   &type_a,
 								   &type_b))) {
 
-			acpi_slptyp[sx] = ACPI_SLP_TYP(type_a, type_b);
 			printk(" S%d", sx);
-		}
-		else {
-			acpi_slptyp[sx] = ACPI_INVALID;
 		}
 	}
 	printk("\n");

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