2024-04-07 00:27:39

by Lino Sanfilippo

[permalink] [raw]
Subject: [PATCH 0/4] RS485 cleanups

The following series contains some minor cleanups and improvements for the
RS485 implementation in serial drivers. There are no bugfixes or intended
functional changes.


Lino Sanfilippo (4):
serial: amba-pl011: get rid of useless wrapper pl011_get_rs485_mode()
serial: amba-pl011: move variable into CONFIG_DMA_ENGINE conditional
serial: 8250: Remove superfluous sanity check
serial: ar933x: Remove unneeded static structure

drivers/tty/serial/8250/8250_port.c | 7 -------
drivers/tty/serial/amba-pl011.c | 16 ++--------------
drivers/tty/serial/ar933x_uart.c | 3 +--
3 files changed, 3 insertions(+), 23 deletions(-)


base-commit: e8f897f4afef0031fe618a8e94127a0934896aba
--
2.43.2


2024-04-07 00:27:52

by Lino Sanfilippo

[permalink] [raw]
Subject: [PATCH 1/4] serial: amba-pl011: get rid of useless wrapper pl011_get_rs485_mode()

Due to earlier code changes function pl011_get_rs485_mode() is now merely
a wrapper for uart_get_rs485_mode() which does not add any further
functionality. So remove it and instead call uart_get_rs485_mode()
directly.

Reviewed-by: Lukas Wunner <[email protected]>
Signed-off-by: Lino Sanfilippo <[email protected]>
---
drivers/tty/serial/amba-pl011.c | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index cf2c890a560f..3d2dac0ebcde 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2708,18 +2708,6 @@ static int pl011_find_free_port(void)
return -EBUSY;
}

-static int pl011_get_rs485_mode(struct uart_amba_port *uap)
-{
- struct uart_port *port = &uap->port;
- int ret;
-
- ret = uart_get_rs485_mode(port);
- if (ret)
- return ret;
-
- return 0;
-}
-
static int pl011_setup_port(struct device *dev, struct uart_amba_port *uap,
struct resource *mmiobase, int index)
{
@@ -2740,7 +2728,7 @@ static int pl011_setup_port(struct device *dev, struct uart_amba_port *uap,
uap->port.flags = UPF_BOOT_AUTOCONF;
uap->port.line = index;

- ret = pl011_get_rs485_mode(uap);
+ ret = uart_get_rs485_mode(&uap->port);
if (ret)
return ret;

--
2.43.2

2024-04-07 00:28:09

by Lino Sanfilippo

[permalink] [raw]
Subject: [PATCH 2/4] serial: amba-pl011: move variable into CONFIG_DMA_ENGINE conditional

Variable dmacr is only used if DMA is enabled, so move it into the
CONFIG_DMA_ENGINE conditional.

Signed-off-by: Lino Sanfilippo <[email protected]>
---
drivers/tty/serial/amba-pl011.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 3d2dac0ebcde..349005e6ab9f 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -256,7 +256,6 @@ struct uart_amba_port {
const u16 *reg_offset;
struct clk *clk;
const struct vendor_data *vendor;
- unsigned int dmacr; /* dma control reg */
unsigned int im; /* interrupt mask */
unsigned int old_status;
unsigned int fifosize; /* vendor-specific */
@@ -266,6 +265,7 @@ struct uart_amba_port {
unsigned int rs485_tx_drain_interval; /* usecs */
#ifdef CONFIG_DMA_ENGINE
/* DMA stuff */
+ unsigned int dmacr; /* dma control reg */
bool using_tx_dma;
bool using_rx_dma;
struct pl011_dmarx_data dmarx;
--
2.43.2

2024-04-07 00:28:41

by Lino Sanfilippo

[permalink] [raw]
Subject: [PATCH 4/4] serial: ar933x: Remove unneeded static structure

In case that no RTS GPIO is available do not use a dedicated nullified
serial_rs485 struct to disable RS485 support, but simply delete the
SER_RS485_ENABLED flag in the ports rs485_supported struct.
This make the structure superfluous and it can be removed.

Signed-off-by: Lino Sanfilippo <[email protected]>
---
drivers/tty/serial/ar933x_uart.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/serial/ar933x_uart.c b/drivers/tty/serial/ar933x_uart.c
index 8d09ace062e5..be9ea988d136 100644
--- a/drivers/tty/serial/ar933x_uart.c
+++ b/drivers/tty/serial/ar933x_uart.c
@@ -699,7 +699,6 @@ static struct uart_driver ar933x_uart_driver = {
.cons = NULL, /* filled in runtime */
};

-static const struct serial_rs485 ar933x_no_rs485 = {};
static const struct serial_rs485 ar933x_rs485_supported = {
.flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND,
};
@@ -795,7 +794,7 @@ static int ar933x_uart_probe(struct platform_device *pdev)
up->rts_gpiod = mctrl_gpio_to_gpiod(up->gpios, UART_GPIO_RTS);

if (!up->rts_gpiod) {
- port->rs485_supported = ar933x_no_rs485;
+ port->rs485_supported.flags &= ~SER_RS485_ENABLED;
if (port->rs485.flags & SER_RS485_ENABLED) {
dev_err(&pdev->dev, "lacking rts-gpio, disabling RS485\n");
port->rs485.flags &= ~SER_RS485_ENABLED;
--
2.43.2

2024-04-07 00:51:25

by Lino Sanfilippo

[permalink] [raw]
Subject: [PATCH 3/4] serial: 8250: Remove superfluous sanity check

The serial core already checks the RS485 RTS settings for sanity, so remove
the superfluous check in serial8250_em485_config().

Signed-off-by: Lino Sanfilippo <[email protected]>
---
drivers/tty/serial/8250/8250_port.c | 7 -------
1 file changed, 7 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 8ca061d3bbb9..86ab6925738a 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -616,13 +616,6 @@ int serial8250_em485_config(struct uart_port *port, struct ktermios *termios,
{
struct uart_8250_port *up = up_to_u8250p(port);

- /* pick sane settings if the user hasn't */
- if (!!(rs485->flags & SER_RS485_RTS_ON_SEND) ==
- !!(rs485->flags & SER_RS485_RTS_AFTER_SEND)) {
- rs485->flags |= SER_RS485_RTS_ON_SEND;
- rs485->flags &= ~SER_RS485_RTS_AFTER_SEND;
- }
-
/*
* Both serial8250_em485_init() and serial8250_em485_destroy()
* are idempotent.
--
2.43.2