diff mbox series

leds: Don't emit brightness set error message if LED supports hw triggers only

Message ID f80b57aa-a542-1d6b-50d9-6de0520f2871@gmail.com
State New
Headers show
Series leds: Don't emit brightness set error message if LED supports hw triggers only | expand

Commit Message

Heiner Kallweit July 22, 2021, 8:25 p.m. UTC
Working on a driver for specific network LEDs that support HW triggers
only I got error "Setting an LED's brightness failed" when switching
to a different trigger. This is caused by call
led_set_brightness(led_cdev, LED_OFF) in led_trigger_set() because
both brigthness_set callbacks are not implemented. Let's suppress
the error message in that case.

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

Patch

diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c
index 8eb8054ef..1104a7f0a 100644
--- a/drivers/leds/led-core.c
+++ b/drivers/leds/led-core.c
@@ -130,6 +130,8 @@  static void set_brightness_delayed(struct work_struct *ws)
 		ret = __led_set_brightness_blocking(led_cdev,
 					led_cdev->delayed_set_value);
 	if (ret < 0 &&
+	    /* LED supports hw triggers only, therefore don't warn */
+	    ret != -ENOTSUPP &&
 	    /* LED HW might have been unplugged, therefore don't warn */
 	    !(ret == -ENODEV && (led_cdev->flags & LED_UNREGISTERING) &&
 	    (led_cdev->flags & LED_HW_PLUGGABLE)))