Re: linux-next: Tree for Dec 16

2014-12-15 Thread Guenter Roeck
On Tue, Dec 16, 2014 at 03:46:22PM +1100, Stephen Rothwell wrote:
 Hi all,
 
 Please do not add any code destined for v3.20 to your linux-next included
 trees/branches until after v3.19-rc1 is released.
 
 Changes since 20141215:
 
 The infiniband tree gained a conflict against Linus' tree and a build
 failure so I used the version from next-20141215.
 
 The userns tree gained a conflict against the vfs tree.
 
 The clk tree gained a build failure so I used the version from
 next-20141215.
 
 Non-merge commits (relative to Linus' tree): 3588
  2582 files changed, 123494 insertions(+), 135748 deletions(-)
 

My metag buildbot test fails with this kernel.

bisect result:

a82be12232dcccf6b914cec7458e96ee79fae0e3 is the first bad commit
commit a82be12232dcccf6b914cec7458e96ee79fae0e3
Author: Andy Lutomirski l...@amacapital.net
Date:   Tue Dec 16 13:26:43 2014 +1100

all arches, signal: move restart_block to struct task_struct

bisect log:

# bad: [a0eda581bf3fdc7be6bdf4cb18ce087675699336] Add linux-next specific files 
for 20141216
# good: [b2776bf7149bddd1f4161f14f79520f17fc1d71d] Linux 3.18
git bisect start 'HEAD' 'v3.18'
# good: [27afc5dbda52ee3dbcd0bda7375c917c6936b470] Merge branch 'for-linus' of 
git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
git bisect good 27afc5dbda52ee3dbcd0bda7375c917c6936b470
# good: [a5e6d5b3bb7124309ce581e9e050e029ab037609] Merge remote-tracking branch 
'l2-mtd/master'
git bisect good a5e6d5b3bb7124309ce581e9e050e029ab037609
# good: [93cc1d514a7e8bc4e00ce913ddccb34ee8a2a001] Merge remote-tracking branch 
'ipmi/for-next'
git bisect good 93cc1d514a7e8bc4e00ce913ddccb34ee8a2a001
# good: [865cde938ee6ab758fd47d1a36150aee20371b85] staging: unisys: virtpci: 
Fix CamelCase in delete_vbus_device()
git bisect good 865cde938ee6ab758fd47d1a36150aee20371b85
# good: [594e400a2c3a64d7c3ba8ad7b0196c887a354100] staging: comedi: das6402: 
add basic (*do_cmdtest) for AI async commands
git bisect good 594e400a2c3a64d7c3ba8ad7b0196c887a354100
# good: [4e8bb35b814a1377dcaf48b98d4ab29176528cdc] Merge remote-tracking branch 
'target-updates/for-next'
git bisect good 4e8bb35b814a1377dcaf48b98d4ab29176528cdc
# good: [e03f3bb62ca8a1124bc408046c50aed7629b24cc] next-20141215/clk
git bisect good e03f3bb62ca8a1124bc408046c50aed7629b24cc
# bad: [a82be12232dcccf6b914cec7458e96ee79fae0e3] all arches, signal: move 
restart_block to struct task_struct
git bisect bad a82be12232dcccf6b914cec7458e96ee79fae0e3
# good: [4425fdc4c01ab7699072a417741a008b0dca576b] ocfs2: do not fallback to 
buffer I/O write if appending
git bisect good 4425fdc4c01ab7699072a417741a008b0dca576b
# good: [98b090c1d15d1c94f01f071b283ce44be8644220] mm: define MADV_FREE for 
some arches
git bisect good 98b090c1d15d1c94f01f071b283ce44be8644220
# good: [ca402e9bfbbac21d3d7541c33adb60f7ebcc480e] arm: add pmd_mkclean for THP
git bisect good ca402e9bfbbac21d3d7541c33adb60f7ebcc480e
# good: [60eeb1279b50c205f045d2b7c76c906a2d2fb751] mm: Fix comment typo 
CONFIG_TRANSPARNTE_HUGE
git bisect good 60eeb1279b50c205f045d2b7c76c906a2d2fb751
# good: [1134212f12cb9e5b3c24b7be5cfa304486f2f96b] do_shared_fault(): check 
that mmap_sem is held
git bisect good 1134212f12cb9e5b3c24b7be5cfa304486f2f96b
# first bad commit: [a82be12232dcccf6b914cec7458e96ee79fae0e3] all arches, 
signal: move restart_block to struct task_struct

--

Guenter
--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: linux-next: Tree for Dec 16

2014-12-15 Thread Guenter Roeck

On 12/15/2014 10:44 PM, Andrew Morton wrote:

On Mon, 15 Dec 2014 22:35:49 -0800 Guenter Roeck li...@roeck-us.net wrote:


On Tue, Dec 16, 2014 at 03:46:22PM +1100, Stephen Rothwell wrote:

Hi all,

Please do not add any code destined for v3.20 to your linux-next included
trees/branches until after v3.19-rc1 is released.

Changes since 20141215:

The infiniband tree gained a conflict against Linus' tree and a build
failure so I used the version from next-20141215.

The userns tree gained a conflict against the vfs tree.

The clk tree gained a build failure so I used the version from
next-20141215.

Non-merge commits (relative to Linus' tree): 3588
  2582 files changed, 123494 insertions(+), 135748 deletions(-)



My metag buildbot test fails with this kernel.


Thanks.  What are the error messages?



Nothing. It just hangs until killed.

qemu log:
char device redirected to /dev/pts/5
Unable to load ROM!
qemu: terminating on signal 15 from pid 17843

http://server.roeck-us.net:8010/builders/qemu-metag-next/builds/60/steps/qemubuildcommand/logs/stdio

Normally output would be similar to the following.

/opt/buildbot/bin/qemu-system-meta -display none -kernel vmlinux -device 
da,exit_threads=1 -chardev stdio,id=chan1 -chardev pty,id=chan2 -append 
rdinit=/sbin/init
char device redirected to /dev/pts/29
Unable to load ROM!
Linux version 3.18.0+ (gro...@server.roeck-us.net) (gcc version 4.2.4 
(IMG-1.4.0.300)) #5 Mon Dec 15 22:50:31 PST 2014
LNKGET/SET go through cache but CONFIG_METAG_LNKGET_AROUND_CACHE=y
DA present
...

Guenter

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 08/48] kernel: Move pm_power_off to common code

2014-11-09 Thread Guenter Roeck
pm_power_off is defined for all architectures. Move it to common code.

Have all architectures call do_kernel_power_off instead of pm_power_off.
Some architectures point pm_power_off to machine_power_off. For those,
call do_kernel_power_off from machine_power_off instead.

Acked-by: David Vrabel david.vra...@citrix.com
Acked-by: Geert Uytterhoeven ge...@linux-m68k.org
Acked-by: Hirokazu Takata tak...@linux-m32r.org
Acked-by: James Hogan james.ho...@imgtec.com
Acked-by: Jesper Nilsson jesper.nils...@axis.com
Acked-by: Max Filippov jcmvb...@gmail.com
Acked-by: Rafael J. Wysocki r...@rjwysocki.net
Acked-by: Richard Weinberger rich...@nod.at
Acked-by: Xuetao Guan g...@mprc.pku.edu.cn
Acked-by: Ralf Baechle r...@linux-mips.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
v6:
- No change.
v5:
- Rebase to v3.18-rc3
- Update powerpc code to reflect merged power-off handler changes
v4:
- No change
v3:
- Replace poweroff in all newly introduced variables and in text
  with power_off or power-off as appropriate
v2:
- do_kernel_poweroff - do_kernel_power_off
- have_kernel_poweroff - have_kernel_power_off

 arch/alpha/kernel/process.c|  9 +++--
 arch/arc/kernel/reset.c|  5 +
 arch/arm/kernel/process.c  |  5 +
 arch/arm64/kernel/process.c|  5 +
 arch/avr32/kernel/process.c|  6 +-
 arch/blackfin/kernel/process.c |  3 ---
 arch/blackfin/kernel/reboot.c  |  2 ++
 arch/c6x/kernel/process.c  |  9 +
 arch/cris/kernel/process.c |  4 +---
 arch/frv/kernel/process.c  |  5 ++---
 arch/hexagon/kernel/reset.c|  5 ++---
 arch/ia64/kernel/process.c |  5 +
 arch/m32r/kernel/process.c |  8 
 arch/m68k/kernel/process.c |  6 +-
 arch/metag/kernel/process.c|  6 +-
 arch/microblaze/kernel/process.c   |  3 ---
 arch/microblaze/kernel/reset.c |  1 +
 arch/mips/kernel/reset.c   |  6 +-
 arch/mn10300/kernel/process.c  |  8 ++--
 arch/openrisc/kernel/process.c |  8 +---
 arch/parisc/kernel/process.c   |  8 
 arch/powerpc/kernel/setup-common.c |  6 +-
 arch/powerpc/xmon/xmon.c   |  3 +--
 arch/s390/kernel/setup.c   |  8 ++--
 arch/score/kernel/process.c|  8 
 arch/sh/kernel/reboot.c|  6 +-
 arch/sparc/kernel/process_32.c | 10 ++
 arch/sparc/kernel/reboot.c |  8 ++--
 arch/tile/kernel/reboot.c  |  7 +++
 arch/um/kernel/reboot.c|  2 --
 arch/unicore32/kernel/process.c|  9 +
 arch/x86/kernel/reboot.c   | 11 +++
 arch/x86/xen/enlighten.c   |  3 +--
 arch/xtensa/kernel/process.c   |  4 
 drivers/parisc/power.c |  3 +--
 kernel/power/power_off_handler.c   |  9 +
 kernel/reboot.c|  4 ++--
 37 files changed, 68 insertions(+), 150 deletions(-)

diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index 1941a07..81c43f8 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -24,6 +24,7 @@
 #include linux/vt.h
 #include linux/mman.h
 #include linux/elfcore.h
+#include linux/pm.h
 #include linux/reboot.h
 #include linux/tty.h
 #include linux/console.h
@@ -40,12 +41,6 @@
 #include proto.h
 #include pci_impl.h
 
-/*
- * Power off function, if any
- */
-void (*pm_power_off)(void) = machine_power_off;
-EXPORT_SYMBOL(pm_power_off);
-
 #ifdef CONFIG_ALPHA_WTINT
 /*
  * Sleep the CPU.
@@ -184,6 +179,8 @@ machine_halt(void)
 void
 machine_power_off(void)
 {
+   do_kernel_power_off();
+
common_shutdown(LINUX_REBOOT_CMD_POWER_OFF, NULL);
 }
 
diff --git a/arch/arc/kernel/reset.c b/arch/arc/kernel/reset.c
index 2768fa1..0758d9d 100644
--- a/arch/arc/kernel/reset.c
+++ b/arch/arc/kernel/reset.c
@@ -26,9 +26,6 @@ void machine_restart(char *__unused)
 
 void machine_power_off(void)
 {
-   /* FIXME ::  power off ??? */
+   do_kernel_power_off();
machine_halt();
 }
