diff mbox series

leds: class: If no default trigger is given, make hw_control trigger the default trigger

Message ID f33543de-3800-488f-a779-1fa282614462@gmail.com
State New
Headers show
Series leds: class: If no default trigger is given, make hw_control trigger the default trigger | expand

Commit Message

Heiner Kallweit Dec. 22, 2023, 9:32 p.m. UTC
If a hw_control_trigger is defined, it's usually desirable to make it
the default trigger. Therefore make it the default trigger, except
the driver explicitly set a default trigger.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/leds/led-class.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Lee Jones Jan. 11, 2024, 10:35 a.m. UTC | #1
On Fri, 22 Dec 2023 22:32:28 +0100, Heiner Kallweit wrote:
> If a hw_control_trigger is defined, it's usually desirable to make it
> the default trigger. Therefore make it the default trigger, except
> the driver explicitly set a default trigger.
> 
> 

Applied, thanks!

[1/1] leds: class: If no default trigger is given, make hw_control trigger the default trigger
      commit: 2ee8444431cfa2324a695f964348124b5c4ca3d4

--
Lee Jones [李琼斯]
diff mbox series

Patch

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index ba1be15cf..24fcff682 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -552,6 +552,12 @@  int led_classdev_register_ext(struct device *parent,
 	led_init_core(led_cdev);
 
 #ifdef CONFIG_LEDS_TRIGGERS
+	/*
+	 * If no default trigger was given and hw_control_trigger is set,
+	 * make it the default trigger.
+	 */
+	if (!led_cdev->default_trigger && led_cdev->hw_control_trigger)
+		led_cdev->default_trigger = led_cdev->hw_control_trigger;
 	led_trigger_set_default(led_cdev);
 #endif