Re: [PATCH v6 4/4] leds: trigger: implement a tty trigger

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 19, 2020 at 12:03:06PM +0100, Uwe Kleine-König wrote:
> On Wed, Feb 19, 2020 at 11:52:39AM +0100, Johan Hovold wrote:
> > On Thu, Feb 13, 2020 at 10:16:00AM +0100, Uwe Kleine-König wrote:
> > > From: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
> > > 
> > > Usage is as follows:
> > > 
> > > 	myled=ledname
> > > 	tty=ttyS0
> > > 
> > > 	echo tty > /sys/class/leds/$myled/trigger
> > > 	cat /sys/class/tty/$tty/dev > /sys/class/leds/$myled/dev
> > > 
> > > . When this new trigger is active it periodically checks the tty's
> > > statistics and when it changed since the last check the led is flashed
> > > once.
> > > 
> > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
> > > ---
> > 
> > > +static ssize_t dev_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);
> > > +	struct tty_struct *tty;
> > > +	dev_t d;
> > > +	int ret;
> > > +
> > > +	if (size == 0 || (size == 1 && buf[0] == '\n')) {
> > > +		tty = NULL;
> > > +	} else {
> > > +		ret = kstrtodev_t(buf, &d);
> > > +		if (ret < 0)
> > > +			return ret;
> > > +
> > > +		tty = tty_kopen_shared(d);
> > 
> > I really don't have time to look at this, but having the led-trigger
> > keep the port open looks fundamentally broken (consider modem-control
> > signals, power, etc).
> 
> If I understand correctly calling tty_kopen_shared() doesn't open the
> device, just keep it referenced which prevents it to disappear. Unless I
> miss something it doesn't result in the tty's .open() being called.

So tty_kopen_shared() is something you added. Judging from a quick look
it seems you can only attach a trigger to an already open port, but the
trigger will then keep the port open (again, consider modem control,
power).

I'm sorry I don't have time to review this myself, but this probably
needs some more eyes on it before being merged.

Johan



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux