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 <thomas.petazzoni@bootlin.com>
This commit is contained in:
Thomas Petazzoni
2024-12-31 10:35:38 +01:00
parent aed3ba0acb
commit 27175946c4

View File

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