lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230109084320.nj7erwh3eu4jlw7y@pengutronix.de>
Date:   Mon, 9 Jan 2023 09:43:20 +0100
From:   Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To:     Juergen Borleis <jbe@...gutronix.de>
Cc:     linux-leds@...r.kernel.org, Pavel Machek <pavel@....cz>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-kernel@...r.kernel.org, kernel@...gutronix.de
Subject: Re: [PATCH] leds: trigger/tty: Use led_set_brightness() to support
 all use cases

Hello Jürgen,

On Mon, May 03, 2021 at 11:25:42AM +0200, Juergen Borleis wrote:
> 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@...gutronix.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);
>  	}

This problem still exists, right?

I think the right thing here is to call led_set_brightness_nosleep()
however.

Having said that, I think there are too many variants of
led_set_brightness which makes it difficult to pick the right one.

(I'm aware of
 - led_set_brightness_nosleep
 - led_set_brightness_nopm
 - led_set_brightness_sync
 - led_set_brightness

and there are a few more static variants in led-core.c
(__led_set_brightness, __led_set_brightness_blocking,
set_brightness_delayed).)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Download attachment "signature.asc" of type "application/pgp-signature" (485 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