diff mbox series

[1/7] serial: 8250_dma: Use ->tx_dma function pointer to start next DMA

Message ID 20220310161650.289387-2-miquel.raynal@bootlin.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series RZN1 UART DMA support | expand

Commit Message

Miquel Raynal March 10, 2022, 4:16 p.m. UTC
From: Phil Edworthy <phil.edworthy@renesas.com>

The 8250 driver is quite flexible. Regarding DMA handling, there is the
possibility to either use the default helper (serial8250_tx_dma()) or
call a specific function. Only the omap and brcm implementation do
that. In both cases, they don't use the serial8250_tx_dma() helper at
all.

As we are going to write a new DMA handling function for the RZ/N1 SoCs
which will use the serial8250_tx_dma() implementation (preceded by a
couple of register writes), we need the ->tx_dma() pointer to link to
our own function, but within the __dma_tx_complete() helper we also need
to call our own implementation instead of the default one directly.

In order to do that, let's call ->tx_dma() instead of
serial8250_tx_dma() from __dma_tx_complete().

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
[miquel.raynal@bootlin.com: Re-write commit message]
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/tty/serial/8250/8250_dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andy Shevchenko March 10, 2022, 5:59 p.m. UTC | #1
On Thu, Mar 10, 2022 at 05:16:44PM +0100, Miquel Raynal wrote:
> From: Phil Edworthy <phil.edworthy@renesas.com>
> 
> The 8250 driver is quite flexible. Regarding DMA handling, there is the
> possibility to either use the default helper (serial8250_tx_dma()) or
> call a specific function. Only the omap and brcm implementation do
> that. In both cases, they don't use the serial8250_tx_dma() helper at
> all.
> 
> As we are going to write a new DMA handling function for the RZ/N1 SoCs
> which will use the serial8250_tx_dma() implementation (preceded by a
> couple of register writes), we need the ->tx_dma() pointer to link to
> our own function, but within the __dma_tx_complete() helper we also need
> to call our own implementation instead of the default one directly.
> 
> In order to do that, let's call ->tx_dma() instead of
> serial8250_tx_dma() from __dma_tx_complete().

In 8250 driver the pattern is to give the generic function "do" name and
then call it in a wrapper:

	if (->foo())
		return ->foo();

	return serial8250_do_foo();

There are plenty of examples in that driver.
diff mbox series

Patch

diff --git a/drivers/tty/serial/8250/8250_dma.c b/drivers/tty/serial/8250/8250_dma.c
index 890fa7ddaa7f..a0563f2341ac 100644
--- a/drivers/tty/serial/8250/8250_dma.c
+++ b/drivers/tty/serial/8250/8250_dma.c
@@ -33,7 +33,7 @@  static void __dma_tx_complete(void *param)
 	if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
 		uart_write_wakeup(&p->port);
 
-	ret = serial8250_tx_dma(p);
+	ret = dma->tx_dma(p);
 	if (ret)
 		serial8250_set_THRI(p);