diff mbox series

[03/11] leds: add helper function to use trigger in hw blink mode

Message ID 20230427001541.18704-4-ansuelsmth@gmail.com
State New
Headers show
Series leds: introduce new LED hw control APIs | expand

Commit Message

Christian Marangi April 27, 2023, 12:15 a.m. UTC
Add helper function to use trigger in hw blink mode.

Add function led_trigger_can_hw_control() that will check if hw_control
ops are defined and if the current trigger match the one supported for
hw_control.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 include/linux/leds.h | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/include/linux/leds.h b/include/linux/leds.h
index 06a67c62ed6e..b9152bff3a96 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -425,6 +425,14 @@  void led_trigger_blink_oneshot(struct led_trigger *trigger,
 void led_trigger_set_default(struct led_classdev *led_cdev);
 int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trigger);
 void led_trigger_remove(struct led_classdev *led_cdev);
+static inline bool led_trigger_can_hw_control(struct led_classdev *led_cdev)
+{
+	if (!led_cdev->hw_control_get || !led_cdev->hw_control_set ||
+	    !led_cdev->hw_control_is_supported)
+		return false;
+
+	return !strcmp(led_cdev->hw_control_trigger, led_cdev->trigger->name);
+}
 
 static inline void led_set_trigger_data(struct led_classdev *led_cdev,
 					void *trigger_data)