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

From: Jiri Slaby
Date: Wed Apr 06 2022 - 07:25:55 EST


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.

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

thanks,
--
js
suse labs