-
-void (*pm_power_off) (void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index fe972a2..aa3f656 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -117,8 +117,6 @@ void soft_restart(unsigned long addr)
 /*
  * Function pointers to optional machine specific functions
  */
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
 
 void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
 
@@ -205,8 +203,7 @@ void machine_power_off(void)
local_irq_disable();
smp_send_stop();
 
-   if (pm_power_off)
-   pm_power_off();
+   do_kernel_power_off();
 }
 
 /*
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index fde9923..6f623a0 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -68,8 +68,6 @@ void soft_restart(unsigned long addr)
 /*
  * Function pointers to optional

[PATCH v5 08/48] kernel: Move pm_power_off to common code

2014-11-06 Thread Guenter Roeck
pm_power_off is defined for all architectures. Move it to common code.

Have all architectures call do_kernel_power_off instead of pm_power_off.
Some architectures point pm_power_off to machine_power_off. For those,
call do_kernel_power_off from machine_power_off instead.

Acked-by: David Vrabel david.vra...@citrix.com
Acked-by: Geert Uytterhoeven ge...@linux-m68k.org
Acked-by: Hirokazu Takata tak...@linux-m32r.org
Acked-by: James Hogan james.ho...@imgtec.com
Acked-by: Jesper Nilsson jesper.nils...@axis.com
Acked-by: Max Filippov jcmvb...@gmail.com
Acked-by: Rafael J. Wysocki r...@rjwysocki.net
Acked-by: Richard Weinberger rich...@nod.at
Acked-by: Xuetao Guan g...@mprc.pku.edu.cn
Acked-by: Ralf Baechle r...@linux-mips.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
v5:
- Rebase to v3.18-rc3
- Update powerpc code to reflect merged power-off handler changes
v4:
- No change
v3:
- Replace poweroff in all newly introduced variables and in text
  with power_off or power-off as appropriate
v2:
- do_kernel_poweroff - do_kernel_power_off
- have_kernel_poweroff - have_kernel_power_off

 arch/alpha/kernel/process.c|  9 +++--
 arch/arc/kernel/reset.c|  5 +
 arch/arm/kernel/process.c  |  5 +
 arch/arm64/kernel/process.c|  5 +
 arch/avr32/kernel/process.c|  6 +-
 arch/blackfin/kernel/process.c |  3 ---
 arch/blackfin/kernel/reboot.c  |  2 ++
 arch/c6x/kernel/process.c  |  9 +
 arch/cris/kernel/process.c |  4 +---
 arch/frv/kernel/process.c  |  5 ++---
 arch/hexagon/kernel/reset.c|  5 ++---
 arch/ia64/kernel/process.c |  5 +
 arch/m32r/kernel/process.c |  8 
 arch/m68k/kernel/process.c |  6 +-
 arch/metag/kernel/process.c|  6 +-
 arch/microblaze/kernel/process.c   |  3 ---
 arch/microblaze/kernel/reset.c |  1 +
 arch/mips/kernel/reset.c   |  6 +-
 arch/mn10300/kernel/process.c  |  8 ++--
 arch/openrisc/kernel/process.c |  8 +---
 arch/parisc/kernel/process.c   |  8 
 arch/powerpc/kernel/setup-common.c |  6 +-
 arch/powerpc/xmon/xmon.c   |  3 +--
 arch/s390/kernel/setup.c   |  8 ++--
 arch/score/kernel/process.c|  8 
 arch/sh/kernel/reboot.c|  6 +-
 arch/sparc/kernel/process_32.c | 10 ++
 arch/sparc/kernel/reboot.c |  8 ++--
 arch/tile/kernel/reboot.c  |  7 +++
 arch/um/kernel/reboot.c|  2 --
 arch/unicore32/kernel/process.c|  9 +
 arch/x86/kernel/reboot.c   | 11 +++
 arch/x86/xen/enlighten.c   |  3 +--
 arch/xtensa/kernel/process.c   |  4 
 drivers/parisc/power.c |  3 +--
 kernel/power/power_off_handler.c   |  9 +
 kernel/reboot.c|  4 ++--
 37 files changed, 68 insertions(+), 150 deletions(-)

diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index 1941a07..81c43f8 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -24,6 +24,7 @@
 #include linux/vt.h
 #include linux/mman.h
 #include linux/elfcore.h
+#include linux/pm.h
 #include linux/reboot.h
 #include linux/tty.h
 #include linux/console.h
@@ -40,12 +41,6 @@
 #include proto.h
 #include pci_impl.h
 
-/*
- * Power off function, if any
- */
-void (*pm_power_off)(void) = machine_power_off;
-EXPORT_SYMBOL(pm_power_off);
-
 #ifdef CONFIG_ALPHA_WTINT
 /*
  * Sleep the CPU.
@@ -184,6 +179,8 @@ machine_halt(void)
 void
 machine_power_off(void)
 {
+   do_kernel_power_off();
+
common_shutdown(LINUX_REBOOT_CMD_POWER_OFF, NULL);
 }
 
diff --git a/arch/arc/kernel/reset.c b/arch/arc/kernel/reset.c
index 2768fa1..0758d9d 100644
--- a/arch/arc/kernel/reset.c
+++ b/arch/arc/kernel/reset.c
@@ -26,9 +26,6 @@ void machine_restart(char *__unused)
 
 void machine_power_off(void)
 {
-   /* FIXME ::  power off ??? */
+   do_kernel_power_off();
machine_halt();
 }
-
-void (*pm_power_off) (void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index fe972a2..aa3f656 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -117,8 +117,6 @@ void soft_restart(unsigned long addr)
 /*
  * Function pointers to optional machine specific functions
  */
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
 
 void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
 
@@ -205,8 +203,7 @@ void machine_power_off(void)
local_irq_disable();
smp_send_stop();
 
-   if (pm_power_off)
-   pm_power_off();
+   do_kernel_power_off();
 }
 
 /*
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index fde9923..6f623a0 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -68,8 +68,6 @@ void soft_restart(unsigned long addr)
 /*
  * Function pointers to optional machine specific

Re: [PATCH 33/44] avr32: atngw100: Register with kernel poweroff handler

2014-11-01 Thread Guenter Roeck

On 11/01/2014 03:16 AM, Hans-Christian Egtvedt wrote:

Around Mon 06 Oct 2014 22:28:35 -0700 or thereabout, Guenter Roeck wrote:

Register with kernel poweroff handler instead of setting pm_power_off
directly.

Cc: Haavard Skinnemoen hskinnem...@gmail.com
Cc: Hans-Christian Egtvedt egtv...@samfundet.no
Signed-off-by: Guenter Roeck li...@roeck-us.net


Acked-by: Hans-Christian Egtvedt egtv...@samfundet.no



Thanks!

Guenter

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 08/47] kernel: Move pm_power_off to common code

2014-10-27 Thread Guenter Roeck
pm_power_off is defined for all architectures. Move it to common code.

Have all architectures call do_kernel_power_off instead of pm_power_off.
Some architectures point pm_power_off to machine_power_off. For those,
call do_kernel_power_off from machine_power_off instead.

Acked-by: David Vrabel david.vra...@citrix.com
Acked-by: Geert Uytterhoeven ge...@linux-m68k.org
Acked-by: Hirokazu Takata tak...@linux-m32r.org
Acked-by: James Hogan james.ho...@imgtec.com
Acked-by: Jesper Nilsson jesper.nils...@axis.com
Acked-by: Max Filippov jcmvb...@gmail.com
Acked-by: Rafael J. Wysocki r...@rjwysocki.net
Acked-by: Richard Weinberger rich...@nod.at
Acked-by: Xuetao Guan g...@mprc.pku.edu.cn
Acked-by: Ralf Baechle r...@linux-mips.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
v3:
- Replace poweroff in all newly introduced variables and in text
  with power_off or power-off as appropriate
v2:
- do_kernel_poweroff - do_kernel_power_off
- have_kernel_poweroff - have_kernel_power_off

 arch/alpha/kernel/process.c|  9 +++--
 arch/arc/kernel/reset.c|  5 +
 arch/arm/kernel/process.c  |  5 +
 arch/arm64/kernel/process.c|  5 +
 arch/avr32/kernel/process.c|  6 +-
 arch/blackfin/kernel/process.c |  3 ---
 arch/blackfin/kernel/reboot.c  |  2 ++
 arch/c6x/kernel/process.c  |  9 +
 arch/cris/kernel/process.c |  4 +---
 arch/frv/kernel/process.c  |  5 ++---
 arch/hexagon/kernel/reset.c|  5 ++---
 arch/ia64/kernel/process.c |  5 +
 arch/m32r/kernel/process.c |  8 
 arch/m68k/kernel/process.c |  6 +-
 arch/metag/kernel/process.c|  6 +-
 arch/microblaze/kernel/process.c   |  3 ---
 arch/microblaze/kernel/reset.c |  1 +
 arch/mips/kernel/reset.c   |  6 +-
 arch/mn10300/kernel/process.c  |  8 ++--
 arch/openrisc/kernel/process.c |  8 +---
 arch/parisc/kernel/process.c   |  8 
 arch/powerpc/kernel/setup-common.c |  6 +++---
 arch/s390/kernel/setup.c   |  8 ++--
 arch/score/kernel/process.c|  8 
 arch/sh/kernel/reboot.c|  6 +-
 arch/sparc/kernel/process_32.c | 10 ++
 arch/sparc/kernel/reboot.c |  8 ++--
 arch/tile/kernel/reboot.c  |  7 +++
 arch/um/kernel/reboot.c|  2 --
 arch/unicore32/kernel/process.c|  9 +
 arch/x86/kernel/reboot.c   | 11 +++
 arch/x86/xen/enlighten.c   |  3 +--
 arch/xtensa/kernel/process.c   |  4 
 drivers/parisc/power.c |  3 +--
 kernel/power/power_off_handler.c   |  8 
 kernel/reboot.c|  4 ++--
 36 files changed, 68 insertions(+), 146 deletions(-)

diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index 1941a07..81c43f8 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -24,6 +24,7 @@
 #include linux/vt.h
 #include linux/mman.h
 #include linux/elfcore.h
+#include linux/pm.h
 #include linux/reboot.h
 #include linux/tty.h
 #include linux/console.h
@@ -40,12 +41,6 @@
 #include proto.h
 #include pci_impl.h
 
-/*
- * Power off function, if any
- */
-void (*pm_power_off)(void) = machine_power_off;
-EXPORT_SYMBOL(pm_power_off);
-
 #ifdef CONFIG_ALPHA_WTINT
 /*
  * Sleep the CPU.
@@ -184,6 +179,8 @@ machine_halt(void)
 void
 machine_power_off(void)
 {
+   do_kernel_power_off();
+
common_shutdown(LINUX_REBOOT_CMD_POWER_OFF, NULL);
 }
 
diff --git a/arch/arc/kernel/reset.c b/arch/arc/kernel/reset.c
index 2768fa1..0758d9d 100644
--- a/arch/arc/kernel/reset.c
+++ b/arch/arc/kernel/reset.c
@@ -26,9 +26,6 @@ void machine_restart(char *__unused)
 
 void machine_power_off(void)
 {
-   /* FIXME ::  power off ??? */
+   do_kernel_power_off();
machine_halt();
 }
-
-void (*pm_power_off) (void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index fe972a2..aa3f656 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -117,8 +117,6 @@ void soft_restart(unsigned long addr)
 /*
  * Function pointers to optional machine specific functions
  */
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
 
 void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
 
@@ -205,8 +203,7 @@ void machine_power_off(void)
local_irq_disable();
smp_send_stop();
 
-   if (pm_power_off)
-   pm_power_off();
+   do_kernel_power_off();
 }
 
 /*
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index fde9923..6f623a0 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -68,8 +68,6 @@ void soft_restart(unsigned long addr)
 /*
  * Function pointers to optional machine specific functions
  */
-void (*pm_power_off)(void);
-EXPORT_SYMBOL_GPL(pm_power_off);
 
 void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd

Re: [PATCH v2 08/47] kernel: Move pm_power_off to common code

2014-10-24 Thread Guenter Roeck
On Fri, Oct 24, 2014 at 10:47:03AM +0100, James Hogan wrote:
 Hi Guenter,
 
 On 21/10/14 05:12, Guenter Roeck wrote:
  pm_power_off is defined for all architectures. Move it to common code.
  
  Have all architectures call do_kernel_power_off instead of pm_power_off.
  Some architectures point pm_power_off to machine_power_off. For those,
  call do_kernel_power_off from machine_power_off instead.
  
  Acked-by: David Vrabel david.vra...@citrix.com
  Acked-by: Geert Uytterhoeven ge...@linux-m68k.org
  Acked-by: Hirokazu Takata tak...@linux-m32r.org
  Acked-by: Jesper Nilsson jesper.nils...@axis.com
  Acked-by: Max Filippov jcmvb...@gmail.com
  Acked-by: Rafael J. Wysocki r...@rjwysocki.net
  Acked-by: Richard Weinberger rich...@nod.at
  Acked-by: Xuetao Guan g...@mprc.pku.edu.cn
 
 For metag:
 Acked-by: James Hogan james.ho...@imgtec.com
 
Thanks!

Guenter
--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 08/47] kernel: Move pm_power_off to common code

2014-10-22 Thread Guenter Roeck
On Wed, Oct 22, 2014 at 05:31:36PM +0200, Ralf Baechle wrote:
 On Mon, Oct 20, 2014 at 09:12:24PM -0700, Guenter Roeck wrote:
 
  pm_power_off is defined for all architectures. Move it to common code.
  
  Have all architectures call do_kernel_power_off instead of pm_power_off.
  Some architectures point pm_power_off to machine_power_off. For those,
  call do_kernel_power_off from machine_power_off instead.
  
  Acked-by: David Vrabel david.vra...@citrix.com
  Acked-by: Geert Uytterhoeven ge...@linux-m68k.org
  Acked-by: Hirokazu Takata tak...@linux-m32r.org
  Acked-by: Jesper Nilsson jesper.nils...@axis.com
  Acked-by: Max Filippov jcmvb...@gmail.com
  Acked-by: Rafael J. Wysocki r...@rjwysocki.net
  Acked-by: Richard Weinberger rich...@nod.at
  Acked-by: Xuetao Guan g...@mprc.pku.edu.cn
  Signed-off-by: Guenter Roeck li...@roeck-us.net
 
 Acked-by: Ralf Baechle r...@linux-mips.org

Thanks!

Guenter
--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 08/47] kernel: Move pm_power_off to common code

2014-10-20 Thread Guenter Roeck
pm_power_off is defined for all architectures. Move it to common code.

Have all architectures call do_kernel_power_off instead of pm_power_off.
Some architectures point pm_power_off to machine_power_off. For those,
call do_kernel_power_off from machine_power_off instead.

