[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210218133733.GB12948@duo.ucw.cz>
Date: Thu, 18 Feb 2021 14:37:33 +0100
From: Pavel Machek <pavel@....cz>
To: Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel@...r.kernel.org, Johan Hovold <johan@...nel.org>,
Jacek Anaszewski <jacek.anaszewski@...il.com>,
linux-serial@...r.kernel.org, Jiri Slaby <jslaby@...e.com>,
kernel@...gutronix.de, linux-leds@...r.kernel.org,
Dan Murphy <dmurphy@...com>
Subject: Re: [PATCH v11] leds: trigger: implement a tty trigger
Hi!
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);
> +
> + 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.
> + if (icount.rx != trigger_data->rx ||
> + icount.tx != trigger_data->tx) {
> + led_set_brightness(trigger_data->led_cdev, LED_ON);
Please use _sync version.
Best regards,
Pavel
--
http://www.livejournal.com/~pavelmachek
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists