Lines Matching +full:8 +full:- +full:cpu
1 // SPDX-License-Identifier: GPL-2.0-only
3 * ledtrig-cpu.c - LED trigger based on CPU activity
5 * This LED trigger will be registered for first 8 CPUs and named
6 * as cpu0..cpu7. There's additional trigger called cpu that
7 * is on when any CPU is active.
10 * with additional sysfs file selecting which CPU to watch.
15 * An API named ledtrig_cpu is exported for any user, who want to add CPU
19 * Copyright 2011 - 2012 Bryan Wu <bryan.wu@canonical.com>
28 #include <linux/cpu.h>
31 #define MAX_NAME_LEN 8
45 * ledtrig_cpu - emit a CPU event as a trigger
46 * @evt: CPU event to be emitted
48 * Emit a CPU event on a CPU core, which will trigger a
54 bool is_active = trig->is_active; in ledtrig_cpu()
56 /* Locate the correct CPU LED */ in ledtrig_cpu()
76 if (is_active != trig->is_active) { in ledtrig_cpu()
81 trig->is_active = is_active; in ledtrig_cpu()
82 atomic_add(is_active ? 1 : -1, &num_active_cpus); in ledtrig_cpu()
86 led_trigger_event(trig->_trig, in ledtrig_cpu()
119 static int ledtrig_online_cpu(unsigned int cpu) in ledtrig_online_cpu() argument
125 static int ledtrig_prepare_down_cpu(unsigned int cpu) in ledtrig_prepare_down_cpu() argument
133 int cpu; in ledtrig_cpu_init() local
136 /* Supports up to 9999 cpu cores */ in ledtrig_cpu_init()
142 led_trigger_register_simple("cpu", &trig_cpu_all); in ledtrig_cpu_init()
145 * Registering CPU led trigger for each CPU core here in ledtrig_cpu_init()
146 * ignores CPU hotplug, but after this CPU hotplug works in ledtrig_cpu_init()
149 for_each_possible_cpu(cpu) { in ledtrig_cpu_init()
150 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); in ledtrig_cpu_init()
152 if (cpu >= 8) in ledtrig_cpu_init()
155 snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); in ledtrig_cpu_init()
157 led_trigger_register_simple(trig->name, &trig->_trig); in ledtrig_cpu_init()
165 pr_err("CPU hotplug notifier for ledtrig-cpu could not be registered: %d\n", in ledtrig_cpu_init()
168 pr_info("ledtrig-cpu: registered to indicate activity on CPUs\n"); in ledtrig_cpu_init()