linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Florian Eckert <fe@dev.tdt.de>
Cc: Eckert.Florian@googlemail.com, jirislaby@kernel.org,
	pavel@ucw.cz, lee@kernel.org, kabel@kernel.org,
	u.kleine-koenig@pengutronix.de, m.brock@vanmierlo.com,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-leds@vger.kernel.org
Subject: Re: [Patch v8 4/6] leds: ledtrig-tty: replace mutex with completion
Date: Thu, 23 Nov 2023 14:10:44 +0000	[thread overview]
Message-ID: <2023112310-salaried-shower-bc76@gregkh> (raw)
In-Reply-To: <20231109085038.371977-5-fe@dev.tdt.de>

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

  reply	other threads:[~2023-11-23 17:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-09  8:50 [Patch v8 0/6] ledtrig-tty: add additional tty state evaluation Florian Eckert
2023-11-09  8:50 ` [Patch v8 1/6] tty: add new helper function tty_get_tiocm Florian Eckert
2023-11-20  7:21   ` Jiri Slaby
2023-11-21  7:35     ` Florian Eckert
2023-11-09  8:50 ` [Patch v8 2/6] leds: ledtrig-tty: free allocated ttyname buffer on deactivate Florian Eckert
2023-11-23 14:06   ` Greg KH
2023-11-27  7:13     ` Florian Eckert
2023-11-27  8:04       ` Lee Jones
2023-11-27  8:19         ` Florian Eckert
2023-11-09  8:50 ` [Patch v8 3/6] leds: ledtrig-tty: change logging if get icount failed Florian Eckert
2023-11-23 14:08   ` Greg KH
2023-11-09  8:50 ` [Patch v8 4/6] leds: ledtrig-tty: replace mutex with completion Florian Eckert
2023-11-23 14:10   ` Greg KH [this message]
2023-11-09  8:50 ` [Patch v8 5/6] leds: ledtrig-tty: make rx tx activitate configurable Florian Eckert
2023-11-23 14:12   ` Greg KH
2023-11-09  8:50 ` [Patch v8 6/6] leds: ledtrig-tty: add additional line state evaluation Florian Eckert
2023-11-09 19:03   ` m.brock
2023-11-17 12:12     ` Lee Jones
2023-11-20  7:21       ` Florian Eckert
2023-11-21 15:23         ` Lee Jones
2023-11-22  9:50           ` Florian Eckert
2023-11-22 11:28             ` Lee Jones
2023-12-01 10:40 ` [Patch v8 0/6] ledtrig-tty: add additional tty " Lee Jones
2023-12-01 13:08   ` Florian Eckert
2023-12-06 13:47     ` Lee Jones
2023-12-06 13:57       ` Florian Eckert

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=2023112310-salaried-shower-bc76@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=Eckert.Florian@googlemail.com \
    --cc=fe@dev.tdt.de \
    --cc=jirislaby@kernel.org \
    --cc=kabel@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=m.brock@vanmierlo.com \
    --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 NNTP newsgroup(s).