File: 0005-xtrx.c-fix-build-error-with-kernel-6.10.patch

package info (click to toggle)
xtrx-dkms 0.0.1%2Bgit20190320.5ae3a3e-3.7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 376 kB
  • sloc: ansic: 7,314; xml: 23; makefile: 21
file content (90 lines) | stat: -rw-r--r-- 2,538 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
From: Weston Reed <weston@westonreed.com>
Date: Thu, 12 Sep 2024 22:01:07 -0700
Subject: [PATCH] xtrx.c: fix build error with kernel 6.10

see kernel commit: https://github.com/torvalds/linux/commit/1788cf6a91d9fa9aa61fc2917afe192c23d67f6a
Origin: https://github.com/myriadrf/xtrx_linux_pcie_drv/pull/20/
Bug-Debian: https://bugs.debian.org/1077678
---
 xtrx.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/xtrx.c b/xtrx.c
index 197a94d..f3e41cf 100644
--- a/xtrx.c
+++ b/xtrx.c
@@ -35,6 +35,7 @@
 #include <linux/serial.h>
 #include <linux/serial_core.h>
 #include <linux/serial_reg.h>
+#include <linux/kfifo.h>
 #include <linux/device.h>
 #include <linux/time.h>
 #include <linux/pps_kernel.h>
@@ -451,7 +452,11 @@ void xtrx_uart_do_rx(struct uart_port *port, unsigned* fifo_used)
 
 static void xtrx_uart_do_tx(struct uart_port *port, unsigned fifo_used)
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
 	struct circ_buf *xmit;
+#else
+	struct tty_port *tport;
+#endif
 	unsigned int max_count;
 	struct xtrx_dev *dev = xtrx_dev_from_uart_port(port);
 
@@ -469,29 +474,53 @@ static void xtrx_uart_do_tx(struct uart_port *port, unsigned fifo_used)
 		return;
 	}
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
 	xmit = &port->state->xmit;
 	if (uart_circ_empty(xmit))
 		goto txq_empty;
+#else
+	tport = &port->state->port;
+	if (kfifo_is_empty(&tport->xmit_fifo))
+		goto txq_empty;
+#endif
 
 	max_count = port->fifosize - fifo_used;
 	while (max_count--) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
 		unsigned int c;
 
 		c = xmit->buf[xmit->tail] & 0xff;
 		//printk(KERN_NOTICE PFX "Char: %x\n", c);
+#else
+		unsigned char c;
+
+		if (kfifo_is_empty(&tport->xmit_fifo) || kfifo_get(&tport->xmit_fifo, &c) == 0)
+			break;
+#endif
 		xtrx_writel(dev, (port->line % XTRX_UART_NUM == XTRX_UART_LINE_GPS) ?
-				    GP_PORT_WR_UART_TX : GP_PORT_WR_SIM_TX, c);
+					GP_PORT_WR_UART_TX : GP_PORT_WR_SIM_TX, c);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
 		xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
 		port->icount.tx++;
 		if (uart_circ_empty(xmit))
 			break;
+#endif
 	}
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
 	if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
 		uart_write_wakeup(port);
 
 	if (uart_circ_empty(xmit))
 		goto txq_empty;
+#else
+	if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
+		uart_write_wakeup(port);
+
+	if (kfifo_is_empty(&tport->xmit_fifo))
+		goto txq_empty;
+#endif
 	return;
 
 txq_empty: