3 The 5.14 kernel reworked the tty register and unregister call
4 arguments, and made one of the arguments to the receive_buf
5 callback const, add some kernel version conditionals to handle
8 Upstream-Status: Inappropriate [no upstream]
9 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
12 sllin/sllin.c | 29 ++++++++++++++++++++++++-----
13 1 file changed, 24 insertions(+), 5 deletions(-)
15 diff --git a/sllin/sllin.c b/sllin/sllin.c
16 index 904cff9..b89d06d 100644
20 #include <linux/version.h>
21 #include "linux/lin_bus.h"
23 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0)
24 +#define FP_CONST const
29 /* Should be in include/linux/tty.h */
31 /* -------------------------------- */
32 @@ -185,9 +191,9 @@ struct sllin {
33 static struct net_device **sllin_devs;
34 static int sllin_configure_frame_cache(struct sllin *sl, struct can_frame *cf);
35 static void sllin_slave_receive_buf(struct tty_struct *tty,
36 - const unsigned char *cp, char *fp, int count);
37 + const unsigned char *cp, FP_CONST char *fp, int count);
38 static void sllin_master_receive_buf(struct tty_struct *tty,
39 - const unsigned char *cp, char *fp, int count);
40 + const unsigned char *cp, FP_CONST char *fp, int count);
43 /* Values of two parity bits in LIN Protected
44 @@ -492,7 +498,7 @@ static void sll_setup(struct net_device *dev)
45 Routines looking at TTY side.
46 ******************************************/
47 static void sllin_master_receive_buf(struct tty_struct *tty,
48 - const unsigned char *cp, char *fp, int count)
49 + const unsigned char *cp, FP_CONST char *fp, int count)
51 struct sllin *sl = (struct sllin *) tty->disc_data;
53 @@ -735,7 +741,7 @@ static void sllin_slave_finish_rx_msg(struct sllin *sl)
56 static void sllin_slave_receive_buf(struct tty_struct *tty,
57 - const unsigned char *cp, char *fp, int count)
58 + const unsigned char *cp, FP_CONST char *fp, int count)
60 struct sllin *sl = (struct sllin *) tty->disc_data;
62 @@ -842,7 +848,7 @@ static void sllin_slave_receive_buf(struct tty_struct *tty,
65 static void sllin_receive_buf(struct tty_struct *tty,
66 - const unsigned char *cp, char *fp, int count)
67 + const unsigned char *cp, FP_CONST char *fp, int count)
69 struct sllin *sl = (struct sllin *) tty->disc_data;
70 netdev_dbg(sl->dev, "sllin_receive_buf invoked, count = %u\n", count);
71 @@ -1619,6 +1625,9 @@ static int sllin_ioctl(struct tty_struct *tty, struct file *file,
73 static struct tty_ldisc_ops sll_ldisc = {
75 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0)
78 #if LINUX_VERSION_CODE < KERNEL_VERSION(5,13,0)
79 .magic = TTY_LDISC_MAGIC,
81 @@ -1648,7 +1657,11 @@ static int __init sllin_init(void)
84 /* Fill in our line protocol discipline, and register it */
85 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0)
86 + status = tty_register_ldisc(&sll_ldisc);
88 status = tty_register_ldisc(N_SLLIN, &sll_ldisc);
91 pr_err("sllin: can't register line discipline\n");
93 @@ -1719,9 +1732,15 @@ static void __exit sllin_exit(void)
97 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0)
98 + tty_unregister_ldisc(&sll_ldisc);
101 i = tty_unregister_ldisc(N_SLLIN);
104 pr_err("sllin: can't unregister ldisc (err %d)\n", i);
108 module_init(sllin_init);