From 27175946c4ea55a426cdcdc1278a7d7c433d2a57 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Tue, 31 Dec 2024 10:35:38 +0100 Subject: [PATCH] tty/module.c: fix ec_tty_write() prototype for Linux >= 6.6 In upstream Linux kernel commits: 95713967ba52389f7cea75704d0cf048080ec218 ("tty: make tty_operations::write()'s count size_t") 69851e4ab8feeb369119a44ddca430c0ee15f0d8 ("tty: propagate u8 data to tty_operations::write()") The prototype of tty_operations->write() was changed from: int (*write)(struct tty_struct * tty, const unsigned char *buf, int count); to: ssize_t (*write)(struct tty_struct *tty, const u8 *buf, size_t count); Both of those commits were merged in Linux 6.6, and this needs an update in tty/module.c to avoid the following build failure: /home/autobuild/autobuild/instance-7/output-1/build/igh-ethercat-1.6.2/./tty/module.c:740:14: error: initialization of "ssize_t (*)(struct tty_struct *, const u8 *, size_t)" {aka "long int (*)(struct tty_struct *, const unsigned char *, long unsigned int)"} from incompatible pointer type "int (*)(struct tty_struct *, const unsigned char *, int)" [-Werror=incompatible-pointer-types] 740 | .write = ec_tty_write, | ^~~~~~~~~~~~ Signed-off-by: Thomas Petazzoni --- tty/module.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tty/module.c b/tty/module.c index af4c1b70..354ddfd6 100644 --- a/tty/module.c +++ b/tty/module.c @@ -488,11 +488,19 @@ static void ec_tty_close(struct tty_struct *tty, struct file *file) /****************************************************************************/ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0) +static ssize_t ec_tty_write( + struct tty_struct *tty, + const u8 *buffer, + size_t count + ) +#else static int ec_tty_write( struct tty_struct *tty, const unsigned char *buffer, int count ) +#endif { ec_tty_t *t = (ec_tty_t *) tty->driver_data; unsigned int data_size, i;