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: <20230306094113.273988-4-fe@dev.tdt.de>
Date:   Mon,  6 Mar 2023 10:41:13 +0100
From:   Florian Eckert <fe@....tdt.de>
To:     u.kleine-koenig@...gutronix.de, gregkh@...uxfoundation.org,
        jirislaby@...nel.org, pavel@....cz, lee@...nel.org
Cc:     linux-kernel@...r.kernel.org, linux-leds@...r.kernel.org,
        Eckert.Florian@...glemail.com
Subject: [PATCH v8 3/3] ledtrig-tty: call correct brightness set function

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@....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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