All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kyösti Mälkki" <kyosti.malkki@gmail.com>
To: balbi@ti.com
Cc: linux-usb@vger.kernel.org, Greg KH <gregkh@linuxfoundation.org>,
	linux-serial@vger.kernel.org
Subject: Re: [PATCH 2/2] usb: gadget serial: Honour termios CLOCAL on disconnect
Date: Mon, 27 Oct 2014 17:43:06 +0200	[thread overview]
Message-ID: <544E680A.9010700@gmail.com> (raw)
In-Reply-To: <20141027133837.GC8537@saruman>

On 10/27/2014 03:38 PM, Felipe Balbi wrote:
> Hi,
>
> On Sun, Oct 26, 2014 at 08:01:30PM +0200, Kyösti Mälkki wrote:
>> There are applications where it is desirable to not hangup ttyGS* when
>> USB disconnect is detected. USB host side of communication may
>> power-cycle periodically or there may be the actual need to physically
>> disconnect and reconnect USB cable temporarily.
>>
>> USB disconnects on serial gadget are comparable to loss of Carrier Detect
>> of conventional UARTs. With the change, if ttyGS* has termios CLOCAL flag
>> set, disconnect on USB does not hangup the TTY.
>>
>> Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
>> ---
>>   drivers/usb/gadget/function/u_serial.c | 9 +++++++--
>>   1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c
>> index 491082a..e68ffd7 100644
>> --- a/drivers/usb/gadget/function/u_serial.c
>> +++ b/drivers/usb/gadget/function/u_serial.c
>> @@ -1254,8 +1254,13 @@ void gserial_disconnect(struct gserial *gser)
>>   	gser->ioport = NULL;
>>   	if (port->port.count > 0 || port->openclose) {
>>   		wake_up_interruptible(&port->drain_wait);
>> -		if (port->port.tty)
>> -			tty_hangup(port->port.tty);
>> +		struct tty_struct *tty = port->port.tty;
>
> declare above as Sergei said.
>
>> +		if (tty) {
>
> is there any situation where tty would be NULL here ?
>
>> +			if (tty->termios.c_cflag & CLOCAL)
>> +				stop_tty(tty);
>> +			else
>> +				tty_hangup(tty);
>
> this I'll defer to Greg who also maintains tty.
>

My main concern is if someone runs getty on ttyACM without explicitly 
clearing CLOCAL. With the patch here login session would no longer get 
SIGHUP if cable is disconnected. And it is not possible to tell if it is 
the same cable that is plugged back in.

KM




--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-10-27 15:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1414346490-19307-1-git-send-email-kyosti.malkki@gmail.com>
     [not found] ` <1414346490-19307-3-git-send-email-kyosti.malkki@gmail.com>
     [not found]   ` <1414346490-19307-3-git-send-email-kyosti.malkki-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-27 13:38     ` [PATCH 2/2] usb: gadget serial: Honour termios CLOCAL on disconnect Felipe Balbi
2014-10-27 15:43       ` Kyösti Mälkki [this message]
     [not found]         ` <544E680A.9010700-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-10-27 15:46           ` Felipe Balbi
2014-10-27 17:11       ` Peter Hurley
2014-11-03 15:18 ` usb: gadget: Fixes to receive from USB EHCI Debug Kyösti Mälkki
     [not found]   ` <1415027885-2181-1-git-send-email-kyosti.malkki-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-11-03 15:18     ` [PATCH v2 1/2] usb: gadget dbgp: Fix endpoint config after USB disconnect Kyösti Mälkki
     [not found]       ` <1415027885-2181-2-git-send-email-kyosti.malkki-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-11-07 18:04         ` Felipe Balbi
2014-11-03 15:18     ` [PATCH v2 2/2] usb: gadget serial: Honour termios CLOCAL on disconnect Kyösti Mälkki
     [not found]       ` <1415027885-2181-3-git-send-email-kyosti.malkki-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-11-03 15:33         ` Peter Hurley
     [not found]           ` <5457A062.50306-WaGBZJeGNqdsbIuE7sb01tBPR1lH4CV8@public.gmane.org>
2014-11-03 23:49             ` Kyösti Mälkki

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=544E680A.9010700@gmail.com \
    --to=kyosti.malkki@gmail.com \
    --cc=balbi@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.