On Wed, Mar 29, 2023 at 10:42:35AM -0500, Brenda Streiff wrote:
The National Instruments (NI) 16550 is a 16550-like UART with larger
FIFOs and embedded RS-232/RS-485 transceiver control circuitry. This
patch adds a driver that can operate this UART, which is used for
onboard serial ports in several NI embedded controller designs.
People are still making new 8250-like variants with different ways of
controlling them these days? That's the design pattern that will not
die, or at least, it keeps getting a "value-add" :(
+++ b/drivers/tty/serial/8250/8250_ni.c
@@ -0,0 +1,447 @@
+// SPDX-License-Identifier: GPL-2.0+
Do you really mean "+"? Sorry, I have to ask.
+/*
+ * NI 16550 UART Driver
+ *
+ * The National Instruments (NI) 16550 is a UART that is compatible with the
+ * TL16C550C and OX16C950B register interfaces, but has additional functions
+ * for RS-485 transceiver control. This driver implements support for the
+ * additional functionality on top of the standard serial8250 core.
+ *
+ * Copyright 2012-2023 National Instruments Corporation
Um, 2012 and every year since then? You all have had an out-of-tree
driver for 11+ years that has been constantly updated every year?
+/* flags for ni16550_device_info */
+#define NI_HAS_PMR BIT(0)
+
+struct ni16550_device_info {
+ unsigned int uartclk;
+ uint8_t prescaler;
Please use proper kernel types, u8.
+ unsigned int flags;
And that's a horrible packing, do you mean to have those offsets?
And why "unsigned int", don't you mean "u64" or "u32"?
+static int ni16550_rs485_config(struct uart_port *port,
+ struct ktermios *termios,
+ struct serial_rs485 *rs485)
+{
+ uint8_t pcr;
+ struct uart_8250_port *up = container_of(port, struct uart_8250_port,
+ port);
+
+ /* "rs485" should be given to us non-NULL. */
+ if (WARN_ON(rs485 == NULL))
Can this ever happen? If not, don't check for it, otherwise you just
rebooted a machine that has panic-on-warn enabled :(
+ return -EINVAL;
Or better yet, handle the case and return the error, why the WARN_ON()?