From f8dc448081790acb916574fd969fb0976dc29e89 Mon Sep 17 00:00:00 2001 From: Florin Sarbu Date: Wed, 7 Jul 2021 15:43:46 +0200 Subject: [PATCH 1/9] unipi_tty: Fix compile on kernel 5.10 We adapt to changes introduced by https://lore.kernel.org/lkml/20210121090020.3147058-2-gregkh@linuxfoundation.org/ Upstream-Status: Pending Signed-off-by: Florin Sarbu --- modules/unipi/src/unipi_tty.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/unipi/src/unipi_tty.c b/modules/unipi/src/unipi_tty.c index 76c0184..3d2ea83 100644 --- a/modules/unipi/src/unipi_tty.c +++ b/modules/unipi/src/unipi_tty.c @@ -662,7 +662,12 @@ static int copy_from_read_buf(struct tty_struct *tty, */ static ssize_t unipi_tty_read(struct tty_struct *tty, struct file *file, +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) unsigned char __user *buf, size_t nr) +#else + unsigned char *buf, size_t nr, + void **cookie, unsigned long offset) +#endif { struct unipi_tty_data *ldata = tty->disc_data; struct tty_port *port = tty->port; From 134b57ca49c245ee19c7b395e19a2195006d3bdd Mon Sep 17 00:00:00 2001 From: Alex Gonzalez Date: Mon, 24 Oct 2022 16:07:36 +0200 Subject: [PATCH 2/9] unipi_spi: use new structure for SPI transfer delays In a change to the SPI subsystem [1], a new `delay` struct was added to replace the `delay_usecs`. This change replaces the current `delay_usecs` with `delay` for this driver. [1] commit bebcfd272df6 ("spi: introduce `delay` field for `spi_transfer` + spi_transfer_delay_exec()") Upstream-status: pending Signed-off-by: Alex Gonzalez --- modules/unipi/src/unipi_spi.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/unipi/src/unipi_spi.c b/modules/unipi/src/unipi_spi.c index a65ace3..e4d3783 100644 --- a/modules/unipi/src/unipi_spi.c +++ b/modules/unipi/src/unipi_spi.c @@ -329,7 +329,12 @@ struct unipi_spi_context* unipi_spi_setup_context(struct spi_device* spi_dev, st s_trans = (struct spi_transfer *)(context + 1); spi_message_init_with_transfers(&context->message, s_trans, trans_count); - s_trans[0].delay_usecs = NEURONSPI_EDGE_DELAY; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0) + s_trans[0].delay_usecs = NEURONSPI_EDGE_DELAY; +#else + s_trans[0].delay.value = NEURONSPI_EDGE_DELAY; + s_trans[0].delay.unit = SPI_DELAY_UNIT_USECS; +#endif s_trans[0].bits_per_word = 8; s_trans[0].speed_hz = freq; @@ -341,7 +346,12 @@ struct unipi_spi_context* unipi_spi_setup_context(struct spi_device* spi_dev, st packet_crc = neuronspi_spi_crc(send_buf->first_message, 4, 0); *((u16*)(send_buf->first_message+4)) = packet_crc; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0) s_trans[1].delay_usecs = delay; +#else + s_trans[1].delay.value = delay; + s_trans[1].delay.unit = SPI_DELAY_UNIT_USECS; +#endif s_trans[1].len = NEURONSPI_FIRST_MESSAGE_LENGTH; s_trans[1].tx_buf = send_buf->first_message; s_trans[1].rx_buf = recv_buf->first_message; @@ -355,7 +365,12 @@ struct unipi_spi_context* unipi_spi_setup_context(struct spi_device* spi_dev, st unipi_spi_trace_1(KERN_INFO "UNIPISPI: SPI Master Write(%3d) %32ph\n", len, send_buf->second_message); remain = len; for (i = 2; i < trans_count; i++) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0) s_trans[i].delay_usecs = 0; +#else + s_trans[i].delay.value = 0; + s_trans[i].delay.unit = SPI_DELAY_UNIT_USECS; +#endif s_trans[i].bits_per_word = 8; s_trans[i].speed_hz = freq; s_trans[i].tx_buf = send_buf->second_message + (NEURONSPI_MAX_TX * (i - 2)); From 83d5ebe2c4741cbcd4519f9621dae276f94073a4 Mon Sep 17 00:00:00 2001 From: Alex Gonzalez Date: Mon, 24 Oct 2022 16:14:17 +0200 Subject: [PATCH 3/9] unipi_tty: remove TTY_LDISC_MAGIC Use of TTY_LDISC_MAGIC was removed in commit 981b22b8777d (tty: remove TTY_LDISC_MAGIC) Upstream-status: pending Signed-off-by: Alex Gonzalez --- modules/unipi/src/unipi_tty.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/unipi/src/unipi_tty.c b/modules/unipi/src/unipi_tty.c index 3d2ea83..36bcc66 100644 --- a/modules/unipi/src/unipi_tty.c +++ b/modules/unipi/src/unipi_tty.c @@ -990,7 +990,9 @@ static long unipi_tty_compat_ioctl(struct tty_struct *tty, struct file *file, #endif static struct tty_ldisc_ops unipi_tty_ops = { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0) .magic = TTY_LDISC_MAGIC, +#endif .owner = THIS_MODULE, .name = "unipi_tty", .open = unipi_tty_open, @@ -1095,7 +1097,9 @@ int __init unipi_tty_init(void) memset(&unipi_tty_ldisc, 0, sizeof(unipi_tty_ldisc)); n_tty_inherit_ops(&unipi_tty_ldisc); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 13, 0) unipi_tty_ldisc.magic = TTY_LDISC_MAGIC; +#endif unipi_tty_ldisc.name = "unipi_tty"; unipi_tty_ldisc.owner = THIS_MODULE; From c833a30e7ec7ac4e0c263d163133bb29ca3b2053 Mon Sep 17 00:00:00 2001 From: Alex Gonzalez Date: Mon, 24 Oct 2022 16:46:29 +0200 Subject: [PATCH 4/9] unipi_tty: remove ldisc number in tty_register_ldisc call The tty_register_ldisc() call dropped accepting the ldisc number in commit fbadf70a805 (tty: set tty_ldisc_ops::num statically) Upstream-status: pending Signed-off-by: Alex Gonzalez --- modules/unipi/src/unipi_tty.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/unipi/src/unipi_tty.c b/modules/unipi/src/unipi_tty.c index 36bcc66..1a1808f 100644 --- a/modules/unipi/src/unipi_tty.c +++ b/modules/unipi/src/unipi_tty.c @@ -1019,7 +1019,11 @@ int __init unipi_tty_init(void) { int err; unipi_tty_trace(KERN_INFO "UNIPISPI: TTY Init\n"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) err = tty_register_ldisc(N_PROFIBUS_FDL, &unipi_tty_ops); +#else + err = tty_register_ldisc(&unipi_tty_ops); +#endif if (err) { printk(KERN_INFO "UNIPISPI: UniPi line discipline registration failed. (%d)", err); return err; @@ -1029,7 +1033,11 @@ int __init unipi_tty_init(void) void __exit unipi_tty_exit(void) { - tty_unregister_ldisc(N_PROFIBUS_FDL); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) + tty_unregister_ldisc(N_PROFIBUS_FDL); +#else + tty_unregister_ldisc(&unipi_tty_ops); +#endif } #else @@ -1111,7 +1119,12 @@ int __init unipi_tty_init(void) unipi_tty_ldisc.receive_buf2 = unipi_tty_receive_buf2; unipi_tty_ldisc.ioctl = unipi_tty_ioctl; - err = tty_register_ldisc(N_PROFIBUS_FDL, &unipi_tty_ldisc); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) + err = tty_register_ldisc(N_PROFIBUS_FDL, &unipi_tty_ldisc); +#else + err = tty_register_ldisc(&unipi_tty_ldisc); +#endif if (err) { printk(KERN_INFO "UniPi line discipline registration failed. (%d)", err); return err; @@ -1121,6 +1134,10 @@ int __init unipi_tty_init(void) void __exit unipi_tty_exit(void) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) tty_unregister_ldisc(N_PROFIBUS_FDL); +#else + tty_unregister_ldisc(&unipi_tty_ldisc); +#endif } #endif From a75f8d4104b427b107632f3fe4baebb4ea354f03 Mon Sep 17 00:00:00 2001 From: Alex Gonzalez Date: Mon, 24 Oct 2022 16:56:36 +0200 Subject: [PATCH 5/9] unipi_tty: adapt to fp of tty_ldisc_ops made const Adapt to commit 0f3dcf3b5d7(tty: make fp of tty_ldisc_ops::receive_buf{,2} const) Upstream-status: pending Signed-off-by: Alex Gonzalez --- modules/unipi/src/unipi_tty.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/unipi/src/unipi_tty.c b/modules/unipi/src/unipi_tty.c index 1a1808f..4d70c59 100644 --- a/modules/unipi/src/unipi_tty.c +++ b/modules/unipi/src/unipi_tty.c @@ -1044,14 +1044,26 @@ void __exit unipi_tty_exit(void) struct tty_ldisc_ops unipi_tty_ldisc; static void (*alias_n_tty_receive_buf)(struct tty_struct *tty, const unsigned char *cp, +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) char *fp, int count); +#else + const char *fp, int count); +#endif static int (*alias_n_tty_receive_buf2)(struct tty_struct *tty, const unsigned char *cp, +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) char *fp, int count); +#else + const char *fp, int count); +#endif static int (*alias_n_tty_ioctl)(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); static void unipi_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) char *fp, int count) +#else + const char *fp, int count) +#endif { int is_parmrk = I_PARMRK(tty); if (is_parmrk) { @@ -1065,7 +1077,11 @@ static void unipi_tty_receive_buf(struct tty_struct *tty, const unsigned char *c } static int unipi_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp, +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0) char *fp, int count) +#else + const char *fp, int count) +#endif { int ret; int is_parmrk = I_PARMRK(tty); From 483cfcb8e25e1756e089c59332628c5fc4a67498 Mon Sep 17 00:00:00 2001 From: Alex Gonzalez Date: Mon, 24 Oct 2022 17:53:19 +0200 Subject: [PATCH 6/9] unipi_spi: adapt to removal of spi_set_cs_timing() The spi_set_cs_timing() interface was removed in commit 4ccf359849ce (spi: remove spi_set_cs_timing()) Upstream-status: pending Signed-off-by: Alex Gonzalez --- modules/unipi/src/unipi_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/unipi/src/unipi_spi.c b/modules/unipi/src/unipi_spi.c index e4d3783..d6260b1 100644 --- a/modules/unipi/src/unipi_spi.c +++ b/modules/unipi/src/unipi_spi.c @@ -1243,7 +1243,7 @@ s32 neuronspi_spi_probe(struct spi_device *spi) u32 always_create_uart = 0; struct kthread_worker *worker; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0) && LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0) struct spi_delay inactive_delay; #endif @@ -1373,7 +1373,7 @@ s32 neuronspi_spi_probe(struct spi_device *spi) if (gpio_is_valid(spi->cs_gpio)) { spi->cs_gpio = -spi->cs_gpio; } -#else +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0) && LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0) inactive_delay.value = 40; inactive_delay.unit = SPI_DELAY_UNIT_USECS; spi_set_cs_timing(spi, NULL, NULL, &inactive_delay); From 39ec941fa97213df026809e268753f3a0a03b4b7 Mon Sep 17 00:00:00 2001 From: Alex Gonzalez Date: Mon, 24 Oct 2022 18:05:47 +0200 Subject: [PATCH 7/9] rtc-unipi: Adapt to removal of nvram ABI Adapt to the removal of the nvram ABI in commit 25ece30561d2 (rtc: nvmem: remove nvram ABI) Upstream-status: pending Signed-off-by: Alex Gonzalez --- modules/rtc-unipi/rtc-unipi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/rtc-unipi/rtc-unipi.c b/modules/rtc-unipi/rtc-unipi.c index 255bcd1..6615b8f 100644 --- a/modules/rtc-unipi/rtc-unipi.c +++ b/modules/rtc-unipi/rtc-unipi.c @@ -671,11 +671,13 @@ static int rtc_unipi_probe(struct i2c_client *client, rtc_unipi->rtc->nvmem_config = &rtc_unipi->nvmem_cfg; rtc_unipi->rtc->nvram_old_abi = true; -#else +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0) && LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) nvmem_cfg.priv = rtc_unipi; rtc_unipi->rtc->nvram_old_abi = true; rtc_nvmem_register(rtc_unipi->rtc, &nvmem_cfg); - +#else + nvmem_cfg.priv = rtc_unipi; + rtc_nvmem_register(rtc_unipi->rtc, &nvmem_cfg); #endif rtc_unipi->rtc->ops = &mcp794xx_rtc_ops; /*chip->rtc_ops ?: &ds13xx_rtc_ops;*/ err = rtc_register_device(rtc_unipi->rtc); From 1b80b94c3f959327cfb8c5784d7eab96f649403d Mon Sep 17 00:00:00 2001 From: Alex Gonzalez Date: Mon, 24 Oct 2022 18:14:07 +0200 Subject: [PATCH 8/9] rtc-unipi: Add devm to rtc_nvmem_register This change is introduced in commit 3a905c2d9544a (rtc: add devm_ prefix to rtc_nvmem_register()) Upstream-status: pending Signed-off-by: Alex Gonzalez --- modules/rtc-unipi/rtc-unipi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rtc-unipi/rtc-unipi.c b/modules/rtc-unipi/rtc-unipi.c index 6615b8f..9953c63 100644 --- a/modules/rtc-unipi/rtc-unipi.c +++ b/modules/rtc-unipi/rtc-unipi.c @@ -677,7 +677,7 @@ static int rtc_unipi_probe(struct i2c_client *client, rtc_nvmem_register(rtc_unipi->rtc, &nvmem_cfg); #else nvmem_cfg.priv = rtc_unipi; - rtc_nvmem_register(rtc_unipi->rtc, &nvmem_cfg); + devm_rtc_nvmem_register(rtc_unipi->rtc, &nvmem_cfg); #endif rtc_unipi->rtc->ops = &mcp794xx_rtc_ops; /*chip->rtc_ops ?: &ds13xx_rtc_ops;*/ err = rtc_register_device(rtc_unipi->rtc); From d8f2dc19830485eb3e9a2d285301a73ebf84accf Mon Sep 17 00:00:00 2001 From: Alex Gonzalez Date: Mon, 24 Oct 2022 18:21:20 +0200 Subject: [PATCH 9/9] rtc-unipi: Adapt to rename of rtc_register_device The rename happens in commit fdcfd854333 (rtc: rework rtc_register_device() resource management) Upstream-status: pending Signed-off-by: Alex Gonzalez --- modules/rtc-unipi/rtc-unipi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/rtc-unipi/rtc-unipi.c b/modules/rtc-unipi/rtc-unipi.c index 9953c63..e40fce7 100644 --- a/modules/rtc-unipi/rtc-unipi.c +++ b/modules/rtc-unipi/rtc-unipi.c @@ -680,7 +680,11 @@ static int rtc_unipi_probe(struct i2c_client *client, devm_rtc_nvmem_register(rtc_unipi->rtc, &nvmem_cfg); #endif rtc_unipi->rtc->ops = &mcp794xx_rtc_ops; /*chip->rtc_ops ?: &ds13xx_rtc_ops;*/ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5,10,0) err = rtc_register_device(rtc_unipi->rtc); +#else + err = devm_rtc_register_device(rtc_unipi->rtc); +#endif if (err) return err;