[PATCH 0/5] leds: fix /sys/class/leds/<led>/trigger and add new api

From: Akinobu Mita
Date: Sun Sep 08 2019 - 08:41:50 EST


Reading /sys/class/leds/<led>/trigger returns all available LED triggers.
However, the size of this file is limited to PAGE_SIZE because of the
limitation for sysfs attribute.

Enabling LED CPU trigger on systems with thousands of CPUs easily hits
PAGE_SIZE limit, and makes it impossible to see all available LED triggers
and which trigger is currently activated.

The first patch in this series converts /sys/class/leds/<led>/trigger to
bin attribute and removes the PAGE_SIZE limitation.

The rest of series provides a new /sys/class/triggers/ directory and
/sys/class/leds/<led>/current-trigger. The new api follows the "one value
per file" rule of sysfs.

Akinobu Mita (5):
leds: remove PAGE_SIZE limit of /sys/class/leds/<led>/trigger
leds: make sure leds_class is initialized before triggers are
registered
driver core: class: add function to create /sys/class/<class>/foo
directory
leds: add /sys/class/triggers/ that contains trigger sub-directories
leds: add /sys/class/leds/<led>/current-trigger

Documentation/ABI/testing/sysfs-class-led | 22 +++++
drivers/base/class.c | 7 ++
drivers/leds/led-class.c | 49 +++++++++--
drivers/leds/led-triggers.c | 139 +++++++++++++++++++++++++-----
drivers/leds/leds.h | 12 +++
include/linux/device.h | 3 +
include/linux/leds.h | 6 +-
7 files changed, 207 insertions(+), 31 deletions(-)

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>
--
2.7.4