[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2023112310-salaried-shower-bc76@gregkh>
Date: Thu, 23 Nov 2023 14:10:44 +0000
From: Greg KH <gregkh@...uxfoundation.org>
To: Florian Eckert <fe@....tdt.de>
Cc: Eckert.Florian@...glemail.com, jirislaby@...nel.org, pavel@....cz,
lee@...nel.org, kabel@...nel.org, u.kleine-koenig@...gutronix.de,
m.brock@...mierlo.com, linux-kernel@...r.kernel.org,
linux-serial@...r.kernel.org, linux-leds@...r.kernel.org
Subject: Re: [Patch v8 4/6] leds: ledtrig-tty: replace mutex with completion
On Thu, Nov 09, 2023 at 09:50:36AM +0100, Florian Eckert wrote:
> With this commit, the mutex handling is replaced by the completion
> handling. When handling mutex, it must always be ensured that the held
> mutex is also released again. This is more error-prone should the number
> of code paths increase.
>
> This is a preparatory commit to make the trigger more configurable via
> additional sysfs parameters. With this change, the worker always runs and
> is no longer stopped if no ttyname is set.
>
> Signed-off-by: Florian Eckert <fe@....tdt.de>
> ---
> drivers/leds/trigger/ledtrig-tty.c | 60 +++++++++++++++---------------
> 1 file changed, 31 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/leds/trigger/ledtrig-tty.c b/drivers/leds/trigger/ledtrig-tty.c
> index 86595add72cd..3badf74fa420 100644
> --- a/drivers/leds/trigger/ledtrig-tty.c
> +++ b/drivers/leds/trigger/ledtrig-tty.c
> @@ -1,5 +1,6 @@
> // SPDX-License-Identifier: GPL-2.0
>
> +#include <linux/completion.h>
> #include <linux/delay.h>
> #include <linux/leds.h>
> #include <linux/module.h>
> @@ -12,15 +13,24 @@
> struct ledtrig_tty_data {
> struct led_classdev *led_cdev;
> struct delayed_work dwork;
> - struct mutex mutex;
> + struct completion sysfs;
> const char *ttyname;
> struct tty_struct *tty;
> int rx, tx;
> };
>
> -static void ledtrig_tty_restart(struct ledtrig_tty_data *trigger_data)
> +static int ledtrig_tty_waitforcompletion(struct device *dev)
Nit, you might want to add a few more '_' characters, right:
ledtrig_tty_wait_for_completion()
to match up with the call to wait_for_completion_timeout() it makes.
> {
> - schedule_delayed_work(&trigger_data->dwork, 0);
> + struct ledtrig_tty_data *trigger_data = led_trigger_get_drvdata(dev);
> + int ret;
> +
> + ret = wait_for_completion_timeout(&trigger_data->sysfs,
> + msecs_to_jiffies(LEDTRIG_TTY_INTERVAL * 20));
> +
Nit, no blank line needed here, if you happen to redo this patch.
thanks,
greg "naming is hard" k-h
Powered by blists - more mailing lists