Acked-by: David Vrabel david.vra...@citrix.com
Acked-by: Geert Uytterhoeven ge...@linux-m68k.org
Acked-by: Hirokazu Takata tak...@linux-m32r.org
Acked-by: Jesper Nilsson jesper.nils...@axis.com
Acked-by: Max Filippov jcmvb...@gmail.com
Acked-by: Rafael J. Wysocki r...@rjwysocki.net
Acked-by: Richard Weinberger rich...@nod.at
Acked-by: Xuetao Guan g...@mprc.pku.edu.cn
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
v2:
- do_kernel_poweroff - do_kernel_power_off
- have_kernel_poweroff - have_kernel_power_off

 arch/alpha/kernel/process.c|  9 +++--
 arch/arc/kernel/reset.c|  5 +
 arch/arm/kernel/process.c  |  5 +
 arch/arm64/kernel/process.c|  5 +
 arch/avr32/kernel/process.c|  6 +-
 arch/blackfin/kernel/process.c |  3 ---
 arch/blackfin/kernel/reboot.c  |  2 ++
 arch/c6x/kernel/process.c  |  9 +
 arch/cris/kernel/process.c |  4 +---
 arch/frv/kernel/process.c  |  5 ++---
 arch/hexagon/kernel/reset.c|  5 ++---
 arch/ia64/kernel/process.c |  5 +
 arch/m32r/kernel/process.c |  8 
 arch/m68k/kernel/process.c |  6 +-
 arch/metag/kernel/process.c|  6 +-
 arch/microblaze/kernel/process.c   |  3 ---
 arch/microblaze/kernel/reset.c |  1 +
 arch/mips/kernel/reset.c   |  6 +-
 arch/mn10300/kernel/process.c  |  8 ++--
 arch/openrisc/kernel/process.c |  8 +---
 arch/parisc/kernel/process.c   |  8 
 arch/powerpc/kernel/setup-common.c |  6 +++---
 arch/s390/kernel/setup.c   |  8 ++--
 arch/score/kernel/process.c|  8 
 arch/sh/kernel/reboot.c|  6 +-
 arch/sparc/kernel/process_32.c | 10 ++
 arch/sparc/kernel/reboot.c |  8 ++--
 arch/tile/kernel/reboot.c  |  7 +++
 arch/um/kernel/reboot.c|  2 --
 arch/unicore32/kernel/process.c|  9 +
 arch/x86/kernel/reboot.c   | 11 +++
 arch/x86/xen/enlighten.c   |  3 +--
 arch/xtensa/kernel/process.c   |  4 
 drivers/parisc/power.c |  3 +--
 kernel/power/poweroff_handler.c|  8 
 kernel/reboot.c|  4 ++--
 36 files changed, 68 insertions(+), 146 deletions(-)

diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index 1941a07..81c43f8 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -24,6 +24,7 @@
 #include linux/vt.h
 #include linux/mman.h
 #include linux/elfcore.h
+#include linux/pm.h
 #include linux/reboot.h
 #include linux/tty.h
 #include linux/console.h
@@ -40,12 +41,6 @@
 #include proto.h
 #include pci_impl.h
 
-/*
- * Power off function, if any
- */
-void (*pm_power_off)(void) = machine_power_off;
-EXPORT_SYMBOL(pm_power_off);
-
 #ifdef CONFIG_ALPHA_WTINT
 /*
  * Sleep the CPU.
@@ -184,6 +179,8 @@ machine_halt(void)
 void
 machine_power_off(void)
 {
+   do_kernel_power_off();
+
common_shutdown(LINUX_REBOOT_CMD_POWER_OFF, NULL);
 }
 
diff --git a/arch/arc/kernel/reset.c b/arch/arc/kernel/reset.c
index 2768fa1..0758d9d 100644
--- a/arch/arc/kernel/reset.c
+++ b/arch/arc/kernel/reset.c
@@ -26,9 +26,6 @@ void machine_restart(char *__unused)
 
 void machine_power_off(void)
 {
-   /* FIXME ::  power off ??? */
+   do_kernel_power_off();
machine_halt();
 }
-
-void (*pm_power_off) (void) = NULL;
-EXPORT_SYMBOL(pm_power_off);
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index fe972a2..aa3f656 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -117,8 +117,6 @@ void soft_restart(unsigned long addr)
 /*
  * Function pointers to optional machine specific functions
  */
-void (*pm_power_off)(void);
-EXPORT_SYMBOL(pm_power_off);
 
 void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
 
@@ -205,8 +203,7 @@ void machine_power_off(void)
local_irq_disable();
smp_send_stop();
 
-   if (pm_power_off)
-   pm_power_off();
+   do_kernel_power_off();
 }
 
 /*
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index c3065db..46a483a 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -68,8 +68,6 @@ void soft_restart(unsigned long addr)
 /*
  * Function pointers to optional machine specific functions
  */
-void (*pm_power_off)(void);
-EXPORT_SYMBOL_GPL(pm_power_off);
 
 void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
 
@@ -129,8 +127,7 @@ void machine_power_off(void)
 {
local_irq_disable();
smp_send_stop();
-   if (pm_power_off)
-   pm_power_off();
+   do_kernel_power_off

Re: [PATCH 12/44] mfd: ab8500-sysctrl: Register with kernel poweroff handler

2014-10-09 Thread Guenter Roeck

On 10/09/2014 03:49 AM, Lee Jones wrote:

On Thu, 09 Oct 2014, Catalin Marinas wrote:


On Tue, Oct 07, 2014 at 09:00:48AM +0100, Lee Jones wrote:

On Mon, 06 Oct 2014, Guenter Roeck wrote:

--- a/drivers/mfd/ab8500-sysctrl.c
+++ b/drivers/mfd/ab8500-sysctrl.c
@@ -6,6 +6,7 @@


[...]


+static int ab8500_power_off(struct notifier_block *this, unsigned long unused1,
+   void *unused2)
  {
sigset_t old;
sigset_t all;
@@ -34,11 +36,6 @@ static void ab8500_power_off(void)
struct power_supply *psy;
int ret;

-   if (sysctrl_dev == NULL) {
-   pr_err(%s: sysctrl not initialized\n, __func__);
-   return;
-   }


Can you explain the purpose of this change please?


I guess it's because the sysctrl_dev is already initialised when
registering the power_off handler, so there isn't a way to call the
above function with a NULL sysctrl_dev. Probably even with the original
code you didn't need this check (after some race fix in
ab8500_sysctrl_remove but races is one of the things Guenter's patches
try to address).


Sounds reasonable, although I think this change should be part of
another patch.


Sure, no problem. I'll split this into two patches.

Since we are at it, any idea what to do with the restart function
in the same file ? It is not used anywhere.

Guenter

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/44] kernel: Add support for poweroff handler call chain

2014-10-09 Thread Guenter Roeck
On Thu, Oct 09, 2014 at 12:31:43PM +0200, Pavel Machek wrote:
 Hi!
 
  +/**
  + * register_poweroff_handler_simple - Register function to be called to 
  power off
  + *the system
  + * @handler:   Function to be called to power off the system
  + * @priority:  Handler priority. For priority guidelines see
  + * register_poweroff_handler.
  + *
  + * This is a simplified version of register_poweroff_handler. It does not
  + * take a notifier as argument, but a function pointer. The function
  + * registers a poweroff handler with specified priority. Poweroff
  + * handlers registered with this function can not be unregistered,
  + * and only a single poweroff handler can be installed using it.
  + *
  + * This function must not be called from modules and is therefore
  + * not exported.
  + *
  + * Returns -EBUSY if a poweroff handler has already been registered
  + * using register_poweroff_handler_simple. Otherwise returns zero,
  + * since atomic_notifier_chain_register() currently always returns zero.
  + */
  +int register_poweroff_handler_simple(void (*handler)(void), int priority)
  +{
  +   char symname[KSYM_NAME_LEN];
  +
  +   if (poweroff_handler_data.handler) {
  +   lookup_symbol_name((unsigned long)poweroff_handler_data.handler,
  +  symname);
  +   pr_warn(Poweroff function already registered (%s), symname);
  +   lookup_symbol_name((unsigned long)handler, symname);
  +   pr_cont(, cannot register %s\n, symname);
  +   return -EBUSY;
  +   }
 
 Dunno, are you maybe overdoing the debugging infrastructure a bit?
 This is not going to happen in production, and if it does happen,
 developer can look the symbol name himself.

On the other side, I don't think it hurts to have that message.
Anyway, I'll use %ps as suggested by Geert.

Guenter
--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 12/44] mfd: ab8500-sysctrl: Register with kernel poweroff handler

2014-10-09 Thread Guenter Roeck
On Thu, Oct 09, 2014 at 02:33:55PM +0100, Lee Jones wrote:
 On Thu, 09 Oct 2014, Guenter Roeck wrote:
 
  On 10/09/2014 03:49 AM, Lee Jones wrote:
  On Thu, 09 Oct 2014, Catalin Marinas wrote:
  
  On Tue, Oct 07, 2014 at 09:00:48AM +0100, Lee Jones wrote:
  On Mon, 06 Oct 2014, Guenter Roeck wrote:
  --- a/drivers/mfd/ab8500-sysctrl.c
  +++ b/drivers/mfd/ab8500-sysctrl.c
  @@ -6,6 +6,7 @@
  
  [...]
  
  +static int ab8500_power_off(struct notifier_block *this, unsigned long 
  unused1,
  +   void *unused2)
{
  sigset_t old;
  sigset_t all;
  @@ -34,11 +36,6 @@ static void ab8500_power_off(void)
  struct power_supply *psy;
  int ret;
  
  -   if (sysctrl_dev == NULL) {
  -   pr_err(%s: sysctrl not initialized\n, __func__);
  -   return;
  -   }
  
  Can you explain the purpose of this change please?
  
  I guess it's because the sysctrl_dev is already initialised when
  registering the power_off handler, so there isn't a way to call the
  above function with a NULL sysctrl_dev. Probably even with the original
  code you didn't need this check (after some race fix in
  ab8500_sysctrl_remove but races is one of the things Guenter's patches
  try to address).
  
  Sounds reasonable, although I think this change should be part of
  another patch.
  
  Sure, no problem. I'll split this into two patches.
  
  Since we are at it, any idea what to do with the restart function
  in the same file ? It is not used anywhere.
 
 You can strip it out with Linus Walleij's Ack.  Or I'll be happy to do
 it?
 
I'll strip it out in a 3rd patch.

Guenter
--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 12/44] mfd: ab8500-sysctrl: Register with kernel poweroff handler

2014-10-09 Thread Guenter Roeck
On Thu, Oct 09, 2014 at 11:49:27AM +0100, Lee Jones wrote:
 On Thu, 09 Oct 2014, Catalin Marinas wrote:
 
  On Tue, Oct 07, 2014 at 09:00:48AM +0100, Lee Jones wrote:
   On Mon, 06 Oct 2014, Guenter Roeck wrote:
--- a/drivers/mfd/ab8500-sysctrl.c
+++ b/drivers/mfd/ab8500-sysctrl.c
@@ -6,6 +6,7 @@
   
   [...]
   
+static int ab8500_power_off(struct notifier_block *this, unsigned long 
unused1,
+   void *unused2)
 {
sigset_t old;
sigset_t all;
@@ -34,11 +36,6 @@ static void ab8500_power_off(void)
struct power_supply *psy;
int ret;
 
-   if (sysctrl_dev == NULL) {
-   pr_err(%s: sysctrl not initialized\n, __func__);
-   return;
-   }
   
   Can you explain the purpose of this change please?
  
  I guess it's because the sysctrl_dev is already initialised when
  registering the power_off handler, so there isn't a way to call the
  above function with a NULL sysctrl_dev. Probably even with the original
  code you didn't need this check (after some race fix in
  ab8500_sysctrl_remove but races is one of the things Guenter's patches
  try to address).
 
 Sounds reasonable, although I think this change should be part of
 another patch.
 
Turns out the options are to either drop the check or to use the device
managed function to register the poweroff handler. I decided to keep
the check and use the device managed function.

Guenter
--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 07/44] qnap-poweroff: Drop reference to pm_power_off from devicetree bindings

2014-10-07 Thread Guenter Roeck
On Tue, Oct 07, 2014 at 12:02:19PM +0100, Mark Rutland wrote:
 On Tue, Oct 07, 2014 at 06:28:09AM +0100, Guenter Roeck wrote:
  Replace reference to pm_power_off (which is an implementation detail)
  and replace it with a more generic description of the driver's 
  functionality.
  
  Cc: Rob Herring robh...@kernel.org
  Cc: Pawel Moll pawel.m...@arm.com
  Cc: Mark Rutland mark.rutl...@arm.com
  Signed-off-by: Guenter Roeck li...@roeck-us.net
  ---
   Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
  
  diff --git 
  a/Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt 
  b/Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt
  index af25e77..1e2260a 100644
  --- a/Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt
  +++ b/Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt
  @@ -3,8 +3,8 @@
   QNAP NAS devices have a microcontroller controlling the main power
   supply. This microcontroller is connected to UART1 of the Kirkwood and
   Orion5x SoCs. Sending the character 'A', at 19200 baud, tells the
  -microcontroller to turn the power off. This driver adds a handler to
  -pm_power_off which is called to turn the power off.
  +microcontroller to turn the power off. This driver installs a handler
  +to power off the system.
 
 I'd remove the last sentence -- the driver is also independent of the
 HW, and the description of how the power off works at the HW level is
 sufficient.
 
Done.

 With that:
 
 Acked-by: Mark Rutland mark.rutl...@arm.com
 
Thanks!

Guenter
--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/44] mfd: axp20x: Register with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly. Register with a low priority value of 64 to reflect that
the original code only sets pm_power_off if it was not already set.

Cc: Lee Jones lee.jo...@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/mfd/axp20x.c   | 30 +-
 include/linux/mfd/axp20x.h |  1 +
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
index dee6539..238db4c 100644
--- a/drivers/mfd/axp20x.c
+++ b/drivers/mfd/axp20x.c
@@ -17,7 +17,8 @@
 #include linux/interrupt.h
 #include linux/kernel.h
 #include linux/module.h
-#include linux/pm_runtime.h
+#include linux/notifier.h
+#include linux/pm.h
 #include linux/regmap.h
 #include linux/slab.h
 #include linux/regulator/consumer.h
@@ -161,11 +162,16 @@ static struct mfd_cell axp20x_cells[] = {
},
 };
 
