Re: [PATCH v3 3/5] tty: Add lookahead param to receive_buf

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

 



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.

[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