Re: [PATCH 1/2] tty: Add lookahead param to receive_buf

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

 



On Tue, Apr 05, 2022 at 01:24:36PM +0300, Ilpo Järvinen wrote:
> After lookahead for XON/XOFF characters is added by the next
> patch, the receive side needs to ensure the flow-control
> actions are not retaken later on when those same characters
> get read by TTY.
> 
> Thus, pass lookahead count to receive_buf and skip
> flow-control character actions if already taken for the
> character in question. Lookahead count will become live after
> the next patch.

...

> -static void n_tty_receive_char_special(struct tty_struct *tty, unsigned char c)
> +static void n_tty_receive_char_special(struct tty_struct *tty, unsigned char c,
> +				       bool lookahead_done)
>  {
>  	struct n_tty_data *ldata = tty->disc_data;
>  
>  	if (I_IXON(tty)) {
>  		if (c == START_CHAR(tty)) {
> -			start_tty(tty);
> -			process_echoes(tty);
> +			if (!lookahead_done) {
> +				start_tty(tty);
> +				process_echoes(tty);
> +			}
>  			return;
>  		}
>  		if (c == STOP_CHAR(tty)) {
> -			stop_tty(tty);
> +			if (!lookahead_done)
> +				stop_tty(tty);
>  			return;
>  		}

Wouldn't be cleaner to inside out the conditionals?

>  	}

	if (I_IXON(tty)) {
		if (lookahead_done) {
			// Can be joined, but I think this is better
			if (c == START_CHAR(tty))
				return;
			if (c == STOP_CHAR(tty))
				return;
		} else {
			if (c == START_CHAR(tty)) {
				start_tty(tty);
				process_echoes(tty);
				return;
			}
			if (c == STOP_CHAR(tty)) {
				stop_tty(tty);
				return;
			}
		}
	}

In my opinion this will show exactly what's going on when we have
lookahead_done and when not.

-- 
With Best Regards,
Andy Shevchenko





[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