-static struct axp20x_dev *axp20x_pm_power_off;
-static void axp20x_power_off(void)
+static int axp20x_power_off(struct notifier_block *this, unsigned long unused1,
+   void *unused2)
+
 {
-   regmap_write(axp20x_pm_power_off-regmap, AXP20X_OFF_CTRL,
-AXP20X_OFF);
+   struct axp20x_dev *axp20x = container_of(this, struct axp20x_dev,
+poweroff_nb);
+
+   regmap_write(axp20x-regmap, AXP20X_OFF_CTRL, AXP20X_OFF);
+
+   return NOTIFY_DONE;
 }
 
 static int axp20x_i2c_probe(struct i2c_client *i2c,
@@ -215,10 +221,11 @@ static int axp20x_i2c_probe(struct i2c_client *i2c,
return ret;
}
 
-   if (!pm_power_off) {
-   axp20x_pm_power_off = axp20x;
-   pm_power_off = axp20x_power_off;
-   }
+   axp20x-poweroff_nb.notifier_call = axp20x_power_off;
+   axp20x-poweroff_nb.priority = 64;
+   ret = register_poweroff_handler(axp20x-poweroff_nb);
+   if (ret)
+   dev_err(i2c-dev, failed to register poweroff handler\n);
 
dev_info(i2c-dev, AXP20X driver loaded\n);
 
@@ -229,10 +236,7 @@ static int axp20x_i2c_remove(struct i2c_client *i2c)
 {
struct axp20x_dev *axp20x = i2c_get_clientdata(i2c);
 
-   if (axp20x == axp20x_pm_power_off) {
-   axp20x_pm_power_off = NULL;
-   pm_power_off = NULL;
-   }
+   unregister_poweroff_handler(axp20x-poweroff_nb);
 
mfd_remove_devices(axp20x-dev);
regmap_del_irq_chip(axp20x-i2c_client-irq, axp20x-regmap_irqc);
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index d0e31a2..8f23b39 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -175,6 +175,7 @@ struct axp20x_dev {
struct regmap   *regmap;
struct regmap_irq_chip_data *regmap_irqc;
longvariant;
+   struct notifier_block   poweroff_nb;
 };
 
 #endif /* __LINUX_MFD_AXP20X_H */
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 27/44] x86: apm: Register with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly. Register with high priority value of 192 to reflect that
the original code overwrites existing poweroff handlers.

Cc: Thomas Gleixner t...@linutronix.de
Cc: Ingo Molnar mi...@redhat.com
Cc: H. Peter Anvin h...@zytor.com
Cc: Jiri Kosina jkos...@suse.cz
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 arch/x86/kernel/apm_32.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 5848744..84566a6 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -219,6 +219,7 @@
 #include linux/init.h
 #include linux/time.h
 #include linux/sched.h
+#include linux/notifier.h
 #include linux/pm.h
 #include linux/capability.h
 #include linux/device.h
@@ -981,7 +982,8 @@ recalc:
  * on their first cpu.
  */
 
-static void apm_power_off(void)
+static int apm_power_off(struct notifier_block *this, unsigned long unused1,
+void *unused2)
 {
/* Some bioses don't like being called from CPU != 0 */
if (apm_info.realmode_power_off) {
@@ -990,8 +992,14 @@ static void apm_power_off(void)
} else {
(void)set_system_power_state(APM_STATE_OFF);
}
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block apm_poweroff_nb = {
+   .notifier_call = apm_power_off,
+   .priority = 192,
+};
+
 #ifdef CONFIG_APM_DO_ENABLE
 
 /**
@@ -1847,8 +1855,11 @@ static int apm(void *unused)
}
 
/* Install our power off handler.. */
-   if (power_off)
-   pm_power_off = apm_power_off;
+   if (power_off) {
+   error = register_poweroff_handler(apm_poweroff_nb);
+   if (error)
+   pr_err(apm: Failed to register poweroff handler\n);
+   }
 
if (num_online_cpus() == 1 || smp) {
 #if defined(CONFIG_APM_DISPLAY_BLANK)  defined(CONFIG_VT)
@@ -2408,9 +2419,8 @@ static void __exit apm_exit(void)
apm_error(disengage power management, error);
}
misc_deregister(apm_device);
+   unregister_poweroff_handler(apm_poweroff_nb);
remove_proc_entry(apm, NULL);
-   if (power_off)
-   pm_power_off = NULL;
if (kapmd_task) {
kthread_stop(kapmd_task);
kapmd_task = NULL;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/44] memory: emif: Use API function to determine poweroff capability

2014-10-06 Thread Guenter Roeck
Use have_kernel_poweroff() to determine if the kernel is able
to power off the system.

Cc: Santosh Shilimkar santosh.shilim...@ti.com
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/memory/emif.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c
index 04644e7..acd830a 100644
--- a/drivers/memory/emif.c
+++ b/drivers/memory/emif.c
@@ -1053,10 +1053,10 @@ static irqreturn_t emif_threaded_isr(int irq, void 
*dev_id)
dev_emerg(emif-dev, SDRAM temperature exceeds operating 
limit.. Needs shut down!!!\n);
 
/* If we have Power OFF ability, use it, else try restarting */
-   if (pm_power_off) {
+   if (have_kernel_poweroff()) {
kernel_power_off();
} else {
-   WARN(1, FIXME: NO pm_power_off!!! trying restart\n);
+   WARN(1, FIXME: NO kernel poweroff capability!!! trying 
restart\n);
kernel_restart(SDRAM Over-temp Emergency restart);
}
return IRQ_HANDLED;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 32/44] arm64: psci: Register with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly.

Cc: Catalin Marinas catalin.mari...@arm.com
Cc: Will Deacon will.dea...@arm.com
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 arch/arm64/kernel/psci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c
index 5539547..c1f3d09 100644
--- a/arch/arm64/kernel/psci.c
+++ b/arch/arm64/kernel/psci.c
@@ -286,7 +286,7 @@ static int __init psci_0_2_init(struct device_node *np)
 
arm_pm_restart = psci_sys_reset;
 
-   pm_power_off = psci_sys_poweroff;
+   register_poweroff_handler_simple(psci_sys_poweroff, 128);
 
 out_put_node:
of_node_put(np);
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 30/44] acpi: Register poweroff handler with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly. Register with high priority value of 192 to reflect that
the driver explicitly overrides existing poweroff handlers.

Cc: Rafael J. Wysocki r...@rjwysocki.net
Cc: Len Brown l...@kernel.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/acpi/sleep.c | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 54da4a3..25aad22 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -15,6 +15,8 @@
 #include linux/dmi.h
 #include linux/device.h
 #include linux/suspend.h
+#include linux/notifier.h
+#include linux/pm.h
 #include linux/reboot.h
 #include linux/acpi.h
 #include linux/module.h
@@ -811,14 +813,22 @@ static void acpi_power_off_prepare(void)
acpi_disable_all_gpes();
 }
 
