Linux-LEDs Archive mirror
 help / color / mirror / Atom feed
From: Juergen Borleis <jbe@pengutronix.de>
To: linux-leds@vger.kernel.org, Pavel Machek <pavel@ucw.cz>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	linux-kernel@vger.kernel.org,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	kernel@pengutronix.de
Subject: [PATCH] leds: trigger/tty: Use led_set_brightness() to support all use cases
Date: Mon,  3 May 2021 11:25:42 +0200	[thread overview]
Message-ID: <20210503092542.14497-1-jbe@pengutronix.de> (raw)

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


             reply	other threads:[~2021-05-03  9:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-03  9:25 Juergen Borleis [this message]
2021-05-03 10:16 ` [PATCH] leds: trigger/tty: Use led_set_brightness() to support all use cases Pavel Machek
2023-01-09  8:43 ` Uwe Kleine-König
2024-02-23 14:22   ` Lee Jones
2024-02-23 14:24     ` Lee Jones

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=20210503092542.14497-1-jbe@pengutronix.de \
    --to=jbe@pengutronix.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).