diff options
Diffstat (limited to 'drivers/leds/trigger/ledtrig-cpu.c')
-rw-r--r-- | drivers/leds/trigger/ledtrig-cpu.c | 24 |
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 | ||
96 | static 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 | |||
112 | static struct notifier_block ledtrig_cpu_nb = { | ||
113 | .notifier_call = ledtrig_cpu_notify, | ||
114 | }; | ||
115 | |||
95 | static int __init ledtrig_cpu_init(void) | 116 | static 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 | ||