Skip to contentSkip to conversation

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

PATCH In review Heiner Kallweit 3 participants 4 messages Jul 22, 2021 – Nov 1, 2021 LED

lore
Share & tools
lore
#0 lore raw

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

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.

---
 drivers/leds/led-core.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/leds/led-core.c +2 -0
index 8eb8054ef..1104a7f0a 100644
@@ -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)))
Signature · 1 line
2.32.0
#1 lore raw

Hi!

Quoted 6 lines

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.

Hmm... do we have such LEDs in tree? LED supporting only hardware triggers is kind of unusual/interesting/and I'm not really sure if we should have them in LED subsystem.

Best regards,
Pavel

Signature · 1 line
http://www.livejournal.com/~pavelmachek
#2 lore raw
Quoted 10 lines · Pavel Machek

Hi!

Quoted 6 lines

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.

Quoted 4 lines

Hmm... do we have such LEDs in tree? LED supporting only hardware triggers is kind of unusual/interesting/and I'm not really sure if we should have them in LED subsystem.

This was when working on network LED support for r8169 where you can select between a number of HW triggers only. IIRC the discussion how to support such network LEDs didn't really come to a conclusion yet. Having said that at least my work hasn't been upstreamed yet.

Quoted 3 lines

Best regards,
Pavel

Heiner

#3 lore raw
In reply to Pavel Machek
Quoted 10 lines · On Mon, 1 Nov 2021 12:59:10 +0100 Pavel Machek <[email protected]> wrote:

Hi!

Quoted 6 lines

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.

Quoted 3 lines

Hmm... do we have such LEDs in tree? LED supporting only hardware triggers is kind of unusual/interesting/and I'm not really sure if we should have them in LED subsystem.

Why not? I mean there actually are such LEDs and the LED subsystem is the best fit for them. The LED trigger ABI can be used to set HW control mode on these LEDs.

I think it would be confusing to put such LEDs into a different subsystem.

Marek