linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ledtrig-cpu: Limit to 4 CPUs
@ 2020-09-19  9:38 Pavel Machek
  2020-09-20 14:15 ` Jacek Anaszewski
  0 siblings, 1 reply; 14+ messages in thread
From: Pavel Machek @ 2020-09-19  9:38 UTC (permalink / raw)
  To: linux-leds, dmurphy

[-- Attachment #1: Type: text/plain, Size: 2039 bytes --]

commit 318681d3e019e39354cc6c2155a7fd1bb8e8084d
Author: Pavel Machek <pavel@ucw.cz>
Date:   Sat Sep 19 11:34:58 2020 +0200

    ledtrig-cpu: Limit to 4 CPUs
    
    Some machines have thousands of CPUs... and trigger mechanisms was not
    really meant for thousands of triggers. I doubt anyone uses this
    trigger on many-CPU machine; but if they do, they'll need to do it
    properly.
    
    Signed-off-by: Pavel Machek <pavel@ucw.cz>

diff --git a/drivers/leds/trigger/ledtrig-cpu.c b/drivers/leds/trigger/ledtrig-cpu.c
index 869976d1b734..b7e00b09b137 100644
--- a/drivers/leds/trigger/ledtrig-cpu.c
+++ b/drivers/leds/trigger/ledtrig-cpu.c
@@ -2,14 +2,18 @@
 /*
  * ledtrig-cpu.c - LED trigger based on CPU activity
  *
- * This LED trigger will be registered for each possible CPU and named as
- * cpu0, cpu1, cpu2, cpu3, etc.
+ * This LED trigger will be registered for first four CPUs and named
+ * as cpu0, cpu1, cpu2, cpu3. There's additional trigger called cpu that
+ * is on when any CPU is active.
+ *
+ * If you want support for arbitrary number of CPUs, make it one trigger,
+ * with additional sysfs file selecting which CPU to watch.
  *
  * It can be bound to any LED just like other triggers using either a
  * board file or via sysfs interface.
  *
  * An API named ledtrig_cpu is exported for any user, who want to add CPU
- * activity indication in their code
+ * activity indication in their code.
  *
  * Copyright 2011 Linus Walleij <linus.walleij@linaro.org>
  * Copyright 2011 - 2012 Bryan Wu <bryan.wu@canonical.com>
@@ -145,6 +149,9 @@ static int __init ledtrig_cpu_init(void)
 	for_each_possible_cpu(cpu) {
 		struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);
 
+		if (cpu > 4)
+			continue;
+
 		snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu);
 
 		led_trigger_register_simple(trig->name, &trig->_trig);

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-10-08 10:10 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-19  9:38 ledtrig-cpu: Limit to 4 CPUs Pavel Machek
2020-09-20 14:15 ` Jacek Anaszewski
2020-09-20 15:39   ` Marek Behun
2020-09-20 16:55     ` Jacek Anaszewski
2020-09-20 17:33       ` Marek Behun
2020-09-20 17:49         ` Jacek Anaszewski
2020-09-20 18:34   ` Pavel Machek
2020-09-21 22:14     ` Jacek Anaszewski
2020-09-21 22:42       ` Pavel Machek
2020-09-22 20:41         ` Jacek Anaszewski
2020-09-25  8:51           ` Jacek Anaszewski
2020-09-25  9:40             ` Pavel Machek
2020-09-26 13:59               ` Jacek Anaszewski
2020-10-08 10:10                 ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).