From 53d085824dd07bc07958a4d055cf071f4d613942 Mon Sep 17 00:00:00 2001 From: Roi L Date: Thu, 20 Apr 2023 22:53:41 +0300 Subject: [PATCH] tty: support for newer kernels Some functions and data structures' names have been modified in recent kernels, make it compatible. Signed-off-by: Roi L --- tty/tiny_serial.c | 7 ++++++- tty/tiny_tty.c | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/tty/tiny_serial.c b/tty/tiny_serial.c index e81defe0b..7d4559b2f 100644 --- a/tty/tiny_serial.c +++ b/tty/tiny_serial.c @@ -142,8 +142,13 @@ static void tiny_break_ctl(struct uart_port *port, int break_state) { } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) +static void tiny_set_termios(struct uart_port *port, + struct ktermios *new, const struct ktermios *old) +#else static void tiny_set_termios(struct uart_port *port, struct ktermios *new, struct ktermios *old) +#endif { int baud, quot, cflag = new->c_cflag; /* get the byte size */ @@ -186,7 +191,7 @@ static void tiny_set_termios(struct uart_port *port, /* Set baud rate */ baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16); quot = uart_get_divisor(port, baud); - + //UART_PUT_DIV_LO(port, (quot & 0xff)); //UART_PUT_DIV_HI(port, ((quot & 0xf00) >> 8)); } diff --git a/tty/tiny_tty.c b/tty/tiny_tty.c index 8705634e9..51c775a37 100644 --- a/tty/tiny_tty.c +++ b/tty/tiny_tty.c @@ -194,7 +194,7 @@ static int tiny_write(struct tty_struct *tty, return retval; } -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)) +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)) static int tiny_write_room(struct tty_struct *tty) #else static unsigned int tiny_write_room(struct tty_struct *tty) @@ -223,7 +223,11 @@ static unsigned int tiny_write_room(struct tty_struct *tty) #define RELEVANT_IFLAG(iflag) ((iflag) & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) +static void tiny_set_termios(struct tty_struct *tty, const struct ktermios *old_termios) +#else static void tiny_set_termios(struct tty_struct *tty, struct ktermios *old_termios) +#endif { unsigned int cflag; @@ -511,7 +515,11 @@ static int __init tiny_init(void) int i; /* allocate the tty driver */ - tiny_tty_driver = alloc_tty_driver(TINY_TTY_MINORS); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) + tiny_tty_driver = tty_alloc_driver(TINY_TTY_MINORS, 0); +#else + tiny_tty_driver = alloc_tty_driver(TINY_TTY_MINORS); +#endif if (!tiny_tty_driver) return -ENOMEM; @@ -535,7 +543,11 @@ static int __init tiny_init(void) retval = tty_register_driver(tiny_tty_driver); if (retval) { pr_err("failed to register tiny tty driver"); - put_tty_driver(tiny_tty_driver); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) + tty_driver_kref_put(tiny_tty_driver); +#else + put_tty_driver(tiny_tty_driver); +#endif return retval; }