Skip to content

Commit 3ee0796

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
serial: core: introduce uart_port_tx_flags()
And an enum with a flag: UART_TX_NOSTOP. To NOT call __port->ops->stop_tx() when the circular buffer is empty. mxs-uart needs this (see the next patch). Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Cc: stable <stable@kernel.org> Tested-by: Emil Kronborg <emil.kronborg@protonmail.com> Link: https://lore.kernel.org/r/20240201105557.28043-1-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 720e78d commit 3ee0796

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

include/linux/serial_core.h

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,17 @@ struct uart_driver {
748748

749749
void uart_write_wakeup(struct uart_port *port);
750750

751-
#define __uart_port_tx(uport, ch, tx_ready, put_char, tx_done, for_test, \
752-
for_post) \
751+
/**
752+
* enum UART_TX_FLAGS -- flags for uart_port_tx_flags()
753+
*
754+
* @UART_TX_NOSTOP: don't call port->ops->stop_tx() on empty buffer
755+
*/
756+
enum UART_TX_FLAGS {
757+
UART_TX_NOSTOP = BIT(0),
758+
};
759+
760+
#define __uart_port_tx(uport, ch, flags, tx_ready, put_char, tx_done, \
761+
for_test, for_post) \
753762
({ \
754763
struct uart_port *__port = (uport); \
755764
struct circ_buf *xmit = &__port->state->xmit; \
@@ -777,7 +786,7 @@ void uart_write_wakeup(struct uart_port *port);
777786
if (pending < WAKEUP_CHARS) { \
778787
uart_write_wakeup(__port); \
779788
\
780-
if (pending == 0) \
789+
if (!((flags) & UART_TX_NOSTOP) && pending == 0) \
781790
__port->ops->stop_tx(__port); \
782791
} \
783792
\
@@ -812,7 +821,7 @@ void uart_write_wakeup(struct uart_port *port);
812821
*/
813822
#define uart_port_tx_limited(port, ch, count, tx_ready, put_char, tx_done) ({ \
814823
unsigned int __count = (count); \
815-
__uart_port_tx(port, ch, tx_ready, put_char, tx_done, __count, \
824+
__uart_port_tx(port, ch, 0, tx_ready, put_char, tx_done, __count, \
816825
__count--); \
817826
})
818827

@@ -826,8 +835,21 @@ void uart_write_wakeup(struct uart_port *port);
826835
* See uart_port_tx_limited() for more details.
827836
*/
828837
#define uart_port_tx(port, ch, tx_ready, put_char) \
829-
__uart_port_tx(port, ch, tx_ready, put_char, ({}), true, ({}))
838+
__uart_port_tx(port, ch, 0, tx_ready, put_char, ({}), true, ({}))
839+
830840

841+
/**
842+
* uart_port_tx_flags -- transmit helper for uart_port with flags
843+
* @port: uart port
844+
* @ch: variable to store a character to be written to the HW
845+
* @flags: %UART_TX_NOSTOP or similar
846+
* @tx_ready: can HW accept more data function
847+
* @put_char: function to write a character
848+
*
849+
* See uart_port_tx_limited() for more details.
850+
*/
851+
#define uart_port_tx_flags(port, ch, flags, tx_ready, put_char) \
852+
__uart_port_tx(port, ch, flags, tx_ready, put_char, ({}), true, ({}))
831853
/*
832854
* Baud rate helpers.
833855
*/

0 commit comments

Comments
 (0)