public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: pm list <linux-pm@lists.linux-foundation.org>
Cc: ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Pavel Machek <pavel@ucw.cz>
Subject: [RFC][PATCH 2/2] PM: Introduce pm_power_off_prepare
Date: Sun, 1 Jul 2007 20:54:31 +0200	[thread overview]
Message-ID: <200707012054.31782.rjw@sisk.pl> (raw)
In-Reply-To: <200707012051.48338.rjw@sisk.pl>

From: Rafael J. Wysocki <rjw@sisk.pl>

Introduce the pm_power_off_prepare() callback that can be registered by the
interested platforms in analogy with pm_idle() and pm_power_off(), used for
preparing the system to power off (needed by ACPI).

This allows us to drop acpi_sysclass and device_acpi that are only defined in
order to register the ACPI power off preparation callback, which is needed by
pm_power_off() registered in a much different way.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/acpi/sleep/poweroff.c |   38 +++++++++-----------------------------
 include/linux/pm.h            |    1 +
 kernel/sys.c                  |    9 +++++++++
 3 files changed, 19 insertions(+), 29 deletions(-)

Index: linux-2.6.22-rc6/include/linux/pm.h
===================================================================
--- linux-2.6.22-rc6.orig/include/linux/pm.h	2007-07-01 13:46:49.000000000 +0200
+++ linux-2.6.22-rc6/include/linux/pm.h	2007-07-01 18:37:28.000000000 +0200
@@ -101,6 +101,7 @@ struct pm_dev
  */
 extern void (*pm_idle)(void);
 extern void (*pm_power_off)(void);
+extern void (*pm_power_off_prepare)(void);
 
 /*
  * Device power management
Index: linux-2.6.22-rc6/kernel/sys.c
===================================================================
--- linux-2.6.22-rc6.orig/kernel/sys.c	2007-06-25 21:07:40.000000000 +0200
+++ linux-2.6.22-rc6/kernel/sys.c	2007-07-01 18:40:59.000000000 +0200
@@ -98,6 +98,13 @@ struct pid *cad_pid;
 EXPORT_SYMBOL(cad_pid);
 
 /*
+ * If set, this is used for preparing the system to power off.
+ */
+
+void (*pm_power_off_prepare)(void);
+EXPORT_SYMBOL(pm_power_off_prepare);
+
+/*
  *	Notifier list for kernel code which wants to be called
  *	at shutdown. This is used to stop any idling DMA operations
  *	and the like. 
@@ -865,6 +872,8 @@ EXPORT_SYMBOL_GPL(kernel_halt);
 void kernel_power_off(void)
 {
 	kernel_shutdown_prepare(SYSTEM_POWER_OFF);
+	if (pm_power_off_prepare)
+		pm_power_off_prepare();
 	printk(KERN_EMERG "Power down.\n");
 	machine_power_off();
 }
Index: linux-2.6.22-rc6/drivers/acpi/sleep/poweroff.c
===================================================================
--- linux-2.6.22-rc6.orig/drivers/acpi/sleep/poweroff.c	2007-07-01 15:10:07.000000000 +0200
+++ linux-2.6.22-rc6/drivers/acpi/sleep/poweroff.c	2007-07-01 18:40:09.000000000 +0200
@@ -39,7 +39,13 @@ int acpi_sleep_prepare(u32 acpi_state)
 
 #ifdef CONFIG_PM
 
-void acpi_power_off(void)
+static void acpi_power_off_prepare(void)
+{
+	/* Prepare to power off the system */
+	acpi_sleep_prepare(ACPI_STATE_S5);
+}
+
+static void acpi_power_off(void)
 {
 	/* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
 	printk("%s called\n", __FUNCTION__);
@@ -48,27 +54,6 @@ void acpi_power_off(void)
 	acpi_enter_sleep_state(ACPI_STATE_S5);
 }
 
-static int acpi_shutdown(struct sys_device *x)
-{
-	switch (system_state) {
-	case SYSTEM_POWER_OFF:
-		/* Prepare to power off the system */
-		return acpi_sleep_prepare(ACPI_STATE_S5);
-	default:
-		return 0;
-	}
-}
-
-static struct sysdev_class acpi_sysclass = {
-	set_kset_name("acpi"),
-	.shutdown = acpi_shutdown
-};
-
-static struct sys_device device_acpi = {
-	.id = 0,
-	.cls = &acpi_sysclass,
-};
-
 static int acpi_poweroff_init(void)
 {
 	if (!acpi_disabled) {
@@ -78,13 +63,8 @@ static int acpi_poweroff_init(void)
 		status =
 		    acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b);
 		if (ACPI_SUCCESS(status)) {
-			int error;
-			error = sysdev_class_register(&acpi_sysclass);
-			if (!error)
-				error = sysdev_register(&device_acpi);
-			if (!error)
-				pm_power_off = acpi_power_off;
-			return error;
+			pm_power_off_prepare = acpi_power_off_prepare;
+			pm_power_off = acpi_power_off;
 		}
 	}
 	return 0;

  parent reply	other threads:[~2007-07-01 18:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-01 18:51 [RFC][PATCH 0/2] PM: Update system power off code Rafael J. Wysocki
2007-07-01 18:53 ` [RFC][PATCH 1/2] ACPI: Do not prepare for hibernation in acpi_shutdown Rafael J. Wysocki
2007-07-04 19:49   ` Pavel Machek
2007-07-04 21:40     ` Rafael J. Wysocki
2007-07-01 18:54 ` Rafael J. Wysocki [this message]
2007-07-04 19:52   ` [RFC][PATCH 2/2] PM: Introduce pm_power_off_prepare Pavel Machek
2007-07-04 21:42     ` Rafael J. Wysocki
2007-07-04 21:39       ` Pavel Machek
2007-07-04 21:52         ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200707012054.31782.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=pavel@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox