aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Moll <pawel.moll@arm.com>2014-01-22 11:32:02 -0500
committerBryan Wu <cooloney@gmail.com>2014-02-27 12:56:54 -0500
commitfba14ae8e924881038406ecff031d2d17becc2cb (patch)
tree86a5548effb8fab412e9940d92cfccb7e2a14927
parentcfbf8d4857c26a8a307fb7cd258074c9dcd8c691 (diff)
ledtrig-cpu: Handle CPU hot(un)plugging
When CPU is hot(un)plugged, no syscore notification is being generated, nor is cpuidle involved. This leaves the CPU LED turned on, because the dying thread is doing some work (LED on) and than it is... well, dying (LED still on :-) Added notifier block for hot(un)plugging operations, generating existing trigger events. Signed-off-by: Pawel Moll <pawel.moll@arm.com> Signed-off-by: Bryan Wu <cooloney@gmail.com>
-rw-r--r--drivers/leds/trigger/ledtrig-cpu.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/leds/trigger/ledtrig-cpu.c b/drivers/leds/trigger/ledtrig-cpu.c
index 118335eccc56..1c3ee9fcaf34 100644
--- a/drivers/leds/trigger/ledtrig-cpu.c
+++ b/drivers/leds/trigger/ledtrig-cpu.c
@@ -26,6 +26,7 @@
26#include <linux/percpu.h> 26#include <linux/percpu.h>
27#include <linux/syscore_ops.h> 27#include <linux/syscore_ops.h>
28#include <linux/rwsem.h> 28#include <linux/rwsem.h>
29#include <linux/cpu.h>
29#include "../leds.h" 30#include "../leds.h"
30 31
31#define MAX_NAME_LEN 8 32#define MAX_NAME_LEN 8
@@ -92,6 +93,26 @@ static struct syscore_ops ledtrig_cpu_syscore_ops = {
92 .resume = ledtrig_cpu_syscore_resume, 93 .resume = ledtrig_cpu_syscore_resume,
93}; 94};
94 95
96static int ledtrig_cpu_notify(struct notifier_block *self,
97 unsigned long action, void *hcpu)
98{
99 switch (action & ~CPU_TASKS_FROZEN) {
100 case CPU_STARTING:
101 ledtrig_cpu(CPU_LED_START);
102 break;
103 case CPU_DYING:
104 ledtrig_cpu(CPU_LED_STOP);
105 break;
106 }
107
108 return NOTIFY_OK;
109}
110
111
112static struct notifier_block ledtrig_cpu_nb = {
113 .notifier_call = ledtrig_cpu_notify,
114};
115
95static int __init ledtrig_cpu_init(void) 116static int __init ledtrig_cpu_init(void)
96{ 117{
97 int cpu; 118 int cpu;
@@ -113,6 +134,7 @@ static int __init ledtrig_cpu_init(void)
113 } 134 }
114 135
115 register_syscore_ops(&ledtrig_cpu_syscore_ops); 136 register_syscore_ops(&ledtrig_cpu_syscore_ops);
137 register_cpu_notifier(&ledtrig_cpu_nb);
116 138
117 pr_info("ledtrig-cpu: registered to indicate activity on CPUs\n"); 139 pr_info("ledtrig-cpu: registered to indicate activity on CPUs\n");
118 140
@@ -124,6 +146,8 @@ static void __exit ledtrig_cpu_exit(void)
124{ 146{
125 int cpu; 147 int cpu;
126 148
149 unregister_cpu_notifier(&ledtrig_cpu_nb);
150
127 for_each_possible_cpu(cpu) { 151 for_each_possible_cpu(cpu) {
128 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); 152 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);
129 153