[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <769b1be-87c3-e1c1-b1f9-d56a74ff549@linux.intel.com>
Date: Tue, 26 Apr 2022 10:48:40 +0300 (EEST)
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: Greg KH <gregkh@...uxfoundation.org>
cc: linux-serial <linux-serial@...r.kernel.org>,
Jiri Slaby <jirislaby@...nel.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
LKML <linux-kernel@...r.kernel.org>,
Gilles Buloz <gilles.buloz@...tron.com>,
Johan Hovold <johan@...nel.org>
Subject: Re: [PATCH v3 3/5] tty: Add lookahead param to receive_buf
On Fri, 22 Apr 2022, Ilpo Järvinen wrote:
> On Fri, 22 Apr 2022, Greg KH wrote:
>
> > > /* Returns true if c is consumed as flow-control character */
> > > -static bool n_tty_receive_char_flow_ctrl(struct tty_struct *tty, unsigned char c)
> > > +static bool n_tty_receive_char_flow_ctrl(struct tty_struct *tty, unsigned char c,
> > > + bool lookahead_done)
> > > {
> > > if (!n_tty_is_char_flow_ctrl(tty, c))
> > > return false;
> > >
> > > + if (lookahead_done)
> > > + return true;
> >
> > Why would this function be called if this option was true?
>
> Agreed, it makes sense to move the check before call (and then I also
> don't need to reorganize this function anymore).
I think I want to renege on this. The reason is that on flow control char,
two things must occur:
a) it must not be treated as normal char
b) if not yet processed, flow control actions need to be taken
When the check is inside, return value of n_tty_receive_char_flow_ctrl
decides a), and b) is kept internal to n_tty_receive_char_flow_ctrl().
If I more that lookahead_done check into the caller domain, things get
IMHO a lot more messy. Effectively, I have three options for the calling
domain to chose from:
if (I_IXON(tty)) {
if (!lookahead_done) {
if (n_tty_receive_char_flow_ctrl(tty, c))
return;
} else if (n_tty_is_char_flow_ctrl(tty, c)) {
return;
}
}
or
if (I_IXON(tty)) {
if ((!lookahead_done && n_tty_receive_char_flow_ctrl(tty, c)) ||
(lookahead_done && n_tty_is_char_flow_ctrl(tty, c))) {
return;
}
vs
if (I_IXON(tty) && n_tty_receive_char_flow_ctrl(tty, c, lookahead_done))
return;
I heavily prefer that last option.
--
i.
Powered by blists - more mailing lists