Skip to contentSkip to conversation

PM: fast power off - driver

PATCH In review akuster 3 participants 4 messages Jan 27, 2007 – Jan 31, 2007

Subsystems (2)
lore
Share & tools
lore

akuster

author
#0 lore raw

PATCH 2/2 PM: fast power off - driver

My apologies, I cc'd the wrong list the first time around.

- Armin
---

Fastpoweroff default profile driver

---
 kernel/power/fastoff/Kconfig      |    8 ++++
 kernel/power/fastoff/Makefile     |    2 -
 kernel/power/fastoff/fastoffdrv.c |   69 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 78 insertions(+), 1 deletion(-)
kernel/power/fastoff/fastoffdrv.c new file +69 -0
Index: linux-2.6_dev/kernel/power/fastoff/fastoffdrv.c
===================================================================
@@ -0,0 +1,69 @@
+/*
+ * kernel/power/fastoff/fastoffdrv.c
+ *
+ * This provides a sysfs interface that allows the user to
+ * bypass running rc kill scripts in the advent the user
+ * needed to power down as fast as possible. This could be
+ * in a low battery conditon and you want to try to keep
+ * data from being corrupted.
+ *
+ * Author: Armin Kuster <[email protected], or [email protected]>
+ *
+ * 2006, 2007  (c) MontaVista Software, Inc. This file is licensed under
+ * the terms of the GNU General Public License version 2. This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/errno.h>
+
+#include "../power.h"
+#include "fpo.h"
+
+static int fsd_default_off(void)
+{
+	/*
+	 * Actions taken:
+	 *
+	 *    1. Freeze all user processes.
+	 *
+	 *    2. Power off
+	 *
+	 *    3. Power off devices
+	 */
+
+	printk(KERN_EMERG "Fast Power Off initiated.\n");
+	fastpoweroff_prepare();
+	fastpoweroff();
+	fastpoweroff_standby();
+	return 1;
+}
+
+static struct fpo_driver fpo_default = {
+	.name = "default",
+	.policy = fsd_default_off,
+};
+
+static int __init fsd_default_init(void)
+{
+	int ret = 0;
+
+	if(( ret = fastpoweroff_register(&fpo_default)) < 0) {
+		printk(KERN_ERR "PM: Fastpoweroff: %s profile registation failed %d.\n",
+			fpo_default.name,ret);
+		goto errout;
+	}
+
+	printk(KERN_INFO "PM: Fastpoweroff, %s profile added\n",fpo_default.name);
+errout:
+	return ret;
+}
+
+module_init(fsd_default_init);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Armin Kuster <[email protected]>");
+
kernel/power/fastoff/Kconfig +8 -0
Index: linux-2.6_dev/kernel/power/fastoff/Kconfig
===================================================================
@@ -10,4 +10,12 @@ config FAST_POWER_OFF
 	---help---
 	  Say yes if you want core support for sysfs/power/fastoff
 
+config FAST_POWER_DOWN
+	tristate "Fast power of profile"
+	depends on FAST_POWER_OFF
+	default n
+	---help---
+	  Say yes if want to bypass the rc kill scripts
+	  and shut the machine down
+
 endmenu
kernel/power/fastoff/Makefile +1 -1
Index: linux-2.6_dev/kernel/power/fastoff/Makefile
===================================================================
@@ -5,4 +5,4 @@
 #
 
 obj-$(CONFIG_FAST_POWER_OFF)	:= fpo.o
-
+obj-$(CONFIG_FAST_POWER_DOWN)	+= fastoffdrv.o
#1 lore raw
Quoted 1 line · On Sat, 27 Jan 2007 10:05:48 -1000 akuster wrote:

My apologies, I cc'd the wrong list the first time around.

+config FAST_POWER_DOWN
+ tristate "Fast power of profile"
---------------------------> off
What does that mean? especially the "profile" part?

+ depends on FAST_POWER_OFF

+ printk(KERN_INFO "PM: Fastpoweroff, %s profile added\n",fpo_default.name);

Space after "," please.

OK, let me see if I understand fsd_default_off().

+static int fsd_default_off(void)
+{
+ /*
+ * Actions taken:
+ *
+ * 1. Freeze all user processes.
+ *
+ * 2. Power off
+ *
+ * 3. Power off devices
+ */
+
+ printk(KERN_EMERG "Fast Power Off initiated.\n");
+ fastpoweroff_prepare();
+ fastpoweroff();
+ fastpoweroff_standby();
+ return 1;
+}

Does this say (2) power off the system and then (3) power off devices? How does it power off devices after calling fastpoweroff()? Or is fastpoweroff() only setting the stage for something to happen later?

Thanks,
---
~Randy

author
#2 lore raw
Quoted 15 lines · Randy Dunlap
Quoted 1 line · On Sat, 27 Jan 2007 10:05:48 -1000 akuster wrote:

My apologies, I cc'd the wrong list the first time around.

kernel/power/fastoff/Kconfig +2 -1
+config FAST_POWER_DOWN
+	tristate "Fast power of profile"
---------------------------> off

What does that mean? especially the "profile" part?

(quoted diff) +2 -0
+	depends on FAST_POWER_OFF
 
 
+	printk(KERN_INFO "PM: Fastpoweroff, %s profile added\n",fpo_default.name);
Quoted 1 line

Space after "," please.

will correct

Quoted 4 lines

OK, let me see if I understand fsd_default_off().

<snipped.

Quoted 2 lines

Does this say (2) power off the system and then (3) power off devices?

yes,

Quoted 1 line

How does it power off devices after calling fastpoweroff()?

It does not, it was only a last ditch effort before losing power. I was on the fence whether to include that, easy to remove.

Quoted 2 lines

Or is fastpoweroff() only setting the stage for something to happen later?

Nope.

Thanks for you time.
- Armin

#3 lore raw
In reply to akuster
Quoted 6 lines · akuster

My apologies, I cc'd the wrong list the first time around.

- Armin
---

Fastpoweroff default profile driver

Why don't you just call the existing reboot(2)? I've had a simple C program that does a very fast poweroff (or reboot) forever and it works just fine. It won't kill all processes, but if you really want to do that you can use killall -r .* first.

-Andi