* [PATCH v2 0/2] Fixes for the tty ledtrigger
@ 2021-02-19 13:33 Uwe Kleine-König
2021-02-19 13:33 ` [PATCH v2 1/2] leds: trigger: Fix error path to not unlock the unlocked mutex Uwe Kleine-König
2021-02-19 13:33 ` [PATCH v2 2/2] leds: trigger/tty: Use led_set_brightness_sync() from workqueue Uwe Kleine-König
0 siblings, 2 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2021-02-19 13:33 UTC (permalink / raw)
To: Pavel Machek, Greg Kroah-Hartman
Cc: kernel, linux-leds, linux-kernel, linux-serial
Hello,
this drops the unused label that the kernel test robot found. Thanks for
catching that.
I also added Pavel's Ack.
Best regards
Uwe
Uwe Kleine-König (2):
leds: trigger: Fix error path to not unlock the unlocked mutex
leds: trigger/tty: Use led_set_brightness_sync() from workqueue
drivers/leds/trigger/ledtrig-tty.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
Range-diff against v1:
1: 7fc10ce8eb8b ! 1: ed39ad41cd91 leds: trigger: Fix error path to not unlock the unlocked mutex
@@ Commit message
Reported-by: Pavel Machek <pavel@ucw.cz>
Fixes: fd4a641ac88f ("leds: trigger: implement a tty trigger")
+ Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
## drivers/leds/trigger/ledtrig-tty.c ##
@@ drivers/leds/trigger/ledtrig-tty.c: static ssize_t ttyname_store(struct device *
} else {
ttyname = NULL;
}
+@@ drivers/leds/trigger/ledtrig-tty.c: static ssize_t ttyname_store(struct device *dev,
+
+ trigger_data->ttyname = ttyname;
+
+-out_unlock:
+ mutex_unlock(&trigger_data->mutex);
+
+ if (ttyname && !running)
2: fe3d28f4a786 ! 2: a812318f4cfc leds: trigger/tty: Use led_set_brightness_sync() from workqueue
@@ Commit message
Reported-by: Pavel Machek <pavel@ucw.cz>
Fixes: fd4a641ac88f ("leds: trigger: implement a tty trigger")
+ Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
## drivers/leds/trigger/ledtrig-tty.c ##
--
2.29.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/2] leds: trigger: Fix error path to not unlock the unlocked mutex
2021-02-19 13:33 [PATCH v2 0/2] Fixes for the tty ledtrigger Uwe Kleine-König
@ 2021-02-19 13:33 ` Uwe Kleine-König
2021-02-19 13:33 ` [PATCH v2 2/2] leds: trigger/tty: Use led_set_brightness_sync() from workqueue Uwe Kleine-König
1 sibling, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2021-02-19 13:33 UTC (permalink / raw)
To: Pavel Machek, Greg Kroah-Hartman
Cc: kernel, linux-leds, linux-kernel, linux-serial
ttyname is allocated before the mutex is taken, so it must not be
unlocked in the error path.
Reported-by: Pavel Machek <pavel@ucw.cz>
Fixes: fd4a641ac88f ("leds: trigger: implement a tty trigger")
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
drivers/leds/trigger/ledtrig-tty.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/leds/trigger/ledtrig-tty.c b/drivers/leds/trigger/ledtrig-tty.c
index d2ab6ab080ac..af61281dc6a1 100644
--- a/drivers/leds/trigger/ledtrig-tty.c
+++ b/drivers/leds/trigger/ledtrig-tty.c
@@ -51,10 +51,8 @@ static ssize_t ttyname_store(struct device *dev,
if (size) {
ttyname = kmemdup_nul(buf, size, GFP_KERNEL);
- if (!ttyname) {
- ret = -ENOMEM;
- goto out_unlock;
- }
+ if (!ttyname)
+ return -ENOMEM;
} else {
ttyname = NULL;
}
@@ -69,7 +67,6 @@ static ssize_t ttyname_store(struct device *dev,
trigger_data->ttyname = ttyname;
-out_unlock:
mutex_unlock(&trigger_data->mutex);
if (ttyname && !running)
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] leds: trigger/tty: Use led_set_brightness_sync() from workqueue
2021-02-19 13:33 [PATCH v2 0/2] Fixes for the tty ledtrigger Uwe Kleine-König
2021-02-19 13:33 ` [PATCH v2 1/2] leds: trigger: Fix error path to not unlock the unlocked mutex Uwe Kleine-König
@ 2021-02-19 13:33 ` Uwe Kleine-König
1 sibling, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2021-02-19 13:33 UTC (permalink / raw)
To: Pavel Machek, Greg Kroah-Hartman
Cc: kernel, linux-leds, linux-kernel, linux-serial
led_set_brightness() involves scheduling a workqueue. As here the led's
brightness setting is done in context of the trigger's workqueue this is
unjustified overhead and it's more sensible to use
led_set_brightness_sync().
Reported-by: Pavel Machek <pavel@ucw.cz>
Fixes: fd4a641ac88f ("leds: trigger: implement a tty trigger")
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@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 af61281dc6a1..f62db7e520b5 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(trigger_data->led_cdev, LED_ON);
+ led_set_brightness_sync(trigger_data->led_cdev, LED_ON);
trigger_data->rx = icount.rx;
trigger_data->tx = icount.tx;
} else {
- led_set_brightness(trigger_data->led_cdev, LED_OFF);
+ led_set_brightness_sync(trigger_data->led_cdev, LED_OFF);
}
out:
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-19 13:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-19 13:33 [PATCH v2 0/2] Fixes for the tty ledtrigger Uwe Kleine-König
2021-02-19 13:33 ` [PATCH v2 1/2] leds: trigger: Fix error path to not unlock the unlocked mutex Uwe Kleine-König
2021-02-19 13:33 ` [PATCH v2 2/2] leds: trigger/tty: Use led_set_brightness_sync() from workqueue Uwe Kleine-König
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 NNTP newsgroup(s).