From: Florian Eckert <fe@dev.tdt.de>
To: u.kleine-koenig@pengutronix.de, gregkh@linuxfoundation.org,
jirislaby@kernel.org, pavel@ucw.cz, lee@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org,
Eckert.Florian@googlemail.com
Subject: [PATCH v8 3/3] ledtrig-tty: call correct brightness set function
Date: Mon, 6 Mar 2023 10:41:13 +0100 [thread overview]
Message-ID: <20230306094113.273988-4-fe@dev.tdt.de> (raw)
In-Reply-To: <20230306094113.273988-1-fe@dev.tdt.de>
The problem is, however, that with LEDs that are connected directly to
the SOC via a GPIO, the LED cannot be switched on or off.
Because the 'leds-gpio' device driver does not need a delayed work.
If we look at the callstack for the function 'led_set_brightness_sync',
then at the end it is checked whether the LED device driver has the
function 'brightness_set_blocking' implemented. This is not the case for
the 'leds-gpio' device.
The function 'brightness_set_blocking' returns LED devices -ENOTSUPP.
This is not evaluated in 'ledtrig-tty' trigger.
In order for the trigger to also work with LED that does not have the
'brightness_set_blocking' function implemented, we must therefore use the
internal API of the LED subsystem and use the function
'led_set_brightness_nosleep'.
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
---
drivers/leds/trigger/ledtrig-tty.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/leds/trigger/ledtrig-tty.c b/drivers/leds/trigger/ledtrig-tty.c
index d3407830fa69..132e809898a7 100644
--- a/drivers/leds/trigger/ledtrig-tty.c
+++ b/drivers/leds/trigger/ledtrig-tty.c
@@ -7,6 +7,8 @@
#include <linux/tty.h>
#include <uapi/linux/serial.h>
+#include "../leds.h"
+
enum tty_led_mode {
TTY_LED_RXTX,
TTY_LED_CTS,
@@ -164,9 +166,9 @@ static void ledtrig_tty_flags(struct ledtrig_tty_data *trigger_data, unsigned in
status = tty_get_mget(trigger_data->tty);
if (status & flag)
- led_set_brightness_sync(trigger_data->led_cdev, LED_ON);
+ led_set_brightness_nosleep(trigger_data->led_cdev, LED_ON);
else
- led_set_brightness_sync(trigger_data->led_cdev, LED_OFF);
+ led_set_brightness_nosleep(trigger_data->led_cdev, LED_OFF);
}
static void ledtrig_tty_work(struct work_struct *work)
@@ -229,12 +231,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_nosleep(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_nosleep(trigger_data->led_cdev, LED_OFF);
}
break;
}
--
2.30.2
next prev parent reply other threads:[~2023-03-06 9:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-06 9:41 [PATCH v8 0/3] leds: ledtrig-tty: add tty_led_mode xtension Florian Eckert
2023-03-06 9:41 ` [PATCH v8 1/3] tty: new helper function tty_get_mget Florian Eckert
2023-03-06 9:41 ` [PATCH v8 2/3] trigger: ledtrig-tty: add additional modes Florian Eckert
2023-03-06 9:41 ` Florian Eckert [this message]
2023-03-06 9:45 ` [PATCH v8 0/3] leds: ledtrig-tty: add tty_led_mode xtension Jiri Slaby
2023-03-06 9:49 ` Florian Eckert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230306094113.273988-4-fe@dev.tdt.de \
--to=fe@dev.tdt.de \
--cc=Eckert.Florian@googlemail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox