| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * ledtrig-cpu.c - LED trigger based on CPU activity |
|---|
| 3 | 4 | * |
|---|
| 4 | | - * This LED trigger will be registered for each possible CPU and named as |
|---|
| 5 | | - * cpu0, cpu1, cpu2, cpu3, etc. |
|---|
| 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. |
|---|
| 8 | + * |
|---|
| 9 | + * If you want support for arbitrary number of CPUs, make it one trigger, |
|---|
| 10 | + * with additional sysfs file selecting which CPU to watch. |
|---|
| 6 | 11 | * |
|---|
| 7 | 12 | * It can be bound to any LED just like other triggers using either a |
|---|
| 8 | 13 | * board file or via sysfs interface. |
|---|
| 9 | 14 | * |
|---|
| 10 | 15 | * An API named ledtrig_cpu is exported for any user, who want to add CPU |
|---|
| 11 | | - * activity indication in their code |
|---|
| 16 | + * activity indication in their code. |
|---|
| 12 | 17 | * |
|---|
| 13 | 18 | * Copyright 2011 Linus Walleij <linus.walleij@linaro.org> |
|---|
| 14 | 19 | * Copyright 2011 - 2012 Bryan Wu <bryan.wu@canonical.com> |
|---|
| 15 | | - * |
|---|
| 16 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 17 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 18 | | - * published by the Free Software Foundation. |
|---|
| 19 | | - * |
|---|
| 20 | 20 | */ |
|---|
| 21 | 21 | |
|---|
| 22 | 22 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 149 | 149 | for_each_possible_cpu(cpu) { |
|---|
| 150 | 150 | struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); |
|---|
| 151 | 151 | |
|---|
| 152 | + if (cpu >= 8) |
|---|
| 153 | + continue; |
|---|
| 154 | + |
|---|
| 152 | 155 | snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); |
|---|
| 153 | 156 | |
|---|
| 154 | 157 | led_trigger_register_simple(trig->name, &trig->_trig); |
|---|