Commit 8322b1f5 authored by Ilpo Järvinen's avatar Ilpo Järvinen Committed by Greg Kroah-Hartman
Browse files

serial: Add uart_rs485_config()



A few serial drivers make a call to rs485_config() themselves (all
these seem to relate to init). Convert them all to use a common helper
which makes it easy to make adjustments on tasks related to it as
serial_rs485 struct sanitization is going to be added.

In pci_fintek_setup() (in 8250_pci.c), the rs485_config() call was made
with NULL, however, it can be changed to pass uart_port's rs485 struct.
No other callers should pass NULL into rs485_config() so the NULL check
can now be eliminated.

Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20220606100433.13793-2-ilpo.jarvinen@linux.intel.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent af14f300
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -1562,9 +1562,7 @@ static int pci_fintek_rs485_config(struct uart_port *port,

	pci_read_config_byte(pci_dev, 0x40 + 8 * *index + 7, &setting);

	if (!rs485)
		rs485 = &port->rs485;
	else if (rs485->flags & SER_RS485_ENABLED)
	if (rs485->flags & SER_RS485_ENABLED)
		memset(rs485->padding, 0, sizeof(rs485->padding));
	else
		memset(rs485, 0, sizeof(*rs485));
@@ -1689,7 +1687,7 @@ static int pci_fintek_init(struct pci_dev *dev)
			 * pciserial_resume_ports()
			 */
			port = serial8250_get_port(priv->line[i]);
			pci_fintek_rs485_config(&port->port, NULL);
			uart_rs485_config(&port->port);
		} else {
			/* First init without port data
			 * force init to RS232 Mode
+1 −1
Original line number Diff line number Diff line
@@ -3191,7 +3191,7 @@ static void serial8250_config_port(struct uart_port *port, int flags)
		autoconfig(up);

	if (port->rs485.flags & SER_RS485_ENABLED)
		port->rs485_config(port, &port->rs485);
		uart_rs485_config(port);

	/* if access method is AU, it is a 16550 with a quirk */
	if (port->type == PORT_16550A && port->iotype == UPIO_AU)
+1 −1
Original line number Diff line number Diff line
@@ -2724,7 +2724,7 @@ static int lpuart_probe(struct platform_device *pdev)
	    sport->port.rs485.delay_rts_after_send)
		dev_err(&pdev->dev, "driver doesn't support RTS delays\n");

	sport->port.rs485_config(&sport->port, &sport->port.rs485);
	uart_rs485_config(&sport->port);

	ret = devm_request_irq(&pdev->dev, sport->port.irq, handler, 0,
				DRIVER_NAME, sport);
+1 −1
Original line number Diff line number Diff line
@@ -2338,7 +2338,7 @@ static int imx_uart_probe(struct platform_device *pdev)
		dev_err(&pdev->dev,
			"low-active RTS not possible when receiver is off, enabling receiver\n");

	imx_uart_rs485_config(&sport->port, &sport->port.rs485);
	uart_rs485_config(&sport->port);

	/* Disable interrupts before requesting them */
	ucr1 = imx_uart_readl(sport, UCR1);
+6 −0
Original line number Diff line number Diff line
@@ -1276,6 +1276,12 @@ static int uart_get_icount(struct tty_struct *tty,
	return 0;
}

int uart_rs485_config(struct uart_port *port)
{
	return port->rs485_config(port, &port->rs485);
}
EXPORT_SYMBOL_GPL(uart_rs485_config);

static int uart_get_rs485_config(struct uart_port *port,
			 struct serial_rs485 __user *rs485)
{
Loading