From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-input <linux-input@vger.kernel.org>,
Linux Media Mailing List <linux-media@vger.kernel.org>,
Pavel Machek <pavel@ucw.cz>, Vojtech Pavlik <vojtech@suse.com>
Subject: Re: [RFC PATCH] serio: add hangup support
Date: Fri, 15 Jul 2016 09:31:19 -0700 [thread overview]
Message-ID: <20160715163119.GA27847@dtor-ws> (raw)
In-Reply-To: <287a7f88-5d45-bb45-c98e-22a2313ab780@xs4all.nl>
Hi Hans,
On Fri, Jul 15, 2016 at 01:27:21PM +0200, Hans Verkuil wrote:
> For the upcoming 4.8 kernel I made a driver for the Pulse-Eight USB CEC adapter.
> This is a usb device that shows up as a ttyACM0 device. It requires that you run
> inputattach in order to communicate with it via serio.
>
> This all works well, but it would be nice to have a udev rule to automatically
> start inputattach. That too works OK, but the problem comes when the USB device
> is unplugged: the tty hangup is never handled by the serio framework so the
> inputattach utility never exits and you have to kill it manually.
>
> By adding this hangup callback the inputattach utility now exists as soon as I
> unplug the USB device.
>
> Is this the correct approach?
>
> BTW, the new driver is found here:
>
> https://git.linuxtv.org/media_tree.git/tree/drivers/staging/media/pulse8-cec
>
> Regards,
>
> Hans
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
>
> ---
> diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
> index 9c927d3..a615846 100644
> --- a/drivers/input/serio/serport.c
> +++ b/drivers/input/serio/serport.c
> @@ -248,6 +248,14 @@ static long serport_ldisc_compat_ioctl(struct tty_struct *tty,
> }
> #endif
>
> +static int serport_ldisc_hangup(struct tty_struct * tty)
> +{
> + struct serport *serport = (struct serport *) tty->disc_data;
> +
> + serport_serio_close(serport->serio);
I see what you mean, but this is not quite correct. I think we should
make serport_serio_close() only reset the SERPORT_ACTIVE flag and have
serport_ldisc_hangup() actually do:
spin_lock_irqsave(&serport->lock, flags);
set_bit(SERPORT_DEAD, &serport->flags);
spin_unlock_irqrestore(&serport->lock, flags);
wake_up_interruptible(&serport->wait);
i.e. if user (via device-driver - input core - evdev - userspace chain)
stops using serio port we should not kill inputattach instance right
then and there, but wait for the serial port device disconnect or
something else killing inputattach.
Vojtech, do you recall any of this code?
Thanks.
--
Dmitry
next prev parent reply other threads:[~2016-07-15 16:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-15 11:27 [RFC PATCH] serio: add hangup support Hans Verkuil
2016-07-15 16:31 ` Dmitry Torokhov [this message]
2016-08-01 13:43 ` Hans Verkuil
2016-08-03 6:32 ` Dmitry Torokhov
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=20160715163119.GA27847@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-input@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=vojtech@suse.com \
/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