History log of /linux-master/drivers/leds/trigger/ledtrig-cpu.c
Revision Date Author Comments
# ff50f532 23-Sep-2023 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

leds: trigger: ledtrig-cpu:: Fix 'output may be truncated' issue for 'cpu'

In order to teach the compiler that 'trig->name' will never be truncated,
we need to tell it that 'cpu' is not negative.

When building with W=1, this fixes the following warnings:

drivers/leds/trigger/ledtrig-cpu.c: In function ‘ledtrig_cpu_init’:
drivers/leds/trigger/ledtrig-cpu.c:155:56: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 5 [-Werror=format-truncation=]
155 | snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu);
| ^~
drivers/leds/trigger/ledtrig-cpu.c:155:52: note: directive argument in the range [-2147483648, 7]
155 | snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu);
| ^~~~~~~
drivers/leds/trigger/ledtrig-cpu.c:155:17: note: ‘snprintf’ output between 5 and 15 bytes into a destination of size 8
155 | snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: 8f88731d052d ("led-triggers: create a trigger for CPU activity")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/3f4be7a99933cf8566e630da54f6ab913caac432.1695453322.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Lee Jones <lee@kernel.org>


# c10074a1 28-May-2021 Lee Jones <lee.jones@linaro.org>

leds: trigger: ledtrig-cpu: Fix incorrectly documented param 'ledevt'

Fixes the following W=1 kernel build warning(s):

drivers/leds/trigger/ledtrig-cpu.c:52: warning: Function parameter or member 'ledevt' not described in 'ledtrig_cpu'
drivers/leds/trigger/ledtrig-cpu.c:52: warning: Excess function parameter 'evt' description in 'ledtrig_cpu'

Cc: Pavel Machek <pavel@ucw.cz>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Bryan Wu <bryan.wu@canonical.com>
Cc: linux-leds@vger.kernel.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Pavel Machek <pavel@ucw.cz>


# abcc1312 19-Sep-2020 Pavel Machek <pavel@ucw.cz>

ledtrig-cpu: Limit to 8 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>


# d2912cb1 04-Jun-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500

Based on 2 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license version 2 as
published by the free software foundation

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license version 2 as
published by the free software foundation #

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 4122 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 0b88b71c 09-Feb-2017 Paulo Costa <me@paulo.costa.nom.br>

leds/trigger/cpu: Add LED trigger for all CPUs aggregated

Currently there is one CPU led trigger per cpu ('cpu0', 'cpu1', ...)

This patch adds a new trigger, 'cpu', with brightness proportional to
the number of active CPUs.

If multiple brightness levels aren't supported on the LED,
it effectively indicates if there is any CPU active.

This is particularly useful on tiny linux boards with more CPU cores than LED pins.

Signed-off-by: Paulo Costa <me@paulo.costa.nom.br>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>


# 73c1b41e 21-Dec-2016 Thomas Gleixner <tglx@linutronix.de>

cpu/hotplug: Cleanup state names

When the state names got added a script was used to add the extra argument
to the calls. The script basically converted the state constant to a
string, but the cleanup to convert these strings into meaningful ones did
not happen.

Replace all the useless strings with 'subsys/xxx/yyy:state' strings which
are used in all the other places already.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Link: http://lkml.kernel.org/r/20161221192112.085444152@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>


# e602fda1 03-Oct-2016 Pavel Machek <pavel@ucw.cz>

ledtrig-cpu.c: fix english

Fix english spelling.

Signed-off-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>


# cd894f14 20-Jul-2016 Sebastian Andrzej Siewior <bigeasy@linutronix.de>

leds/trigger/cpu: Move from CPU_STARTING to ONLINE level

There is no need the ledtriger to be called *that* early in the hotplug
process (+ with disabled interrupts). As explained by Jacek Anaszewski [0]
there is no need for it.
Therefore this patch moves it to the ONLINE/PREPARE_DOWN level using the
dynamic registration for the id.

[0] https://lkml.kernel.org/r/578C92BC.2070603@samsung.com

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: rt@linutronix.de
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-leds@vger.kernel.org
Link: http://lkml.kernel.org/r/1469028295-14702-1-git-send-email-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>


# 911a359d 13-Jul-2016 Richard Cochran <rcochran@linutronix.de>

leds/trigger/cpu: Convert to hotplug state machine

This is a straightforward conversion. We place this callback last
in the list so that the LED illuminates only after a successful
bring up sequence.

( NOTE: The patch adds a FIXME question about the callback used,
this question should probably be revisited later on.)

Signed-off-by: Richard Cochran <rcochran@linutronix.de>
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-leds@vger.kernel.org
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160713153336.465496902@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>


# 227a0ca1 13-Dec-2015 Paul Gortmaker <paul.gortmaker@windriver.com>

leds: ledtrig-cpu: Make the driver explicitly non-modular

The Kconfig for this driver is currently:

config LEDS_TRIGGER_CPU
bool "LED CPU Trigger"

...meaning that it currently is not being built as a module by anyone.
Lets remove the modular code that is essentially orphaned, so that
when reading the driver there is no doubt it is builtin-only.

Since module_init translates to device_initcall in the non-modular
case, the init ordering remains unchanged with this commit.

We also delete the MODULE_LICENSE tag etc. since all that information
is already contained at the top of the file in the comments.

Cc: Bryan Wu <cooloney@gmail.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: linux-leds@vger.kernel.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>


# 24c9301f 05-May-2014 Christoph Lameter <cl@linux.com>

drivers/leds: Replace __get_cpu_var use through this_cpu_ptr

Use this_cpu_ptr for the address calculation instead of __get_cpu_var.

Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>


# fba14ae8 22-Jan-2014 Pawel Moll <pawel.moll@arm.com>

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>


# f07fb521 20-Feb-2013 Kim, Milo <Milo.Kim@ti.com>

leds: move LED trigger drivers into new subdirectory

For better driver management, new subdirectory, 'trigger' is created.
All LED trigger drivers are moved into this directory.

Internal header, 'leds.h' is included in each LED trigger drivers.
Fix the location of header file, "leds.h" -> "../leds.h" in driver files.
One exception is here, 'ledtrig-timer.c'.
There is no need to include 'leds.h'. so '#include "leds.h"' line was removed.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>