linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <jhovold@gmail.com>
To: Peter Hurley <peter@hurleysoftware.com>
Cc: Johan Hovold <jhovold@gmail.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	Chris Ruehl <chris.ruehl@gtsys.com.hk>,
	Alan Stern <stern@rowland.harvard.edu>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	linux-usb@vger.kernel.org, linux-serial@vger.kernel.org,
	Alan Cox <alan@linux.intel.com>
Subject: Re: [RFC 3/4] tty: clean up port drain-delay handling
Date: Thu, 14 Feb 2013 10:12:06 +0100	[thread overview]
Message-ID: <20130214091206.GB2130@localhost> (raw)
In-Reply-To: <1360805971.3385.27.camel@thor.lan>

On Wed, Feb 13, 2013 at 08:39:31PM -0500, Peter Hurley wrote:
> On Wed, 2013-02-13 at 18:27 +0100, Johan Hovold wrote:
> > Move port drain-delay handling to a separate function.
> > ---
> >  drivers/tty/tty_port.c | 29 ++++++++++++++++++-----------
> >  1 file changed, 18 insertions(+), 11 deletions(-)
> > 
> > diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
> > index ffe3689..0a5e955 100644
> > --- a/drivers/tty/tty_port.c
> > +++ b/drivers/tty/tty_port.c
> > @@ -407,6 +407,23 @@ int tty_port_block_til_ready(struct tty_port *port,
> >  }
> >  EXPORT_SYMBOL(tty_port_block_til_ready);
> >  
> > +static void tty_port_drain_delay(struct tty_port *port, struct tty_struct *tty)
> > +{
> > +	unsigned int bps = tty_get_baud_rate(tty);
> > +	long timeout;
> 
> 
> > +	if (!port->drain_delay)
> > +		return;
>                ^^^^^^^^^^^^
> How about drop this and ...
> 
> > +	if (bps > 1200) {
> > +		timeout = (HZ * 10 * port->drain_delay) / bps;
> > +		timeout = max_t(long, timeout, HZ / 10);
> > +	} else {
> > +		timeout = 2 * HZ;
> > +	}
> > +	schedule_timeout_interruptible(timeout);
> > +}
> > +
> >  int tty_port_close_start(struct tty_port *port,
> >  				struct tty_struct *tty, struct file *filp)
> >  {
> > @@ -445,17 +462,7 @@ int tty_port_close_start(struct tty_port *port,
> >  	if (test_bit(ASYNCB_INITIALIZED, &port->flags) &&
> >  			port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
> >  		tty_wait_until_sent_from_close(tty, port->closing_wait);
> > -	if (port->drain_delay) {
> > -		unsigned int bps = tty_get_baud_rate(tty);
> > -		long timeout;
> > -
> > -		if (bps > 1200)
> > -			timeout = max_t(long,
> > -				(HZ * 10 * port->drain_delay) / bps, HZ / 10);
> > -		else
> > -			timeout = 2 * HZ;
> > -		schedule_timeout_interruptible(timeout);
> > -	}
> > +	tty_port_drain_delay(port, tty);
> 
> ....
> 	if (port->drain_delay)
> 		tty_port_drain_delay(port, tty);

Yeah, I agree. Checking at the call site would perhaps be more clear in
this case.

Thanks,
Johan

  reply	other threads:[~2013-02-14  9:13 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <510B2C09.7020700@gtsys.com.hk>
2013-02-13 14:25 ` USB Ooops PL2303 when unplug while use (linux v3.7.3) Johan Hovold
2013-02-13 14:28   ` [PATCH] USB: serial: fix null-pointer dereferences on disconnect Johan Hovold
     [not found]     ` <1360765731-23164-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-13 14:34       ` Felipe Balbi
2013-02-13 14:48         ` Johan Hovold
2013-02-13 16:41     ` Greg KH
2013-02-13 16:53       ` [PATCH resend] " Johan Hovold
2013-02-13 17:27   ` [RFC 0/4] tty: port hangup and close issues Johan Hovold
2013-02-13 17:27     ` [RFC 1/4] tty: clean up port shutdown Johan Hovold
2013-02-13 17:27     ` [RFC 2/4] tty: fix DTR/RTS not being dropped on hang up Johan Hovold
     [not found]       ` <1360776446-31371-3-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-13 18:06         ` [RFC v2 " Johan Hovold
2013-02-13 19:32         ` [RFC " Peter Hurley
     [not found]           ` <1360783973.8499.48.camel-AsKIXgLx6sE@public.gmane.org>
2013-02-14  1:11             ` Peter Hurley
     [not found]               ` <1360804273.3385.23.camel-AsKIXgLx6sE@public.gmane.org>
2013-02-14  9:04                 ` Johan Hovold
2013-02-13 17:27     ` [RFC 3/4] tty: clean up port drain-delay handling Johan Hovold
2013-02-14  1:39       ` Peter Hurley
2013-02-14  9:12         ` Johan Hovold [this message]
2013-02-13 17:27     ` [RFC 4/4] tty: fix close of uninitialised ports Johan Hovold
2013-02-13 17:36     ` [RFC 0/4] tty: port hangup and close issues Alan Cox
     [not found]       ` <20130213173630.63e29b47-+KEw/ACL1GZE/aiTQr5FLb0Ud+EcFu5g@public.gmane.org>
2013-02-13 18:05         ` Johan Hovold
     [not found]     ` <1360776446-31371-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-20 16:02       ` [PATCH 0/4] TTY: port hangup and close fixes Johan Hovold
2013-02-20 16:02         ` [PATCH 1/4] TTY: clean up port shutdown Johan Hovold
2013-02-20 16:02         ` [PATCH 2/4] TTY: fix DTR not being dropped on hang up Johan Hovold
2013-02-23 14:18           ` Peter Hurley
2013-02-26 10:59             ` Johan Hovold
2013-02-20 16:02         ` [PATCH 3/4] TTY: clean up port drain-delay handling Johan Hovold
     [not found]         ` <1361376172-31860-1-git-send-email-jhovold-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-02-20 16:02           ` [PATCH 4/4] TTY: fix close of uninitialised ports Johan Hovold
2013-02-21  1:53         ` [PATCH 0/4] TTY: port hangup and close fixes Peter Hurley
2013-02-13 18:40   ` USB Ooops PL2303 when unplug while use (linux v3.7.3) Peter Hurley
     [not found]     ` <1360780808.8499.43.camel-AsKIXgLx6sE@public.gmane.org>
2013-02-14 17:43       ` Johan Hovold
2013-02-22 10:03         ` USB: serial: port lifetimes (was: Re: USB Ooops PL2303 when unplug while use (linux v3.7.3)) Johan Hovold
2013-02-22 15:17           ` Alan Stern
2013-02-22 17:11             ` Johan Hovold
2013-02-22 17:35               ` Alan Stern
     [not found]                 ` <Pine.LNX.4.44L0.1302221218270.1365-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2013-02-22 17:44                   ` Greg KH
2013-02-22 18:21                 ` Peter Hurley
     [not found]                   ` <1361557284.5752.25.camel-AsKIXgLx6sE@public.gmane.org>
2013-02-22 18:57                     ` Alan Stern
2013-02-23 16:05                     ` Johan Hovold
2013-02-23 16:23                 ` Johan Hovold
2013-02-23 16:34                   ` Johan Hovold
2013-02-23 17:31                   ` Alan Stern
2013-02-23 18:12                     ` Johan Hovold
2013-02-23 21:20                       ` Alan Stern

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=20130214091206.GB2130@localhost \
    --to=jhovold@gmail.com \
    --cc=alan@linux.intel.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=chris.ruehl@gtsys.com.hk \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter@hurleysoftware.com \
    --cc=stern@rowland.harvard.edu \
    /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).