[RFC PATCH 2/9] leds: Add callback offloaded() to query the state of hw control trigger

From: Rong Zhang

Date: Fri Feb 27 2026 - 14:07:12 EST


Currently, we have multiple triggers implementing hw control. However,
the LED core doesn't really know the hw control state since the
coordination is done directly between the hw control trigger and the LED
device.

In the following patches, we are about to support hardware initiated
trigger transitions to/from hw control trigger. The hw control state is
a fundamental factor of determining if a transition should be permitted.

Add a callback offloaded() so that the LED core can query the hw control
state and use it to make decisions in hw initiated trigger transitions.

Signed-off-by: Rong Zhang <i@xxxxxxxx>
---
Documentation/leds/leds-class.rst | 5 +++++
include/linux/leds.h | 1 +
2 files changed, 6 insertions(+)

diff --git a/Documentation/leds/leds-class.rst b/Documentation/leds/leds-class.rst
index 5db620ed27aa2..84665200a88dc 100644
--- a/Documentation/leds/leds-class.rst
+++ b/Documentation/leds/leds-class.rst
@@ -235,6 +235,11 @@ LED driver must implement the following API to support hw control:
Returns a pointer to a struct device or NULL if nothing
is currently attached.

+LED trigger must implement the following API to support hw control:
+ - offloaded:
+ return a boolean indicating if the trigger is offloaded to
+ hardware.
+
LED driver can activate additional modes by default to workaround the
impossibility of supporting each different mode on the supported trigger.
Examples are hardcoding the blink speed to a set interval, enable special
diff --git a/include/linux/leds.h b/include/linux/leds.h
index b16b803cc1ac5..7332034a43c85 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -485,6 +485,7 @@ struct led_trigger {
const char *name;
int (*activate)(struct led_classdev *led_cdev);
void (*deactivate)(struct led_classdev *led_cdev);
+ bool (*offloaded)(struct led_classdev *led_cdev);

/* Brightness set by led_trigger_event */
enum led_brightness brightness;
--
2.51.0