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

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

 



On Wed, 6 Apr 2022, Jiri Slaby wrote:

> On 05. 04. 22, 12:24, 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.
> ...
> > --- a/include/linux/tty_ldisc.h
> > +++ b/include/linux/tty_ldisc.h
> > @@ -224,11 +224,11 @@ struct tty_ldisc_ops {
> >   	 * The following routines are called from below.
> >   	 */
> >   	void	(*receive_buf)(struct tty_struct *tty, const unsigned char
> > *cp,
> > -			       const char *fp, int count);
> > +			       const char *fp, int count, int
> > lookahead_count);
> >   	void	(*write_wakeup)(struct tty_struct *tty);
> >   	void	(*dcd_change)(struct tty_struct *tty, unsigned int status);
> >   	int	(*receive_buf2)(struct tty_struct *tty, const unsigned char
> > *cp,
> > -				const char *fp, int count);
> > +				const char *fp, int count, int
> > lookahead_count);
> 
> Please always use unsigned if you don't expect negative numbers. count should
> be changed to unsigned in long term too.

Ok. I had just used the same types as there were previously. The types are 
a big mess, int and size_t conversions being done back and forth within 
that callchain for count. And now that you mentioned unsigned it 
seems that fp (flag ptr) is also inconsistent.

> > diff --git a/include/linux/tty_port.h b/include/linux/tty_port.h
> > index 58e9619116b7..1871a6a9cb00 100644
> > --- a/include/linux/tty_port.h
> > +++ b/include/linux/tty_port.h
> > @@ -39,7 +39,7 @@ struct tty_port_operations {
> >   };
> >     struct tty_port_client_operations {
> > -	int (*receive_buf)(struct tty_port *port, const unsigned char *, const
> > unsigned char *, size_t);
> > +	int (*receive_buf)(struct tty_port *port, const unsigned char *, const
> > unsigned char *, size_t, size_t);
> 
> Good, here it is unsigned and even of size_t size (I don't immediately see
> why, but OK).

You mean that the flag ptr is now unsigned char * (which I didn't even 
touch)?

Your comment leaves me to wonder though, what you now want for the 
lookahead count (the last arg), size_t or unsigned int? Lookahead count 
cannot be negative, and AFAICT, count neither because that would mean tty 
has to return some characters back :-).

...Maybe I'll do another patch post these fix ones to match/correct the 
types.

-- 
 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