From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: linux-serial@vger.kernel.org,
Greg KH <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
NXP Linux Team <linux-imx@nxp.com>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Subject: [PATCH 01/36] serial: Add uart_rs485_config()
Date: Mon, 6 Jun 2022 13:03:58 +0300 [thread overview]
Message-ID: <20220606100433.13793-2-ilpo.jarvinen@linux.intel.com> (raw)
In-Reply-To: <20220606100433.13793-1-ilpo.jarvinen@linux.intel.com>
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: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/tty/serial/8250/8250_pci.c | 6 ++----
drivers/tty/serial/8250/8250_port.c | 2 +-
drivers/tty/serial/fsl_lpuart.c | 2 +-
drivers/tty/serial/imx.c | 2 +-
drivers/tty/serial/serial_core.c | 6 ++++++
include/linux/serial_core.h | 1 +
6 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index a17619db7939..fb0a49e39072 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -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
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 78b6dedc43e6..d7384ab364d2 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -3199,7 +3199,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)
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 0d6e62f6bb07..509a7912fa9d 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -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);
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 7d2094dc5a59..9ce09b81ac9b 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -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);
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 9a85b41caa0a..8466181db4e9 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -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)
{
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index cbd5070bc87f..d3ebb4db2d80 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -592,4 +592,5 @@ static inline int uart_handle_break(struct uart_port *port)
!((cflag) & CLOCAL))
int uart_get_rs485_mode(struct uart_port *port);
+int uart_rs485_config(struct uart_port *port);
#endif /* LINUX_SERIAL_CORE_H */
--
2.30.2
next prev parent reply other threads:[~2022-06-06 10:05 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-06 10:03 [PATCH 00/36] RS485 serial_rs485 sanitization Ilpo Järvinen
2022-06-06 10:03 ` Ilpo Järvinen [this message]
2022-06-25 20:19 ` [PATCH 01/36] serial: Add uart_rs485_config() Lukas Wunner
2022-06-26 12:36 ` Lino Sanfilippo
2022-06-06 10:03 ` [PATCH 02/36] serial: Move serial_rs485 sanitization into separate function Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 03/36] serial: Add rs485_supported to uart_port Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 04/36] serial: 8250: Create serial8250_em485_supported for em485 users Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 05/36] serial: 8250_bcm2835aux: Use serial8250_em485_supported Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 06/36] serial: 8250_dwlib: Fill in rs485_supported Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 07/36] serial: 8250_exar: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 08/36] serial: 8250_fintek: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 09/36] serial: 8250_lpc18cc: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 10/36] serial: 8250_of: Use serial8250_em485_supported Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 11/36] serial: 8250_pci: Fill in rs485_supported for pci_fintek Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 12/36] serial: pl011: Fill in rs485_supported Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 13/36] serial: ar933x: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 14/36] serial: atmel: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 15/36] serial: fsl_lpuart: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 16/36] serial: imx: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 17/36] serial: max310x: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 18/36] serial: mcf: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 19/36] serial: omap: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 20/36] serial: sc16is7xx: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 21/36] serial: stm32: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 22/36] serial: Sanitize rs485_struct Ilpo Järvinen
2022-06-25 20:12 ` Lukas Wunner
2022-06-26 12:39 ` Lino Sanfilippo
2022-06-06 10:04 ` [PATCH 23/36] serial: Clear rs485 struct when non-RS485 mode is set Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 24/36] serial: return -EINVAL for non-legacy RS485 flags Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 25/36] serial: 8250_dwlib: Remove serial_rs485 sanitization Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 26/36] serial: 8250_fintek: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 27/36] serial: 8250: lpc18xx: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 28/36] serial: 8250_pci: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 29/36] serial: pl011: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 30/36] serial: fsl_lpuart: Call core's sanitization and remove custom one Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 31/36] serial: imx: Remove serial_rs485 sanitization Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 32/36] serial: max310x: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 33/36] serial: 8250_exar: Remove serial_rs485 assignment Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 34/36] serial: mcf: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 35/36] serial: sc16is7xx: " Ilpo Järvinen
2022-06-06 10:04 ` [PATCH 36/36] serial: 8250: Remove serial_rs485 sanitization from em485 Ilpo Järvinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220606100433.13793-2-ilpo.jarvinen@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=festevam@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox