From c438cf82563a641fc78284ae6b5b38f03ddb21fb Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Tue, 31 Dec 2024 10:53:14 +0100 Subject: [PATCH] package/igh-ethercat: fix build of tty module with recent kernels Since commit eec3a1108a65ab8de4a313a7f34205c5d5ad8f2b ("package/igh-ethercat: add configuration options"), we are building more components of igh-ethercat, including the tty module, which fails to build with Linux kernels >= 6.6. This commit adds 3 patches, submitted upstream, that fix those build failures. Fixes: https://autobuild.buildroot.org/results/1bb799f4ae6140b67c4eb28c04aa45ccbd296b31/ Cc: Jannik Becher Signed-off-by: Thomas Petazzoni Signed-off-by: Julien Olivain --- ....c-mark-internal-functions-as-static.patch | 154 ++++++++++++++++++ ...-ec_tty_write-prototype-for-Linux-6..patch | 58 +++++++ ...-ec_tty_send_xchar-prototype-for-Lin.patch | 50 ++++++ 3 files changed, 262 insertions(+) create mode 100644 package/igh-ethercat/0001-tty-module.c-mark-internal-functions-as-static.patch create mode 100644 package/igh-ethercat/0002-tty-module.c-fix-ec_tty_write-prototype-for-Linux-6..patch create mode 100644 package/igh-ethercat/0003-tty-module.c-fix-ec_tty_send_xchar-prototype-for-Lin.patch diff --git a/package/igh-ethercat/0001-tty-module.c-mark-internal-functions-as-static.patch b/package/igh-ethercat/0001-tty-module.c-mark-internal-functions-as-static.patch new file mode 100644 index 0000000000..5d6dd6b9b6 --- /dev/null +++ b/package/igh-ethercat/0001-tty-module.c-mark-internal-functions-as-static.patch @@ -0,0 +1,154 @@ +From aed3ba0acb2c355be562cfbdb3a375682412c144 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Tue, 31 Dec 2024 10:28:41 +0100 +Subject: [PATCH] tty/module.c: mark internal functions as static +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Fixes: + +/home/autobuild/autobuild/instance-7/output-1/build/igh-ethercat-1.6.2/./tty/module.c:128:12: warning: no previous prototype for ‘ec_tty_init_module’ [-Wmissing-prototypes] + 128 | int __init ec_tty_init_module(void) + | ^~~~~~~~~~~~~~~~~~ +/home/autobuild/autobuild/instance-7/output-1/build/igh-ethercat-1.6.2/./tty/module.c:189:13: warning: no previous prototype for ‘ec_tty_cleanup_module’ [-Wmissing-prototypes] + 189 | void __exit ec_tty_cleanup_module(void) + | ^~~~~~~~~~~~~~~~~~~~~ +/home/autobuild/autobuild/instance-7/output-1/build/igh-ethercat-1.6.2/./tty/module.c:216:5: warning: no previous prototype for ‘ec_tty_init’ [-Wmissing-prototypes] + 216 | int ec_tty_init(ec_tty_t *t, int minor, + | ^~~~~~~~~~~ +/home/autobuild/autobuild/instance-7/output-1/build/igh-ethercat-1.6.2/./tty/module.c:293:6: warning: no previous prototype for ‘ec_tty_clear’ [-Wmissing-prototypes] + 293 | void ec_tty_clear(ec_tty_t *tty) + | ^~~~~~~~~~~~ +/home/autobuild/autobuild/instance-7/output-1/build/igh-ethercat-1.6.2/./tty/module.c:301:14: warning: no previous prototype for ‘ec_tty_tx_size’ [-Wmissing-prototypes] + 301 | unsigned int ec_tty_tx_size(ec_tty_t *tty) + | ^~~~~~~~~~~~~~ +/home/autobuild/autobuild/instance-7/output-1/build/igh-ethercat-1.6.2/./tty/module.c:316:14: warning: no previous prototype for ‘ec_tty_tx_space’ [-Wmissing-prototypes] + 316 | unsigned int ec_tty_tx_space(ec_tty_t *tty) + | ^~~~~~~~~~~~~~~ +/home/autobuild/autobuild/instance-7/output-1/build/igh-ethercat-1.6.2/./tty/module.c:323:14: warning: no previous prototype for ‘ec_tty_rx_size’ [-Wmissing-prototypes] + 323 | unsigned int ec_tty_rx_size(ec_tty_t *tty) + | ^~~~~~~~~~~~~~ +/home/autobuild/autobuild/instance-7/output-1/build/igh-ethercat-1.6.2/./tty/module.c:338:14: warning: no previous prototype for ‘ec_tty_rx_space’ [-Wmissing-prototypes] + 338 | unsigned int ec_tty_rx_space(ec_tty_t *tty) + | ^~~~~~~~~~~~~~~ +/home/autobuild/autobuild/instance-7/output-1/build/igh-ethercat-1.6.2/./tty/module.c:345:5: warning: no previous prototype for ‘ec_tty_get_serial_info’ [-Wmissing-prototypes] + 345 | int ec_tty_get_serial_info(ec_tty_t *tty, struct serial_struct *data) + | ^~~~~~~~~~~~~~~~~~~~~~ + +Signed-off-by: Thomas Petazzoni +Upstream: https://gitlab.com/etherlab.org/ethercat/-/merge_requests/150 +--- + tty/module.c | 26 +++++++++++++------------- + 1 file changed, 13 insertions(+), 13 deletions(-) + +diff --git a/tty/module.c b/tty/module.c +index 05486940..af4c1b70 100644 +--- a/tty/module.c ++++ b/tty/module.c +@@ -64,9 +64,9 @@ ec_tty_t *ttys[EC_TTY_MAX_DEVICES]; + struct semaphore tty_sem; + + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +-void ec_tty_wakeup(struct timer_list *); ++static void ec_tty_wakeup(struct timer_list *); + #else +-void ec_tty_wakeup(unsigned long); ++static void ec_tty_wakeup(unsigned long); + #endif + + /****************************************************************************/ +@@ -125,7 +125,7 @@ static const struct tty_operations ec_tty_ops; // see below + * + * \return 0 on success, else < 0 + */ +-int __init ec_tty_init_module(void) ++static int __init ec_tty_init_module(void) + { + int i, ret = 0; + unsigned flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; +@@ -186,7 +186,7 @@ out_return: + * + * Clears all master instances. + */ +-void __exit ec_tty_cleanup_module(void) ++static void __exit ec_tty_cleanup_module(void) + { + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0) + int i; +@@ -213,7 +213,7 @@ void __exit ec_tty_cleanup_module(void) + * ec_tty_t methods. + ****************************************************************************/ + +-int ec_tty_init(ec_tty_t *t, int minor, ++static int ec_tty_init(ec_tty_t *t, int minor, + const ec_tty_operations_t *ops, void *cb_data) + { + int ret; +@@ -290,7 +290,7 @@ int ec_tty_init(ec_tty_t *t, int minor, + + /****************************************************************************/ + +-void ec_tty_clear(ec_tty_t *tty) ++static void ec_tty_clear(ec_tty_t *tty) + { + del_timer_sync(&tty->timer); + tty_unregister_device(tty_driver, tty->minor); +@@ -298,7 +298,7 @@ void ec_tty_clear(ec_tty_t *tty) + + /****************************************************************************/ + +-unsigned int ec_tty_tx_size(ec_tty_t *tty) ++static unsigned int ec_tty_tx_size(ec_tty_t *tty) + { + unsigned int ret; + +@@ -313,14 +313,14 @@ unsigned int ec_tty_tx_size(ec_tty_t *tty) + + /****************************************************************************/ + +-unsigned int ec_tty_tx_space(ec_tty_t *tty) ++static unsigned int ec_tty_tx_space(ec_tty_t *tty) + { + return EC_TTY_TX_BUFFER_SIZE - 1 - ec_tty_tx_size(tty); + } + + /****************************************************************************/ + +-unsigned int ec_tty_rx_size(ec_tty_t *tty) ++static unsigned int ec_tty_rx_size(ec_tty_t *tty) + { + unsigned int ret; + +@@ -335,14 +335,14 @@ unsigned int ec_tty_rx_size(ec_tty_t *tty) + + /****************************************************************************/ + +-unsigned int ec_tty_rx_space(ec_tty_t *tty) ++static unsigned int ec_tty_rx_space(ec_tty_t *tty) + { + return EC_TTY_RX_BUFFER_SIZE - 1 - ec_tty_rx_size(tty); + } + + /****************************************************************************/ + +-int ec_tty_get_serial_info(ec_tty_t *tty, struct serial_struct *data) ++static int ec_tty_get_serial_info(ec_tty_t *tty, struct serial_struct *data) + { + struct serial_struct tmp; + +@@ -362,9 +362,9 @@ int ec_tty_get_serial_info(ec_tty_t *tty, struct serial_struct *data) + /** Timer function. + */ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +-void ec_tty_wakeup(struct timer_list *t) ++static void ec_tty_wakeup(struct timer_list *t) + #else +-void ec_tty_wakeup(unsigned long data) ++static void ec_tty_wakeup(unsigned long data) + #endif + { + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +-- +2.47.1 + diff --git a/package/igh-ethercat/0002-tty-module.c-fix-ec_tty_write-prototype-for-Linux-6..patch b/package/igh-ethercat/0002-tty-module.c-fix-ec_tty_write-prototype-for-Linux-6..patch new file mode 100644 index 0000000000..78a444715e --- /dev/null +++ b/package/igh-ethercat/0002-tty-module.c-fix-ec_tty_write-prototype-for-Linux-6..patch @@ -0,0 +1,58 @@ +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 +Upstream: https://gitlab.com/etherlab.org/ethercat/-/merge_requests/150 +--- + 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; +-- +2.47.1 + diff --git a/package/igh-ethercat/0003-tty-module.c-fix-ec_tty_send_xchar-prototype-for-Lin.patch b/package/igh-ethercat/0003-tty-module.c-fix-ec_tty_send_xchar-prototype-for-Lin.patch new file mode 100644 index 0000000000..62662ee103 --- /dev/null +++ b/package/igh-ethercat/0003-tty-module.c-fix-ec_tty_send_xchar-prototype-for-Lin.patch @@ -0,0 +1,50 @@ +From 2824232792364140569d522627b48a64e5d3a690 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Tue, 31 Dec 2024 10:38:03 +0100 +Subject: [PATCH] tty/module.c: fix ec_tty_send_xchar() prototype for Linux >= + 6.8 + +In upstream Linux kernel commit: + 3a00da027946cd08db1c1be2de4620950bbdf074 ("tty: make tty_operations::send_xchar accept u8 char") + +The prototype of tty_operations->send_xchar() was changed from: + + void (*send_xchar)(struct tty_struct *tty, char ch); + +to: + + void (*send_xchar)(struct tty_struct *tty, u8 ch); + +This commit was merged in Linux 6.8, and therefore the +ec_tty_send_xchar() implementation needs to be changed to avoid the +following build failure: + +/home/autobuild/autobuild/instance-7/output-1/build/igh-ethercat-1.6.2/./tty/module.c:751:19: error: initialization of "void (*)(struct tty_struct *, u8)" {aka "void (*)(struct tty_struct *, unsigned char)"} from incompatible pointer type "void (*)(struct tty_struct *, char)" [-Werror=incompatible-pointer-types] + 751 | .send_xchar = ec_tty_send_xchar, + | ^~~~~~~~~~~~~~~~~ + +Signed-off-by: Thomas Petazzoni +Upstream: https://gitlab.com/etherlab.org/ethercat/-/merge_requests/150 +--- + tty/module.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/tty/module.c b/tty/module.c +index 354ddfd6..2b7b22bb 100644 +--- a/tty/module.c ++++ b/tty/module.c +@@ -724,7 +724,11 @@ static int ec_tty_break(struct tty_struct *tty, int break_state) + + /****************************************************************************/ + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 8, 0) ++static void ec_tty_send_xchar(struct tty_struct *tty, u8 ch) ++#else + static void ec_tty_send_xchar(struct tty_struct *tty, char ch) ++#endif + { + #if EC_TTY_DEBUG >= 2 + printk(KERN_INFO PFX "%s(ch=%02x).\n", __func__, (unsigned int) ch); +-- +2.47.1 +