-static void acpi_power_off(void)
+static int acpi_power_off(struct notifier_block *this,
+ unsigned long unused1, void *unused2)
 {
/* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
printk(KERN_DEBUG %s called\n, __func__);
local_irq_disable();
acpi_enter_sleep_state(ACPI_STATE_S5);
+
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block acpi_poweroff_nb = {
+   .notifier_call = acpi_power_off,
+   .priority = 192,
+};
+
 int __init acpi_sleep_init(void)
 {
char supported[ACPI_S_STATE_COUNT * 3 + 1];
@@ -835,7 +845,8 @@ int __init acpi_sleep_init(void)
if (acpi_sleep_state_supported(ACPI_STATE_S5)) {
sleep_states[ACPI_STATE_S5] = 1;
pm_power_off_prepare = acpi_power_off_prepare;
-   pm_power_off = acpi_power_off;
+   if (register_poweroff_handler(acpi_poweroff_nb))
+   pr_err(acpi: Failed to register poweroff handler\n);
}
 
supported[0] = 0;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/44] mfd: retu: Register with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly. Register with a low priority value of 64 to reflect that
the original code only sets pm_power_off if it was not already set.

Cc: Lee Jones lee.jo...@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/mfd/retu-mfd.c | 33 +++--
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/mfd/retu-mfd.c b/drivers/mfd/retu-mfd.c
index 663f8a3..64b60fa 100644
--- a/drivers/mfd/retu-mfd.c
+++ b/drivers/mfd/retu-mfd.c
@@ -22,6 +22,8 @@
 #include linux/slab.h
 #include linux/mutex.h
 #include linux/module.h
+#include linux/notifier.h
+#include linux/pm.h
 #include linux/regmap.h
 #include linux/mfd/core.h
 #include linux/mfd/retu.h
@@ -43,6 +45,7 @@ struct retu_dev {
struct device   *dev;
struct mutexmutex;
struct regmap_irq_chip_data *irq_data;
+   struct notifier_block   poweroff_nb;
 };
 
 static struct resource retu_pwrbutton_res[] = {
@@ -81,9 +84,6 @@ static struct regmap_irq_chip retu_irq_chip = {
.ack_base   = RETU_REG_IDR,
 };
 
-/* Retu device registered for the power off. */
-static struct retu_dev *retu_pm_power_off;
-
 static struct resource tahvo_usb_res[] = {
{
.name   = tahvo-usb,
@@ -165,12 +165,14 @@ int retu_write(struct retu_dev *rdev, u8 reg, u16 data)
 }
 EXPORT_SYMBOL_GPL(retu_write);
 
-static void retu_power_off(void)
+static int retu_power_off(struct notifier_block *this, unsigned long unused1,
+ void *unused2)
 {
-   struct retu_dev *rdev = retu_pm_power_off;
+   struct retu_dev *rdev = container_of(this, struct retu_dev,
+poweroff_nb);
int reg;
 
-   mutex_lock(retu_pm_power_off-mutex);
+   mutex_lock(rdev-mutex);
 
/* Ignore power button state */
regmap_read(rdev-regmap, RETU_REG_CC1, reg);
@@ -183,7 +185,9 @@ static void retu_power_off(void)
for (;;)
cpu_relax();
 
-   mutex_unlock(retu_pm_power_off-mutex);
+   mutex_unlock(rdev-mutex);
+
+   return NOTIFY_DONE;
 }
 
 static int retu_regmap_read(void *context, const void *reg, size_t reg_size,
@@ -279,9 +283,13 @@ static int retu_probe(struct i2c_client *i2c, const struct 
i2c_device_id *id)
return ret;
}
 
-   if (i2c-addr == 1  !pm_power_off) {
-   retu_pm_power_off = rdev;
-   pm_power_off  = retu_power_off;
+   if (i2c-addr == 1) {
+   rdev-poweroff_nb.notifier_call = retu_power_off;
+   rdev-poweroff_nb.priority = 64;
+   ret = register_poweroff_handler(rdev-poweroff_nb);
+   if (ret)
+   dev_err(rdev-dev,
+   Failed to register poweroff handler\n);
}
 
return 0;
@@ -291,10 +299,7 @@ static int retu_remove(struct i2c_client *i2c)
 {
struct retu_dev *rdev = i2c_get_clientdata(i2c);
 
-   if (retu_pm_power_off == rdev) {
-   pm_power_off  = NULL;
-   retu_pm_power_off = NULL;
-   }
+   unregister_poweroff_handler(rdev-poweroff_nb);
mfd_remove_devices(rdev-dev);
regmap_del_irq_chip(i2c-irq, rdev-irq_data);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 19/44] ipmi: Register with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly. Register with a high priority value of 192 to reflect that
the original code overwrites pm_power_off unconditionally.

Register poweroff handler after the ipmi system is ready, and unregister
it prior to cleanup. This avoids having to check for the ready variable
in the poweroff callback.

Cc: Corey Minyard miny...@acm.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/char/ipmi/ipmi_poweroff.c | 30 +++---
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_poweroff.c 
b/drivers/char/ipmi/ipmi_poweroff.c
index 9f2e3be..a942a41 100644
--- a/drivers/char/ipmi/ipmi_poweroff.c
+++ b/drivers/char/ipmi/ipmi_poweroff.c
@@ -36,6 +36,7 @@
 #include linux/proc_fs.h
 #include linux/string.h
 #include linux/completion.h
+#include linux/notifier.h
 #include linux/pm.h
 #include linux/kdev_t.h
 #include linux/ipmi.h
@@ -63,9 +64,6 @@ static ipmi_user_t ipmi_user;
 static int ipmi_ifnum;
 static void (*specific_poweroff_func)(ipmi_user_t user);
 
-/* Holds the old poweroff function so we can restore it on removal. */
-static void (*old_poweroff_func)(void);
-
 static int set_param_ifnum(const char *val, struct kernel_param *kp)
 {
int rv = param_set_int(val, kp);
@@ -544,15 +542,20 @@ static struct poweroff_function poweroff_functions[] = {
 
 
 /* Called on a powerdown request. */
-static void ipmi_poweroff_function(void)
+static int ipmi_poweroff_function(struct notifier_block *this,
+ unsigned long unused1, void *unused2)
 {
-   if (!ready)
-   return;
-
/* Use run-to-completion mode, since interrupts may be off. */
specific_poweroff_func(ipmi_user);
+
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block ipmi_poweroff_nb = {
+   .notifier_call = ipmi_poweroff_function,
+   .priority = 192,
+};
+
 /* Wait for an IPMI interface to be installed, the first one installed
will be grabbed by this code and used to perform the powerdown. */
 static void ipmi_po_new_smi(int if_num, struct device *device)
@@ -631,9 +634,12 @@ static void ipmi_po_new_smi(int if_num, struct device 
*device)
printk(KERN_INFO PFX Found a %s style poweroff function\n,
   poweroff_functions[i].platform_type);
specific_poweroff_func = poweroff_functions[i].poweroff_func;
-   old_poweroff_func = pm_power_off;
-   pm_power_off = ipmi_poweroff_function;
+
ready = 1;
+
+   rv = register_poweroff_handler(ipmi_poweroff_nb);
+   if (rv)
+   pr_err(PFX failed to register poweroff handler\n);
 }
 
 static void ipmi_po_smi_gone(int if_num)
@@ -644,9 +650,10 @@ static void ipmi_po_smi_gone(int if_num)
if (ipmi_ifnum != if_num)
return;
 
+   unregister_poweroff_handler(ipmi_poweroff_nb);
+
ready = 0;
ipmi_destroy_user(ipmi_user);
-   pm_power_off = old_poweroff_func;
 }
 
 static struct ipmi_smi_watcher smi_watcher = {
@@ -732,12 +739,13 @@ static void __exit ipmi_poweroff_cleanup(void)
 
ipmi_smi_watcher_unregister(smi_watcher);
 
+   unregister_poweroff_handler(ipmi_poweroff_nb);
+
if (ready) {
rv = ipmi_destroy_user(ipmi_user);
if (rv)
printk(KERN_ERR PFX could not cleanup the IPMI
user: 0x%x\n, rv);
-   pm_power_off = old_poweroff_func;
}
 }
 module_exit(ipmi_poweroff_cleanup);
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/44] mfd: twl4030-power: Register with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly. Register with a low priority value of 64 to reflect that
the original code only sets pm_power_off if it was not already set.

Make twl4030_power_off static as it is only called from the twl4030-power
driver.

Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Lee Jones lee.jo...@linaro.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/mfd/twl4030-power.c | 25 +
 include/linux/i2c/twl.h |  1 -
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 4d3ff37..bd6b830 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -25,9 +25,10 @@
  */
 
 #include linux/module.h
-#include linux/pm.h
+#include linux/notifier.h
 #include linux/i2c/twl.h
 #include linux/platform_device.h
+#include linux/pm.h
 #include linux/of.h
 #include linux/of_device.h
 
@@ -611,7 +612,8 @@ twl4030_power_configure_resources(const struct 
twl4030_power_data *pdata)
  * After a successful execution, TWL shuts down the power to the SoC
  * and all peripherals connected to it.
  */
-void twl4030_power_off(void)
+static int twl4030_power_off(struct notifier_block *this, unsigned long 
unused1,
+void *unused2)
 {
int err;
 
@@ -619,8 +621,15 @@ void twl4030_power_off(void)
   TWL4030_PM_MASTER_P1_SW_EVENTS);
if (err)
pr_err(TWL4030 Unable to power off\n);
+
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block twl4030_poweroff_nb = {
+   .notifier_call = twl4030_power_off,
+   .priority = 64,
+};
+
 static bool twl4030_power_use_poweroff(const struct twl4030_power_data *pdata,
struct device_node *node)
 {
@@ -836,7 +845,7 @@ static int twl4030_power_probe(struct platform_device *pdev)
}
 
/* Board has to be wired properly to use this feature */
-   if (twl4030_power_use_poweroff(pdata, node)  !pm_power_off) {
+   if (twl4030_power_use_poweroff(pdata, node)) {
/* Default for SEQ_OFFSYNC is set, lets ensure this */
err = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, val,
  TWL4030_PM_MASTER_CFG_P123_TRANSITION);
@@ -853,7 +862,13 @@ static int twl4030_power_probe(struct platform_device 
*pdev)
}
}
 
-   pm_power_off = twl4030_power_off;
+   err = register_poweroff_handler(twl4030_poweroff_nb);
+   if (err) {
+   dev_err(pdev-dev,
+   Failed to register poweroff handler\n);
+   /* Not a fatal error */
+   err = 0;
+   }
}
 
 relock:
@@ -869,6 +884,8 @@ relock:
 
 static int twl4030_power_remove(struct platform_device *pdev)
 {
+   unregister_poweroff_handler(twl4030_poweroff_nb);
+
return 0;
 }
 
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 8cfb50f..f8544f1 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -680,7 +680,6 @@ struct twl4030_power_data {
 };
 
 extern int twl4030_remove_script(u8 flags);
-extern void twl4030_power_off(void);
 
 struct twl4030_codec_data {
unsigned int digimic_delay; /* in ms */
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 31/44] arm: Register with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly. Always use register_poweroff_handler_simple as there is no
indication that more than one poweroff handler is registered.

If the poweroff handler only resets the system or puts the CPU in sleep mode,
select a priority of 0 to indicate that the poweroff handler is one of last
resort. If the poweroff handler powers off the system, select a priority
of 128.

Cc: Russell King li...@arm.linux.org.uk
Cc: Andrew Victor li...@maxim.org.za
Cc: Nicolas Ferre nicolas.fe...@atmel.com
Cc: Jean-Christophe Plagniol-Villard plagn...@jcrosoft.com
Cc: Stephen Warren swar...@wwwdotorg.org
Cc: Christian Daudt b...@fixthebug.org
Cc: Matt Porter mpor...@linaro.org
Cc: Anton Vorontsov an...@enomsg.org
Cc: Rob Herring r...@kernel.org
Cc: Shawn Guo shawn@freescale.com
Cc: Sascha Hauer ker...@pengutronix.de
Cc: Imre Kaloz ka...@openwrt.org
Cc: Krzysztof Halasa k...@pm.waw.pl
Cc: Tony Lindgren t...@atomide.com
Cc: Jason Cooper ja...@lakedaemon.net
Cc: Andrew Lunn and...@lunn.ch
Cc: Sebastian Hesselbarth sebastian.hesselba...@gmail.com
Cc: Eric Miao eric.y.m...@gmail.com
Cc: Haojian Zhuang haojian.zhu...@gmail.com
Cc: Robert Jarzmik robert.jarz...@free.fr
Cc: Marek Vasut marek.va...@gmail.com
Cc: Ben Dooks ben-li...@fluff.org
Cc: Kukjin Kim kgene@samsung.com
Cc: Linus Walleij linus.wall...@linaro.org
Cc: Tony Prisk li...@prisktech.co.nz
Cc: Stefano Stabellini stefano.stabell...@eu.citrix.com
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 arch/arm/kernel/psci.c | 2 +-
 arch/arm/mach-at91/board-gsia18s.c | 2 +-
 arch/arm/mach-at91/setup.c | 4 ++--
 arch/arm/mach-bcm/board_bcm2835.c  | 2 +-
 arch/arm/mach-cns3xxx/cns3420vb.c  | 2 +-
 arch/arm/mach-cns3xxx/core.c   | 2 +-
 arch/arm/mach-highbank/highbank.c  | 2 +-
 arch/arm/mach-imx/mach-mx31moboard.c   | 2 +-
 arch/arm/mach-iop32x/em7210.c  | 2 +-
 arch/arm/mach-iop32x/glantank.c| 2 +-
 arch/arm/mach-iop32x/iq31244.c | 2 +-
 arch/arm/mach-iop32x/n2100.c   | 2 +-
 arch/arm/mach-ixp4xx/dsmg600-setup.c   | 2 +-
 arch/arm/mach-ixp4xx/nas100d-setup.c   | 2 +-
 arch/arm/mach-ixp4xx/nslu2-setup.c | 2 +-
 arch/arm/mach-omap2/board-omap3touchbook.c | 2 +-
 arch/arm/mach-orion5x/board-mss2.c | 2 +-
 arch/arm/mach-orion5x/dns323-setup.c   | 6 +++---
 arch/arm/mach-orion5x/kurobox_pro-setup.c  | 2 +-
 arch/arm/mach-orion5x/ls-chl-setup.c   | 2 +-
 arch/arm/mach-orion5x/ls_hgl-setup.c   | 2 +-
 arch/arm/mach-orion5x/lsmini-setup.c   | 2 +-
 arch/arm/mach-orion5x/mv2120-setup.c   | 2 +-
 arch/arm/mach-orion5x/net2big-setup.c  | 2 +-
 arch/arm/mach-orion5x/terastation_pro2-setup.c | 2 +-
 arch/arm/mach-orion5x/ts209-setup.c| 2 +-
 arch/arm/mach-orion5x/ts409-setup.c| 2 +-
 arch/arm/mach-pxa/corgi.c  | 2 +-
 arch/arm/mach-pxa/mioa701.c| 2 +-
 arch/arm/mach-pxa/poodle.c | 2 +-
 arch/arm/mach-pxa/spitz.c  | 2 +-
 arch/arm/mach-pxa/tosa.c   | 2 +-
 arch/arm/mach-pxa/viper.c  | 2 +-
 arch/arm/mach-pxa/z2.c | 6 +++---
 arch/arm/mach-pxa/zeus.c   | 6 +++---
 arch/arm/mach-s3c24xx/mach-gta02.c | 2 +-
 arch/arm/mach-s3c24xx/mach-jive.c  | 2 +-
 arch/arm/mach-s3c24xx/mach-vr1000.c| 2 +-
 arch/arm/mach-s3c64xx/mach-smartq.c| 2 +-
 arch/arm/mach-sa1100/generic.c | 2 +-
 arch/arm/mach-sa1100/simpad.c  | 2 +-
 arch/arm/mach-u300/regulator.c | 2 +-
 arch/arm/mach-vt8500/vt8500.c  | 2 +-
 arch/arm/xen/enlighten.c   | 2 +-
 44 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
index f73891b..dd58d86 100644
--- a/arch/arm/kernel/psci.c
+++ b/arch/arm/kernel/psci.c
@@ -264,7 +264,7 @@ static int psci_0_2_init(struct device_node *np)
 
arm_pm_restart = psci_sys_reset;
 
-   pm_power_off = psci_sys_poweroff;
+   register_poweroff_handler_simple(psci_sys_poweroff, 128);
 
 out_put_node:
of_node_put(np);
diff --git a/arch/arm/mach-at91/board-gsia18s.c 
b/arch/arm/mach-at91/board-gsia18s.c
index b729dd1..6722e66 100644
--- a/arch/arm/mach-at91/board-gsia18s.c
+++ b/arch/arm/mach-at91/board-gsia18s.c
@@ -521,7 +521,7 @@ static void gsia18s_power_off(void)
 
 static int __init gsia18s_power_off_init(void)
 {
-   pm_power_off = gsia18s_power_off;
+   register_poweroff_handler_simple(gsia18s_power_off, 128);
return 0;
 }
 
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index f7a07a5..9989e88 100644
--- a/arch/arm/mach-at91/setup.c

[PATCH 13/44] mfd: max8907: Register with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly. Register with a low priority value of 64 to reflect that
the original code only sets pm_power_off if it was not already set.

Note that this patch fixes a problem on driver unload as side effect:
The old code did not restore or clean up pm_power_off on remove,
meaning the pointer was left in an undefined state.

Cc: Lee Jones lee.jo...@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/mfd/max8907.c   | 24 ++--
 include/linux/mfd/max8907.h |  2 ++
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/max8907.c b/drivers/mfd/max8907.c
index 232749c..b8cddc1 100644
--- a/drivers/mfd/max8907.c
+++ b/drivers/mfd/max8907.c
@@ -19,6 +19,7 @@
 #include linux/module.h
 #include linux/of.h
 #include linux/of_device.h
+#include linux/pm.h
 #include linux/regmap.h
 #include linux/slab.h
 
@@ -177,11 +178,16 @@ static const struct regmap_irq_chip max8907_rtc_irq_chip 
= {
.num_irqs = ARRAY_SIZE(max8907_rtc_irqs),
 };
 
-static struct max8907 *max8907_pm_off;
-static void max8907_power_off(void)
+static int max8907_power_off(struct notifier_block *this, unsigned long 
unused1,
+void *unused2)
 {
-   regmap_update_bits(max8907_pm_off-regmap_gen, MAX8907_REG_RESET_CNFG,
+   struct max8907 *max8907 = container_of(this, struct max8907,
+  poweroff_nb);
+
+   regmap_update_bits(max8907-regmap_gen, MAX8907_REG_RESET_CNFG,
MAX8907_MASK_POWER_OFF, MAX8907_MASK_POWER_OFF);
+
+   return NOTIFY_DONE;
 }
 
 static int max8907_i2c_probe(struct i2c_client *i2c,
@@ -267,9 +273,13 @@ static int max8907_i2c_probe(struct i2c_client *i2c,
goto err_add_devices;
}
 
-   if (pm_off  !pm_power_off) {
-   max8907_pm_off = max8907;
-   pm_power_off = max8907_power_off;
+   if (pm_off) {
+   max8907-poweroff_nb.notifier_call = max8907_power_off;
+   max8907-poweroff_nb.priority = 64;
+   ret = register_poweroff_handler(max8907-poweroff_nb);
+   if (ret)
+   dev_err(i2c-dev,
+   Failed to register poweroff handler);
}
 
return 0;
@@ -293,6 +303,8 @@ static int max8907_i2c_remove(struct i2c_client *i2c)
 {
struct max8907 *max8907 = i2c_get_clientdata(i2c);
 
+   unregister_poweroff_handler(max8907-poweroff_nb);
+
mfd_remove_devices(max8907-dev);
 
regmap_del_irq_chip(max8907-i2c_gen-irq, max8907-irqc_rtc);
diff --git a/include/linux/mfd/max8907.h b/include/linux/mfd/max8907.h
index b06f7a6..016428e 100644
--- a/include/linux/mfd/max8907.h
+++ b/include/linux/mfd/max8907.h
@@ -13,6 +13,7 @@
 #define __LINUX_MFD_MAX8907_H
 
 #include linux/mutex.h
+#include linux/notifier.h
 #include linux/pm.h
 
 #define MAX8907_GEN_I2C_ADDR   (0x78  1)
@@ -247,6 +248,7 @@ struct max8907 {
struct regmap_irq_chip_data *irqc_chg;
struct regmap_irq_chip_data *irqc_on_off;
struct regmap_irq_chip_data *irqc_rtc;
+   struct notifier_block   poweroff_nb;
 };
 
 #endif
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 41/44] x86: pmc_atom: Register poweroff handler with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly. Register with a low priority value of 64 to reflect that
the original code only sets pm_power_off if it was not already set.

Cc: Thomas Gleixner t...@linutronix.de
Cc: Ingo Molnar mi...@redhat.com
Cc: H. Peter Anvin h...@zytor.com
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 arch/x86/kernel/pmc_atom.c | 20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/pmc_atom.c b/arch/x86/kernel/pmc_atom.c
index 0c424a6..79331a2 100644
--- a/arch/x86/kernel/pmc_atom.c
+++ b/arch/x86/kernel/pmc_atom.c
@@ -20,6 +20,8 @@
 #include linux/pci.h
 #include linux/device.h
 #include linux/debugfs.h
+#include linux/notifier.h
+#include linux/pm.h
 #include linux/seq_file.h
 #include linux/io.h
 
@@ -92,7 +94,8 @@ static inline void pmc_reg_write(struct pmc_dev *pmc, int 
reg_offset, u32 val)
writel(val, pmc-regmap + reg_offset);
 }
 
-static void pmc_power_off(void)
+static int pmc_power_off(struct notifier_block *this, unsigned long unused1,
+void *unused2)
 {
u16 pm1_cnt_port;
u32 pm1_cnt_value;
@@ -107,8 +110,15 @@ static void pmc_power_off(void)
pm1_cnt_value |= SLEEP_ENABLE;
 
outl(pm1_cnt_value, pm1_cnt_port);
+
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block pmc_poweroff_nb = {
+   .notifier_call = pmc_power_off,
+   .priority = 64,
+};
+
 static void pmc_hw_reg_setup(struct pmc_dev *pmc)
 {
/*
@@ -247,8 +257,12 @@ static int pmc_setup_dev(struct pci_dev *pdev)
acpi_base_addr = ACPI_BASE_ADDR_MASK;
 
/* Install power off function */
-   if (acpi_base_addr != 0  pm_power_off == NULL)
-   pm_power_off = pmc_power_off;
+   if (acpi_base_addr != 0) {
+   ret = register_poweroff_handler(pmc_poweroff_nb);
+   if (ret)
+   dev_err(pdev-dev,
+   Failed to install poweroff handler\n);
+   }
 
pci_read_config_dword(pdev, PMC_BASE_ADDR_OFFSET, pmc-base_addr);
pmc-base_addr = PMC_BASE_ADDR_MASK;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/44] mfd: tps65910: Register with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly. Register with a low priority value of 64 to reflect that
the original code only sets pm_power_off if it was not already set.

Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Lee Jones lee.jo...@linaro.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/mfd/tps65910.c   | 27 ++-
 include/linux/mfd/tps65910.h |  3 +++
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
index f243e75..0b114d3 100644
--- a/drivers/mfd/tps65910.c
+++ b/drivers/mfd/tps65910.c
@@ -23,6 +23,8 @@
 #include linux/irq.h
 #include linux/irqdomain.h
 #include linux/mfd/core.h
+#include linux/notifier.h
+#include linux/pm.h
 #include linux/regmap.h
 #include linux/mfd/tps65910.h
 #include linux/of.h
@@ -437,19 +439,20 @@ struct tps65910_board *tps65910_parse_dt(struct 
i2c_client *client,
 }
 #endif
 
-static struct i2c_client *tps65910_i2c_client;
-static void tps65910_power_off(void)
+static int tps65910_power_off(struct notifier_block *this,
+ unsigned long unused1, void *unused2)
 {
-   struct tps65910 *tps65910;
-
-   tps65910 = dev_get_drvdata(tps65910_i2c_client-dev);
+   struct tps65910 *tps65910 = container_of(this, struct tps65910,
+poweroff_nb);
 
if (tps65910_reg_set_bits(tps65910, TPS65910_DEVCTRL,
DEVCTRL_PWR_OFF_MASK)  0)
-   return;
+   return NOTIFY_DONE;
 
tps65910_reg_clear_bits(tps65910, TPS65910_DEVCTRL,
DEVCTRL_DEV_ON_MASK);
+
+   return NOTIFY_DONE;
 }
 
 static int tps65910_i2c_probe(struct i2c_client *i2c,
@@ -500,9 +503,13 @@ static int tps65910_i2c_probe(struct i2c_client *i2c,
tps65910_ck32k_init(tps65910, pmic_plat_data);
tps65910_sleepinit(tps65910, pmic_plat_data);
 
-   if (pmic_plat_data-pm_off  !pm_power_off) {
-   tps65910_i2c_client = i2c;
-   pm_power_off = tps65910_power_off;
+   if (pmic_plat_data-pm_off) {
+   tps65910-poweroff_nb.notifier_call = tps65910_power_off;
+   tps65910-poweroff_nb.priority = 64;
+   ret = register_poweroff_handler(tps65910-poweroff_nb);
+   if (ret)
+   dev_err(i2c-dev,
+   failed to register poweroff handler\n);
}
 
ret = mfd_add_devices(tps65910-dev, -1,
@@ -522,6 +529,8 @@ static int tps65910_i2c_remove(struct i2c_client *i2c)
 {
struct tps65910 *tps65910 = i2c_get_clientdata(i2c);
 
+   unregister_poweroff_handler(tps65910-poweroff_nb);
+
tps65910_irq_exit(tps65910);
mfd_remove_devices(tps65910-dev);
 
diff --git a/include/linux/mfd/tps65910.h b/include/linux/mfd/tps65910.h
index 6483a6f..65cae2c 100644
--- a/include/linux/mfd/tps65910.h
+++ b/include/linux/mfd/tps65910.h
@@ -905,6 +905,9 @@ struct tps65910 {
/* IRQ Handling */
int chip_irq;
struct regmap_irq_chip_data *irq_data;
+
+   /* Poweroff handling */
+   struct notifier_block poweroff_nb;
 };
 
 struct tps65910_platform_data {
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/44] mfd: ab8500-sysctrl: Register with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly. Register with a low priority value of 64 to reflect that
the original code only sets pm_power_off if it was not already set.

Cc: Linus Walleij linus.wall...@linaro.org
Cc: Lee Jones lee.jo...@linaro.org
Cc: Samuel Ortiz sa...@linux.intel.com
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/mfd/ab8500-sysctrl.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
index 8e0dae5..677438f 100644
--- a/drivers/mfd/ab8500-sysctrl.c
+++ b/drivers/mfd/ab8500-sysctrl.c
@@ -6,6 +6,7 @@
 
 #include linux/err.h
 #include linux/module.h
+#include linux/notifier.h
 #include linux/platform_device.h
 #include linux/pm.h
 #include linux/reboot.h
@@ -23,7 +24,8 @@
 
 static struct device *sysctrl_dev;
 
-static void ab8500_power_off(void)
+static int ab8500_power_off(struct notifier_block *this, unsigned long unused1,
+   void *unused2)
 {
sigset_t old;
sigset_t all;
@@ -34,11 +36,6 @@ static void ab8500_power_off(void)
struct power_supply *psy;
int ret;
 
-   if (sysctrl_dev == NULL) {
-   pr_err(%s: sysctrl not initialized\n, __func__);
-   return;
-   }
-
/*
 * If we have a charger connected and we're powering off,
 * reboot into charge-only mode.
@@ -83,8 +80,15 @@ shutdown:
 AB8500_STW4500CTRL1_SWRESET4500N);
(void)sigprocmask(SIG_SETMASK, old, NULL);
}
+
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block ab8500_poweroff_nb = {
+   .notifier_call = ab8500_power_off,
+   .priority = 64,
+};
+
 /*
  * Use the AB WD to reset the platform. It will perform a hard
  * reset instead of a soft reset. Write the reset reason to
@@ -185,6 +189,7 @@ static int ab8500_sysctrl_probe(struct platform_device 
*pdev)
struct ab8500 *ab8500 = dev_get_drvdata(pdev-dev.parent);
struct ab8500_platform_data *plat;
struct ab8500_sysctrl_platform_data *pdata;
+   int err;
 
plat = dev_get_platdata(pdev-dev.parent);
 
@@ -193,8 +198,9 @@ static int ab8500_sysctrl_probe(struct platform_device 
*pdev)
 
sysctrl_dev = pdev-dev;
 
-   if (!pm_power_off)
-   pm_power_off = ab8500_power_off;
+   err = register_poweroff_handler(ab8500_poweroff_nb);
+   if (err)
+   dev_err(pdev-dev, Failed to register poweroff handler\n);
 
pdata = plat-sysctrl;
if (pdata) {
@@ -226,11 +232,9 @@ static int ab8500_sysctrl_probe(struct platform_device 
*pdev)
 
 static int ab8500_sysctrl_remove(struct platform_device *pdev)
 {
+   unregister_poweroff_handler(ab8500_poweroff_nb);
sysctrl_dev = NULL;
 
-   if (pm_power_off == ab8500_power_off)
-   pm_power_off = NULL;
-
return 0;
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 35/44] m68k: Register with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly.

Cc: Geert Uytterhoeven ge...@linux-m68k.org
Cc: Joshua Thompson fun...@jurai.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 arch/m68k/emu/natfeat.c | 2 +-
 arch/m68k/mac/config.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/m68k/emu/natfeat.c b/arch/m68k/emu/natfeat.c
index 91e2ae7..c4d5bd8 100644
--- a/arch/m68k/emu/natfeat.c
+++ b/arch/m68k/emu/natfeat.c
@@ -91,5 +91,5 @@ void __init nf_init(void)
pr_info(NatFeats found (%s, %lu.%lu)\n, buf, version  16,
version  0x);
 
-   pm_power_off = nf_poweroff;
+   register_poweroff_handler_simple(nf_poweroff, 128);
 }
diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index 677913ff..5d8e2e6 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -160,7 +160,7 @@ void __init config_mac(void)
mach_set_clock_mmss = mac_set_clock_mmss;
mach_reset = mac_reset;
mach_halt = mac_poweroff;
-   pm_power_off = mac_poweroff;
+   register_poweroff_handler_simple(mac_poweroff, 128);
mach_max_dma_address = 0x;
 #if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
mach_beep = mac_mksound;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 21/44] power/reset: gpio-poweroff: Register with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly. Register with a low priority value of 64 to reflect that
the original code only sets pm_power_off if it was not already set.

Other changes:

Drop note that there can not be an additional instance of this driver.
The original reason no longer applies, it should be obvious that there
can only be one instance of the driver if static variables are used to
reflect its state, and support for multiple instances can now be added
easily if needed by avoiding static variables.

Do not create an error message if another poweroff handler has already been
registered. This is perfectly normal and acceptable.

Do not display a warning traceback if the poweroff handler fails to
power off the system. There may be other poweroff handlers.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/power/reset/gpio-poweroff.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/power/reset/gpio-poweroff.c 
b/drivers/power/reset/gpio-poweroff.c
index ce849bc..e95a7a1 100644
--- a/drivers/power/reset/gpio-poweroff.c
+++ b/drivers/power/reset/gpio-poweroff.c
@@ -14,18 +14,18 @@
 #include linux/kernel.h
 #include linux/init.h
 #include linux/delay.h
+#include linux/notifier.h
+#include linux/pm.h
 #include linux/platform_device.h
 #include linux/gpio/consumer.h
 #include linux/of_platform.h
 #include linux/module.h
 
-/*
- * Hold configuration here, cannot be more than one instance of the driver
- * since pm_power_off itself is global.
- */
 static struct gpio_desc *reset_gpio;
 
-static void gpio_poweroff_do_poweroff(void)
+static int gpio_poweroff_do_poweroff(struct notifier_block *this,
+unsigned long unused1, void *unused2)
+
 {
BUG_ON(!reset_gpio);
 
@@ -42,20 +42,18 @@ static void gpio_poweroff_do_poweroff(void)
/* give it some time */
mdelay(3000);
 
-   WARN_ON(1);
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block gpio_poweroff_nb = {
+   .notifier_call = gpio_poweroff_do_poweroff,
+   .priority = 64,
+};
+
 static int gpio_poweroff_probe(struct platform_device *pdev)
 {
bool input = false;
-
-   /* If a pm_power_off function has already been added, leave it alone */
-   if (pm_power_off != NULL) {
-   dev_err(pdev-dev,
-   %s: pm_power_off function already registered,
-  __func__);
-   return -EBUSY;
-   }
+   int err;
 
reset_gpio = devm_gpiod_get(pdev-dev, NULL);
if (IS_ERR(reset_gpio))
@@ -77,14 +75,16 @@ static int gpio_poweroff_probe(struct platform_device *pdev)
}
}
 
-   pm_power_off = gpio_poweroff_do_poweroff;
-   return 0;
+   err = register_poweroff_handler(gpio_poweroff_nb);
+   if (err)
+   dev_err(pdev-dev, Failed to register poweroff handler\n);
+
+   return err;
 }
 
 static int gpio_poweroff_remove(struct platform_device *pdev)
 {
-   if (pm_power_off == gpio_poweroff_do_poweroff)
-   pm_power_off = NULL;
+   unregister_poweroff_handler(gpio_poweroff_nb);
 
return 0;
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 42/44] efi: Register poweroff handler with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly. Register with low priority value of 64 since the efi code
states that this is a poweroff handler of last resort.

Cc: Matt Fleming matt.flem...@intel.com
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/firmware/efi/reboot.c | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/efi/reboot.c b/drivers/firmware/efi/reboot.c
index 9c59d1c..c082439 100644
--- a/drivers/firmware/efi/reboot.c
+++ b/drivers/firmware/efi/reboot.c
@@ -3,6 +3,8 @@
  * Copyright (c) 2014 Red Hat, Inc., Mark Salter msal...@redhat.com
  */
 #include linux/efi.h
+#include linux/notifier.h
+#include linux/pm.h
 #include linux/reboot.h
 
 int efi_reboot_quirk_mode = -1;
@@ -38,19 +40,32 @@ bool __weak efi_poweroff_required(void)
return false;
 }
 
-static void efi_power_off(void)
+static int efi_power_off(struct notifier_block *this,
+unsigned long unused1, void *unused2)
 {
efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);
+
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block efi_poweroff_nb = {
+   .notifier_call = efi_power_off,
+   .priority = 64,
+};
+
 static int __init efi_shutdown_init(void)
 {
+   int ret = 0;
+
if (!efi_enabled(EFI_RUNTIME_SERVICES))
return -ENODEV;
 
-   if (efi_poweroff_required())
-   pm_power_off = efi_power_off;
+   if (efi_poweroff_required()) {
+   ret = register_poweroff_handler(efi_poweroff_nb);
+   if (ret)
+   pr_err(efi: Failed to register poweroff handler\n);
+   }
 
-   return 0;
+   return ret;
 }
 late_initcall(efi_shutdown_init);
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 40/44] x86: intel-mid: Drop registration of dummy poweroff handlers

2014-10-06 Thread Guenter Roeck
A dummy poweroff handler does not serve any purpose. Drop it.

Cc: Thomas Gleixner t...@linutronix.de
Cc: Ingo Molnar mi...@redhat.com
Cc: H. Peter Anvin h...@zytor.com
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 arch/x86/platform/intel-mid/intel-mid.c | 5 -
 arch/x86/platform/intel-mid/mfld.c  | 5 -
 2 files changed, 10 deletions(-)

diff --git a/arch/x86/platform/intel-mid/intel-mid.c 
b/arch/x86/platform/intel-mid/intel-mid.c
index 1bbedc4..4b70666 100644
--- a/arch/x86/platform/intel-mid/intel-mid.c
+++ b/arch/x86/platform/intel-mid/intel-mid.c
@@ -67,10 +67,6 @@ static void *(*get_intel_mid_ops[])(void) = 
INTEL_MID_OPS_INIT;
 enum intel_mid_cpu_type __intel_mid_cpu_chip;
 EXPORT_SYMBOL_GPL(__intel_mid_cpu_chip);
 
-static void intel_mid_power_off(void)
-{
-};
-
 static void intel_mid_reboot(void)
 {
intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
@@ -183,7 +179,6 @@ void __init x86_intel_mid_early_setup(void)
 
legacy_pic = null_legacy_pic;
 
-   pm_power_off = intel_mid_power_off;
machine_ops.emergency_restart  = intel_mid_reboot;
 
/* Avoid searching for BIOS MP tables */
diff --git a/arch/x86/platform/intel-mid/mfld.c 
b/arch/x86/platform/intel-mid/mfld.c
index 23381d2..cf6842f 100644
--- a/arch/x86/platform/intel-mid/mfld.c
+++ b/arch/x86/platform/intel-mid/mfld.c
@@ -23,10 +23,6 @@ static struct intel_mid_ops penwell_ops = {
.arch_setup = penwell_arch_setup,
 };
 
-static void mfld_power_off(void)
-{
-}
-
 static unsigned long __init mfld_calibrate_tsc(void)
 {
unsigned long fast_calibrate;
@@ -61,7 +57,6 @@ static unsigned long __init mfld_calibrate_tsc(void)
 static void __init penwell_arch_setup(void)
 {
x86_platform.calibrate_tsc = mfld_calibrate_tsc;
-   pm_power_off = mfld_power_off;
 }
 
 void *get_penwell_ops(void)
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 25/44] power/reset: vexpress-poweroff: Register with kernel poweroff handler

2014-10-06 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly.

Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/power/reset/vexpress-poweroff.c | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/power/reset/vexpress-poweroff.c 
b/drivers/power/reset/vexpress-poweroff.c
index 4dc102e2..060c55d 100644
--- a/drivers/power/reset/vexpress-poweroff.c
+++ b/drivers/power/reset/vexpress-poweroff.c
@@ -12,6 +12,7 @@
  */
 
 #include linux/delay.h
+#include linux/notifier.h
 #include linux/of.h
 #include linux/of_device.h
 #include linux/platform_device.h
@@ -36,11 +37,19 @@ static void vexpress_reset_do(struct device *dev, const 
char *what)
 
 static struct device *vexpress_power_off_device;
 
-static void vexpress_power_off(void)
+static int vexpress_power_off(struct notifier_block *this,
+ unsigned long unused1, void *unused2)
 {
vexpress_reset_do(vexpress_power_off_device, power off);
+
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block vexpress_poweroff_nb = {
+   .notifier_call = vexpress_power_off,
+   .priority = 128,
+};
+
 static struct device *vexpress_restart_device;
 
 static void vexpress_restart(enum reboot_mode reboot_mode, const char *cmd)
@@ -92,6 +101,7 @@ static int vexpress_reset_probe(struct platform_device *pdev)
const struct of_device_id *match =
of_match_device(vexpress_reset_of_match, pdev-dev);
struct regmap *regmap;
+   int ret;
 
if (match)
func = (enum vexpress_reset_func)match-data;
@@ -106,7 +116,12 @@ static int vexpress_reset_probe(struct platform_device 
*pdev)
switch (func) {
case FUNC_SHUTDOWN:
vexpress_power_off_device = pdev-dev;
-   pm_power_off = vexpress_power_off;
+   ret = register_poweroff_handler(vexpress_poweroff_nb);
+   if (ret) {
+   dev_err(pdev-dev,
+   Failed to register poweroff handler\n);
+   return ret;
+   }
break;
case FUNC_RESET:
if (!vexpress_restart_device)
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/44] kernel: Add support for poweroff handler call chain

2014-10-06 Thread Guenter Roeck
Various drivers implement architecture and/or device specific means to
remove power from the system.  For the most part, those drivers set the
global variable pm_power_off to point to a function within the driver.

This mechanism has a number of drawbacks.  Typically only one scheme
to remove power is supported (at least if pm_power_off is used).
At least in theory there can be multiple means remove power, some of
which may be less desirable. For example, some mechanisms may only
power off the CPU or the CPU card, while another may power off the
entire system.  Others may really just execute a restart sequence
or drop into the ROM monitor. Using pm_power_off can also be racy
if the function pointer is set from a driver built as module, as the
driver may be in the process of being unloaded when pm_power_off is
called. If there are multiple poweroff handlers in the system, removing
a module with such a handler may inadvertently reset the pointer to
pm_power_off to NULL, leaving the system with no means to remove power.

Introduce a system poweroff handler call chain to solve the described
problems.  This call chain is expected to be executed from the
architecture specific machine_power_off() function.  Drivers providing
system poweroff functionality are expected to register with this call chain.
By using the priority field in the notifier block, callers can control
poweroff handler execution sequence and thus ensure that the poweroff
handler with the optimal capabilities to remove power for a given system
is called first.

Cc: Andrew Morton a...@linux-foundation.org
cc: Heiko Stuebner he...@sntech.de
Cc: Romain Perier romain.per...@gmail.com
Cc: Rafael J. Wysocki r...@rjwysocki.net
Cc: Len Brown len.br...@intel.com
Cc: Pavel Machek pa...@ucw.cz
Cc: Alexander Graf ag...@suse.de
Cc: Geert Uytterhoeven ge...@linux-m68k.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 include/linux/pm.h  |  13 +++
 kernel/power/Makefile   |   1 +
 kernel/power/poweroff_handler.c | 172 
 3 files changed, 186 insertions(+)
 create mode 100644 kernel/power/poweroff_handler.c

diff --git a/include/linux/pm.h b/include/linux/pm.h
index 72c0fe0..45271b5 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -34,6 +34,19 @@
 extern void (*pm_power_off)(void);
 extern void (*pm_power_off_prepare)(void);
 
+/*
+ * Callbacks to manage poweroff handlers
+ */
+
+struct notifier_block;
+
+extern int register_poweroff_handler(struct notifier_block *);
+extern int register_poweroff_handler_simple(void (*function)(void),
+   int priority);
+extern int unregister_poweroff_handler(struct notifier_block *);
+extern void do_kernel_poweroff(void);
+extern bool have_kernel_poweroff(void);
+
 struct device; /* we have a circular dep with device.h */
 #ifdef CONFIG_VT_CONSOLE_SLEEP
 extern void pm_vt_switch_required(struct device *dev, bool required);
diff --git a/kernel/power/Makefile b/kernel/power/Makefile
index 29472bf..4d9f0c7 100644
--- a/kernel/power/Makefile
+++ b/kernel/power/Makefile
@@ -2,6 +2,7 @@
 ccflags-$(CONFIG_PM_DEBUG) := -DDEBUG
 
 obj-y  += qos.o
+obj-y  += poweroff_handler.o
 obj-$(CONFIG_PM)   += main.o
 obj-$(CONFIG_VT_CONSOLE_SLEEP) += console.o
 obj-$(CONFIG_FREEZER)  += process.o
diff --git a/kernel/power/poweroff_handler.c b/kernel/power/poweroff_handler.c
new file mode 100644
index 000..ed99e5e
--- /dev/null
+++ b/kernel/power/poweroff_handler.c
@@ -0,0 +1,172 @@
+/*
+ * linux/kernel/power/poweroff_handler.c - Poweroff handling functions
+ *
+ * Copyright (c) 2014 Guenter Roeck
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#define pr_fmt(fmt)poweroff:  fmt
+
+#include linux/ctype.h
+#include linux/export.h
+#include linux/kallsyms.h
+#include linux/notifier.h
+#include linux/pm.h
+#include linux/slab.h
+#include linux/types.h
+
+/*
+ * Notifier list for kernel code which wants to be called
+ * to power off the system.
+ */
+static ATOMIC_NOTIFIER_HEAD(poweroff_handler_list);
+
+/**
+ * register_poweroff_handler - Register function to be called to power off
+ * the system
+ * @nb: Info about handler function to be called
+ * @nb-priority:  Handler priority. Handlers should follow the
+ * following guidelines for setting priorities.
+ * 0:  Poweroff handler of last resort,
+ * with limited poweroff capabilities,
+ * such as poweroff handlers which
+ * do not really power off the system
+ * but loop forever or stop

[RFC PATCH 12/16] unicore32: support poweroff through poweroff handler call chain

2014-09-30 Thread Guenter Roeck
The kernel core now supports a poweroff handler call chain
to remove power from the system. Call it if pm_power_off
is set to NULL.

Cc: Guan Xuetao g...@mprc.pku.edu.cn
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 arch/unicore32/kernel/process.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/unicore32/kernel/process.c b/arch/unicore32/kernel/process.c
index b008e99..421fde6 100644
--- a/arch/unicore32/kernel/process.c
+++ b/arch/unicore32/kernel/process.c
@@ -66,6 +66,8 @@ void machine_power_off(void)
 {
if (pm_power_off)
pm_power_off();
+   else
+   do_kernel_poweroff();
machine_halt();
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 15/16] power/reset: restart-poweroff: Register with kernel poweroff handler

2014-09-30 Thread Guenter Roeck
Register with kernel poweroff handler instead of seting pm_power_off
directly.  Register as poweroff handler of last resort since the driver
does not really power off the system but executes a restart.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/power/reset/restart-poweroff.c | 24 +++-
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/power/reset/restart-poweroff.c 
b/drivers/power/reset/restart-poweroff.c
index edd707e..82d058f 100644
--- a/drivers/power/reset/restart-poweroff.c
+++ b/drivers/power/reset/restart-poweroff.c
@@ -12,35 +12,33 @@
  */
 #include linux/kernel.h
 #include linux/init.h
+#include linux/notifier.h
 #include linux/platform_device.h
 #include linux/of_platform.h
 #include linux/module.h
 #include linux/reboot.h
-#include asm/system_misc.h
 
-static void restart_poweroff_do_poweroff(void)
+static int restart_poweroff_do_poweroff(struct notifier_block *this,
+   unsigned long unused1, void *unused2)
 {
reboot_mode = REBOOT_HARD;
machine_restart(NULL);
+
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block restart_poweroff_handler = {
+   .notifier_call = restart_poweroff_do_poweroff,
+};
+
 static int restart_poweroff_probe(struct platform_device *pdev)
 {
-   /* If a pm_power_off function has already been added, leave it alone */
-   if (pm_power_off != NULL) {
-   dev_err(pdev-dev,
-   pm_power_off function already registered);
-   return -EBUSY;
-   }
-
-   pm_power_off = restart_poweroff_do_poweroff;
-   return 0;
+   return register_restart_handler(restart_poweroff_handler);
 }
 
 static int restart_poweroff_remove(struct platform_device *pdev)
 {
-   if (pm_power_off == restart_poweroff_do_poweroff)
-   pm_power_off = NULL;
+   unregister_restart_handler(restart_poweroff_handler);
 
return 0;
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 16/16] mfd: palmas: Register with kernel poweroff handler

2014-09-30 Thread Guenter Roeck
Register with kernel poweroff handler instead of setting pm_power_off
directly.

Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Lee Jones lee.jo...@linaro.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 drivers/mfd/palmas.c   | 30 +-
 include/linux/mfd/palmas.h |  3 +++
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index 28cb048..e8ef345a 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -19,6 +19,7 @@
 #include linux/i2c.h
 #include linux/interrupt.h
 #include linux/irq.h
+#include linux/reboot.h
 #include linux/regmap.h
 #include linux/err.h
 #include linux/mfd/core.h
@@ -425,20 +426,18 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c,
ti,system-power-controller);
 }
 
-static struct palmas *palmas_dev;
-static void palmas_power_off(void)
+static int palmas_power_off(struct notifier_block *this, unsigned long unused1,
+   void *unused2)
 {
+   struct palmas *palmas = container_of(this, struct palmas, poweroff_nb);
unsigned int addr;
int ret, slave;
 
-   if (!palmas_dev)
-   return;
-
slave = PALMAS_BASE_TO_SLAVE(PALMAS_PMU_CONTROL_BASE);
addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE, PALMAS_DEV_CTRL);
 
ret = regmap_update_bits(
-   palmas_dev-regmap[slave],
+   palmas-regmap[slave],
addr,
PALMAS_DEV_CTRL_DEV_ON,
0);
@@ -446,6 +445,8 @@ static void palmas_power_off(void)
if (ret)
pr_err(%s: Unable to write to DEV_CTRL_DEV_ON: %d\n,
__func__, ret);
+
+   return NOTIFY_DONE;
 }
 
 static unsigned int palmas_features = PALMAS_PMIC_FEATURE_SMPS10_BOOST;
@@ -668,9 +669,15 @@ no_irq:
ret = of_platform_populate(node, NULL, NULL, i2c-dev);
if (ret  0) {
goto err_irq;
-   } else if (pdata-pm_off  !pm_power_off) {
-   palmas_dev = palmas;
-   pm_power_off = palmas_power_off;
+   } else if (pdata-pm_off) {
+   palmas-poweroff_nb.notifier_call = palmas_power_off;
+   palmas-poweroff_nb.priority = 128;
+   ret = register_poweroff_handler(palmas-poweroff_nb);
+   if (ret) {
+   dev_err(palmas-dev,
+   cannot register poweroff handler);
+   ret = 0;
+   }
}
}
 
@@ -698,10 +705,7 @@ static int palmas_i2c_remove(struct i2c_client *i2c)
i2c_unregister_device(palmas-i2c_clients[i]);
}
 
-   if (palmas == palmas_dev) {
-   pm_power_off = NULL;
-   palmas_dev = NULL;
-   }
+   unregister_poweroff_handler(palmas-poweroff_nb);
 
return 0;
 }
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index fb0390a..4715057 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -18,6 +18,7 @@
 
 #include linux/usb/otg.h
 #include linux/leds.h
+#include linux/notifier.h
 #include linux/regmap.h
 #include linux/regulator/driver.h
 #include linux/extcon.h
@@ -68,6 +69,8 @@ struct palmas {
struct i2c_client *i2c_clients[PALMAS_NUM_CLIENTS];
struct regmap *regmap[PALMAS_NUM_CLIENTS];
 
+   struct notifier_block poweroff_nb;
+
/* Stored chip id */
int id;
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 11/16] sh: support poweroff through poweroff handler call chain

2014-09-30 Thread Guenter Roeck
The kernel core now supports a poweroff handler call chain
to remove power from the system. Call it if pm_power_off
is set to NULL.

Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 arch/sh/kernel/reboot.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/sh/kernel/reboot.c b/arch/sh/kernel/reboot.c
index 04afe5b..8e68926 100644
--- a/arch/sh/kernel/reboot.c
+++ b/arch/sh/kernel/reboot.c
@@ -53,6 +53,8 @@ static void native_machine_power_off(void)
 {
if (pm_power_off)
pm_power_off();
+   else
+   do_kernel_poweroff();
 }
 
 static void native_machine_halt(void)
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 13/16] x86: support poweroff through poweroff handler call chain

2014-09-30 Thread Guenter Roeck
The kernel core now supports a poweroff handler call chain
to remove power from the system. Call it if pm_power_off
is set to NULL.

Cc: Thomas Gleixner t...@linutronix.de
Cc: Ingo Molnar mi...@redhat.com
Cc: H. Peter Anvin h...@zytor.com
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 arch/x86/kernel/reboot.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 17962e6..c5514aa 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -651,6 +651,10 @@ static void native_machine_power_off(void)
if (!reboot_force)
machine_shutdown();
pm_power_off();
+   } else {
+   if (!reboot_force)
+   machine_shutdown();
+   do_kernel_poweroff();
}
/* A fallback in case there is no PM info available */
tboot_shutdown(TB_SHUTDOWN_HALT);
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 09/16] metag: support poweroff through poweroff handler call chain

2014-09-30 Thread Guenter Roeck
The kernel core now supports a poweroff handler call chain
to remove power from the system. Call it if pm_power_off
is set to NULL.

Cc: James Hogan james.ho...@imgtec.com
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 arch/metag/kernel/process.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/metag/kernel/process.c b/arch/metag/kernel/process.c
index 483dff9..ff7f3eb 100644
--- a/arch/metag/kernel/process.c
+++ b/arch/metag/kernel/process.c
@@ -92,6 +92,8 @@ void machine_power_off(void)
 {
if (pm_power_off)
pm_power_off();
+   else
+   do_kernel_poweroff();
smp_send_stop();
hard_processor_halt(HALT_OK);
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 10/16] mips: support poweroff through poweroff handler call chain

2014-09-30 Thread Guenter Roeck
The kernel core now supports a poweroff handler call chain
to remove power from the system. Call it if pm_power_off
is set to NULL.

Cc: Ralf Baechle r...@linux-mips.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 arch/mips/kernel/reset.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/mips/kernel/reset.c b/arch/mips/kernel/reset.c
index 07fc524..c3391d7 100644
--- a/arch/mips/kernel/reset.c
+++ b/arch/mips/kernel/reset.c
@@ -41,4 +41,6 @@ void machine_power_off(void)
 {
if (pm_power_off)
pm_power_off();
+   else
+   do_kernel_poweroff();
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 07/16] c6x: support poweroff through poweroff handler call chain

2014-09-30 Thread Guenter Roeck
The kernel core now supports a poweroff handler call chain
to remove power from the system. Call it if pm_power_off
is set to NULL.

Cc: Mark Salter msal...@redhat.com
Cc: Aurelien Jacquiot a-jacqu...@ti.com
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 arch/c6x/kernel/process.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/c6x/kernel/process.c b/arch/c6x/kernel/process.c
index 57d2ea8..ddf088e 100644
--- a/arch/c6x/kernel/process.c
+++ b/arch/c6x/kernel/process.c
@@ -75,6 +75,8 @@ void machine_power_off(void)
 {
if (pm_power_off)
pm_power_off();
+   else
+   do_kernel_poweroff();
halt_loop();
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 01/16] kernel: Add support for poweroff handler call chain

2014-09-30 Thread Guenter Roeck
Various drivers implement architecture and/or device specific means to
remove power from the system.  For the most part, those drivers set the
global variable pm_power_off to point to a function within the driver.

This mechanism has a number of drawbacks.  Typically only one scheme
to remove power is supported (at least if pm_power_off is used).
At least in theory there can be multiple means remove power, some of
which may be less desirable. For example, some mechanisms may only
power off the CPU or the CPU card, while another may power off the
entire system.  Others may really just execute a restart sequence
or drop into the ROM monitor. Using pm_power_off can also be racy
if the function pointer is set from a driver built as module, as the
driver may be in the process of being unloaded when pm_power_off is
called. If there are multiple poweroff handlers in the system, removing
a module with such a handler may inadvertently reset the pointer to
pm_power_off to NULL, leaving the system with no means to remove power.

Introduce a system poweroff handler call chain to solve the described
problems.  This call chain is expected to be executed from the
architecture specific machine_power_off() function.  Drivers providing
system poweroff functionality are expected to register with this call chain.
By using the priority field in the notifier block, callers can control
poweroff handler execution sequence and thus ensure that the poweroff
handler with the optimal capabilities to remove power for a given system
is called first.

Cc: Andrew Morton a...@linux-foundation.org
cc: Heiko Stuebner he...@sntech.de
Cc: Romain Perier romain.per...@gmail.com
Cc: James E.J. Bottomley j...@parisc-linux.org
Cc: Helge Deller del...@gmx.de
Cc: Russell King li...@arm.linux.org.uk
Cc: Catalin Marinas catalin.mari...@arm.com
Cc: Will Deacon will.dea...@arm.com
Cc: Haavard Skinnemoen hskinnem...@gmail.com
Cc: Hans-Christian Egtvedt egtv...@samfundet.no
Cc: Mark Salter msal...@redhat.com
Cc: Aurelien Jacquiot a-jacqu...@ti.com
Cc: Tony Luck tony.l...@intel.com
Cc: Fenghua Yu fenghua...@intel.com
Cc: James Hogan james.ho...@imgtec.com
Cc: Ralf Baechle r...@linux-mips.org
Cc: Guan Xuetao g...@mprc.pku.edu.cn
Cc: Thomas Gleixner t...@linutronix.de
Cc: Ingo Molnar mi...@redhat.com
Cc: H. Peter Anvin h...@zytor.com
Cc: Konrad Rzeszutek Wilk konrad.w...@oracle.com
Cc: Boris Ostrovsky boris.ostrov...@oracle.com
Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Lee Jones lee.jo...@linaro.org
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 include/linux/reboot.h |  4 +++
 kernel/reboot.c| 81 ++
 2 files changed, 85 insertions(+)

diff --git a/include/linux/reboot.h b/include/linux/reboot.h
index 67fc8fc..b172951 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -38,6 +38,10 @@ extern int reboot_force;
 extern int register_reboot_notifier(struct notifier_block *);
 extern int unregister_reboot_notifier(struct notifier_block *);
 
+extern int register_poweroff_handler(struct notifier_block *);
+extern int unregister_poweroff_handler(struct notifier_block *);
+extern void do_kernel_poweroff(void);
+
 extern int register_restart_handler(struct notifier_block *);
 extern int unregister_restart_handler(struct notifier_block *);
 extern void do_kernel_restart(char *cmd);
diff --git a/kernel/reboot.c b/kernel/reboot.c
index 5925f5a..bdfab65 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -106,6 +106,87 @@ EXPORT_SYMBOL(unregister_reboot_notifier);
 
 /*
  * Notifier list for kernel code which wants to be called
+ * to power off the system.
+ */
+static ATOMIC_NOTIFIER_HEAD(poweroff_handler_list);
+
+/**
+ * register_poweroff_handler - Register function to be called to power off
+ * the system
+ * @nb: Info about handler function to be called
+ * @nb-priority:  Handler priority. Handlers should follow the
+ * following guidelines for setting priorities.
+ * 0:  Poweroff handler of last resort,
+ * with limited poweroff capabilities
+ * 128:Default poweroff handler; use if no other
+ * poweroff handler is expected to be available,
+ * and/or if poweroff functionality is
+ * sufficient to poweroff the entire system
+ * 255:Highest priority poweroff handler, will
+ * preempt all other poweroff handlers
+ *
+ * Registers a function with code to be called to poweroff the
+ * system.
+ *
+ * Registered functions will be called from machine_power_off as last
+ * step of the poweroff sequence (if the architecture specific
+ * machine_power_off function calls

[RFC PATCH 05/16] arm64: support poweroff through poweroff handler call chain

2014-09-30 Thread Guenter Roeck
The kernel core now supports a poweroff handler call chain
to remove power from the system. Call it if pm_power_off
is set to NULL.

Cc: Catalin Marinas catalin.mari...@arm.com
Cc: Will Deacon will.dea...@arm.com
Signed-off-by: Guenter Roeck li...@roeck-us.net
---
 arch/arm64/kernel/process.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 398ab05..cc0c63e 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -157,6 +157,8 @@ void machine_power_off(void)
smp_send_stop();
if (pm_power_off)
pm_power_off();
+   else
+   do_kernel_poweroff();
 }
 
 /*
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] tty/metag_da: Add console_poll module parameter

2014-09-15 Thread Guenter Roeck
On Fri, Sep 12, 2014 at 11:15:22PM +0100, James Hogan wrote:
 Currently the metag_da console channel is write only, it doesn't get
 polled for incoming data. This is for performance  latency reasons as
 polling blocks the processor for a significant amount of time waiting
 for the JTAG probe to respond to the request and restart the thread.
 This means that the console channel cannot be used for a login prompt,
 so ttyDA2 is usually used instead.
 
 In a virtual environment with a virtual DA such as QEMU however the
 polling is much cheaper as the request can be handled immediately. It is
 useful to be able to enable polling in such an environment in order to
 get both the kernel log and a usable login prompt on the same DA
 channel.
 
 Add a console_poll module parameter which allows polling to be enabled
 for the console channel. It defaults to off as that is the current
 behaviour for good reason on real hardware.
 
 It can be enabled by appending metag_da.console_poll to the kernel
 command line.
 
 Signed-off-by: James Hogan james.ho...@imgtec.com
 Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
 Cc: Jiri Slaby jsl...@suse.cz
 Cc: Guenter Roeck li...@roeck-us.net

Tested-by: Guenter Roeck li...@roeck-us.net

Thanks a lot!

Guenter
--
To unsubscribe from this list: send the line unsubscribe linux-metag in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html