linux-mips
[Top] [All Lists]

[PATCH -queue] Loongson: Cleanup the halt and poweroff action

To: Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH -queue] Loongson: Cleanup the halt and poweroff action
From: Wu Zhangjin <wuzhangjin@gmail.com>
Date: Wed, 27 Jan 2010 22:39:46 +0800
Cc: Liu Shiwei <liushiwei@gmail.com>, Wu Zhangjin <wuzhangjin@gmail.com>, linux-mips <linux-mips@linux-mips.org>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:reply-to:to:cc :content-type:organization:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=Y7Bb7+ms1TgkUQC5sMY9fgAf5au4f8nJVMY7wWp9oVg=; b=fqyFMe6BEnxdxofYt4/qb0f3ebSo4PuZgsHnr9pd007iP4+cdrhkkO0eDgxO/f+uhn Zgub/dUOW+jguiYIED5Ee4LEYuxvdHCA9aj9rLvLwIQA27MJKYQPNlGzlLVtR6ZkmpJF joVe3/90asi/3u7PeWc+FIIerDFHMmLF6JJPc=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:reply-to:to:cc:content-type:organization:date :message-id:mime-version:x-mailer:content-transfer-encoding; b=CdEUks89aHe/QG9UWiTGH9Q9Lvv8GzIBGu+lbmyo9zDT4PYbr1rlNkxPdP8f+fz7O+ xmx3hroSmIuxz+NzIb+iB4dWEh+WWEhKQ4M9y7L1HAeurZGeyUo4PyiAMGNaCuohIy3F dLqV+Z/VeyPvxxo+XSngrDqIYkJNp9+w6HMsM=
Organization: DSLab, Lanzhou University, China
Reply-to: wuzhangjin@gmail.com
Sender: linux-mips-bounce@linux-mips.org
(Add linux-mips <linux-mips@linux-mips.org> into the CC: list to make the 
patchwork get it!)

From: Wu Zhangjin <wuzhangjin@gmail.com>

In the old source code, I have let halt and poweroff do the same action,
but in reality, they have different meanings.

As the manpage of shutdown shows:

-r     Reboot after shutdown.
-H     Halt action is to halt or drop into boot monitor on systems that support 
it.
-P     Halt action is to turn off the power.

and in the real world, some machines(e.g. NAS) did not provide a power
button and the shutdown works as reset, so, we need to provide a
mechanism to let the users turn off the power safely without breaking
the system, such a mechanism is "halt", which only put the system into a
dead loop or a power-save mode and print some information to the screen
to tell the users to turn off the power safely.

$ shutdown -hH now /* loongson_halt, not turn off the power */
$ shutdown -hP now /* loongson_poweroff, work as poweroff */

Tested-by: Liu Shiwei <liushiwei@gmail.com>
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
 arch/mips/loongson/common/reset.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/mips/loongson/common/reset.c 
b/arch/mips/loongson/common/reset.c
index 33dff18..4bd9c18 100644
--- a/arch/mips/loongson/common/reset.c
+++ b/arch/mips/loongson/common/reset.c
@@ -25,17 +25,26 @@ static void loongson_restart(char *command)
        ((void (*)(void))ioremap_nocache(LOONGSON_BOOT_BASE, 4)) ();
 }
 
-static void loongson_halt(void)
+static void loongson_poweroff(void)
 {
        mach_prepare_shutdown();
        unreachable();
 }
 
+static void loongson_halt(void)
+{
+       pr_notice("\n\n** You can safely turn off the power now **\n\n");
+       while (1) {
+               if (cpu_wait)
+                       cpu_wait();
+       }
+}
+
 static int __init mips_reboot_setup(void)
 {
        _machine_restart = loongson_restart;
        _machine_halt = loongson_halt;
-       pm_power_off = loongson_halt;
+       pm_power_off = loongson_poweroff;
 
        return 0;
 }
-- 
1.6.6




<Prev in Thread] Current Thread [Next in Thread>