linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Pavel Machek <pavel@ucw.cz>
Cc: kernel@pengutronix.de,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>,
	Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	linux-serial@vger.kernel.org, Jiri Slaby <jslaby@suse.com>,
	linux-leds@vger.kernel.org, Dan Murphy <dmurphy@ti.com>
Subject: Re: [PATCH v11] leds: trigger: implement a tty trigger
Date: Fri, 19 Feb 2021 09:00:38 +0100	[thread overview]
Message-ID: <20210219080038.et46fcrha7ymw6b3@pengutronix.de> (raw)
In-Reply-To: <20210218133733.GB12948@duo.ucw.cz>

[-- Attachment #1: Type: text/plain, Size: 2040 bytes --]

Hi Pavel,

On Thu, Feb 18, 2021 at 02:37:33PM +0100, Pavel Machek wrote:
> Close, but see below:
> 
> > +static ssize_t ttyname_store(struct device *dev,
> > +			     struct device_attribute *attr, const char *buf,
> > +			     size_t size)
> > +{
> > +	struct ledtrig_tty_data *trigger_data = led_trigger_get_drvdata(dev);
> > +	char *ttyname;
> > +	ssize_t ret = size;
> > +	bool running;
> > +
> > +	if (size > 0 && buf[size - 1] == '\n')
> > +		size -= 1;
> > +
> > +	if (size) {
> > +		ttyname = kmemdup_nul(buf, size, GFP_KERNEL);
> > +		if (!ttyname) {
> > +			ret = -ENOMEM;
> > +			goto out_unlock;
> 
> Unlock without a lock:
> 
> > +out_unlock:
> > +	mutex_unlock(&trigger_data->mutex);

Indeed, I prepare an incremental patch that does return -ENOMEM instead
of goto out_unlock.

> > +
> > +	if (ttyname && !running)
> > +		ledtrig_tty_restart(trigger_data);
> > +
> > +	return ret;
> > +}
> 
> > +
> > +		tty = tty_kopen_shared(devno);
> > +		if (IS_ERR(tty) || !tty)
> > +			/* What to do? retry or abort */
> > +			goto out;
> 
> Abort would make sense to me.

In this case it would IMHO be sensible to already try the
tty_kopen_shared() in ttyname_store() and let that one fail if the tty
doesn't exist. I'll have to go through the history of this patch set, if
I remember correctly it was like that at one point.

> > +	if (icount.rx != trigger_data->rx ||
> > +	    icount.tx != trigger_data->tx) {
> > +		led_set_brightness(trigger_data->led_cdev, LED_ON);
> 
> Please use _sync version.

OK, there are too many variants for me. I'll just believe you that
led_set_brightness_sync is the right one. (Hmm, on the other hand I'll
have to understand the difference for a good commit log. I'll dig into
that. "Pavel said so" probably isn't good enough :-))

Best regards and thanks for your review,
Uwe

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2021-02-19  8:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-18 10:42 [PATCH v10 0/3] leds: trigger: implement a tty trigger Uwe Kleine-König
2020-12-18 10:42 ` [PATCH v10 1/3] tty: rename tty_kopen() and add new function tty_kopen_shared() Uwe Kleine-König
2020-12-18 10:42 ` [PATCH v10 2/3] tty: new helper function tty_get_icount() Uwe Kleine-König
2020-12-18 10:42 ` [PATCH v10 3/3] leds: trigger: implement a tty trigger Uwe Kleine-König
2021-01-13 16:16   ` Greg Kroah-Hartman
2021-01-13 17:30     ` [PATCH v11] " Uwe Kleine-König
2021-01-13 18:34       ` Greg Kroah-Hartman
2021-02-18 13:33         ` Pavel Machek
2021-02-18 21:19           ` Uwe Kleine-König
2021-02-18 21:21             ` Greg Kroah-Hartman
2021-02-18 13:37       ` Pavel Machek
2021-02-19  8:00         ` Uwe Kleine-König [this message]
2020-12-28 15:10 ` [PATCH v10 0/3] " Greg Kroah-Hartman

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=20210219080038.et46fcrha7ymw6b3@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=dmurphy@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jacek.anaszewski@gmail.com \
    --cc=johan@kernel.org \
    --cc=jslaby@suse.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /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).