lkml.org 
[lkml]   [2021]   [May]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] leds: trigger/tty: Use led_set_brightness() to support all use cases
Date
Using led_set_brightness_sync() only works for LEDs which are connected
via some kind of external bus like I²C or SPI. But it doesn't work for
the simple use case of directly connected LEDs via GPIOs.
Because this function only honors the led_classdev::brightness_set_blocking
callback. But the LED-GPIO driver registers the
led_classdev::brightness_set member if the GPIO can be modified directly
and thus, TTY triggers fail silently with -ENOTSUPP.

With the previously used led_set_brightness() it works for both use cases.
This function first checks for the simple case where the GPIO can be changed
without additional overhead, and if it fails, does the modification via a
workqueue.

Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
---
drivers/leds/trigger/ledtrig-tty.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/trigger/ledtrig-tty.c b/drivers/leds/trigger/ledtrig-tty.c
index f62db7e..af61281 100644
--- a/drivers/leds/trigger/ledtrig-tty.c
+++ b/drivers/leds/trigger/ledtrig-tty.c
@@ -122,12 +122,12 @@ static void ledtrig_tty_work(struct work_struct *work)

if (icount.rx != trigger_data->rx ||
icount.tx != trigger_data->tx) {
- led_set_brightness_sync(trigger_data->led_cdev, LED_ON);
+ led_set_brightness(trigger_data->led_cdev, LED_ON);

trigger_data->rx = icount.rx;
trigger_data->tx = icount.tx;
} else {
- led_set_brightness_sync(trigger_data->led_cdev, LED_OFF);
+ led_set_brightness(trigger_data->led_cdev, LED_OFF);
}

out:
--
2.20.1
\
 
 \ /
  Last update: 2021-05-03 11:26    [W:0.051 / U:0.952 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site