Reading /sys/class/leds/<led>/trigger returns all available LED triggers.
However, this violates the "one value per file" rule of sysfs.
This provides /sys/class/leds/<led>/current-trigger which is almost
identical to /sys/class/leds/<led>/trigger. The only difference is that
'current-trigger' only shows the current trigger name.
This new file follows the "one value per file" rule of sysfs.
We can find all available LED triggers by listing the
/sys/devices/virtual/led-trigger/ directory.
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx>
Cc: Jacek Anaszewski <jacek.anaszewski@xxxxxxxxx>
Cc: Pavel Machek <pavel@xxxxxx>
Cc: Dan Murphy <dmurphy@xxxxxx>
Signed-off-by: Akinobu Mita <akinobu.mita@xxxxxxxxx>
---
Documentation/ABI/testing/sysfs-class-led | 13 +++++++++++
drivers/leds/led-class.c | 10 ++++++++
drivers/leds/led-triggers.c | 38 +++++++++++++++++++++++++++----
drivers/leds/leds.h | 5 ++++
4 files changed, 62 insertions(+), 4 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-class-led b/Documentation/ABI/testing/sysfs-class-led
index 5f67f7a..fdfed3f 100644
--- a/Documentation/ABI/testing/sysfs-class-led
+++ b/Documentation/ABI/testing/sysfs-class-led
@@ -61,3 +61,16 @@ Description:
gpio and backlight triggers. In case of the backlight trigger,
it is useful when driving a LED which is intended to indicate
a device in a standby like state.
+
+What: /sys/class/leds/<led>/current-trigger
+Date: September 2019
+KernelVersion: 5.5
+Contact: linux-leds@xxxxxxxxxxxxxxx
+Description:
+ Set the trigger for this LED. A trigger is a kernel based source
+ of LED events.
+ Writing the trigger name to this file will change the current
+ trigger. Trigger specific parameters can appear in
+ /sys/class/leds/<led> once a given trigger is selected. For
+ their documentation see sysfs-class-led-trigger-*.
+ Reading this file will return the current LED trigger name.