ARM: Move leds idle start/stop calls to idle notifiers
authorTodd Poynor <toddpoynor@google.com>
Sat, 25 Jun 2011 02:33:01 +0000 (19:33 -0700)
committerTodd Poynor <toddpoynor@google.com>
Fri, 15 Jul 2011 22:26:45 +0000 (15:26 -0700)
Change-Id: I5d8e4e85b17bbab7992ecb477f0bdb5e4138b166
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
arch/arm/kernel/leds.c
arch/arm/kernel/process.c

index 0f107dcb034790d3be0b7405b7c235034d495868..136e8376a3eb43a05aaa8653c04805e2dc278272 100644 (file)
@@ -9,6 +9,8 @@
  */
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/notifier.h>
+#include <linux/cpu.h>
 #include <linux/sysdev.h>
 #include <linux/syscore_ops.h>
 
@@ -101,6 +103,25 @@ static struct syscore_ops leds_syscore_ops = {
        .resume         = leds_resume,
 };
 
+static int leds_idle_notifier(struct notifier_block *nb, unsigned long val,
+                                void *data)
+{
+       switch (val) {
+       case IDLE_START:
+               leds_event(led_idle_start);
+               break;
+       case IDLE_END:
+               leds_event(led_idle_end);
+               break;
+       }
+
+       return 0;
+}
+
+static struct notifier_block leds_idle_nb = {
+       .notifier_call = leds_idle_notifier,
+};
+
 static int __init leds_init(void)
 {
        int ret;
@@ -109,8 +130,12 @@ static int __init leds_init(void)
                ret = sysdev_register(&leds_device);
        if (ret == 0)
                ret = sysdev_create_file(&leds_device, &attr_event);
-       if (ret == 0)
+
+       if (ret == 0) {
                register_syscore_ops(&leds_syscore_ops);
+               idle_notifier_register(&leds_idle_nb);
+       }
+
        return ret;
 }
 
index 7dee54ae0b311ff4922d7df9c28751969c6ca66a..919de7c84f761586a8c48280fc5272e98913451f 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/hw_breakpoint.h>
 
 #include <asm/cacheflush.h>
-#include <asm/leds.h>
 #include <asm/processor.h>
 #include <asm/system.h>
 #include <asm/thread_notify.h>
@@ -183,7 +182,6 @@ void cpu_idle(void)
        /* endless idle loop with no priority at all */
        while (1) {
                tick_nohz_stop_sched_tick(1);
-               leds_event(led_idle_start);
                idle_notifier_call_chain(IDLE_START);
                while (!need_resched()) {
 #ifdef CONFIG_HOTPLUG_CPU
@@ -208,7 +206,6 @@ void cpu_idle(void)
                                local_irq_enable();
                        }
                }
-               leds_event(led_idle_end);
                idle_notifier_call_chain(IDLE_END);
                tick_nohz_restart_sched_tick();
                preempt_enable_no_resched();