Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
3ee07964 720e78d7

+27 -5
+27 -5
include/linux/serial_core.h
··· 748 748 749 749 void uart_write_wakeup(struct uart_port *port); 750 750 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) \ 753 762 ({ \ 754 763 struct uart_port *__port = (uport); \ 755 764 struct circ_buf *xmit = &__port->state->xmit; \ ··· 786 777 if (pending < WAKEUP_CHARS) { \ 787 778 uart_write_wakeup(__port); \ 788 779 \ 789 - if (pending == 0) \ 780 + if (!((flags) & UART_TX_NOSTOP) && pending == 0) \ 790 781 __port->ops->stop_tx(__port); \ 791 782 } \ 792 783 \ ··· 821 812 */ 822 813 #define uart_port_tx_limited(port, ch, count, tx_ready, put_char, tx_done) ({ \ 823 814 unsigned int __count = (count); \ 824 - __uart_port_tx(port, ch, tx_ready, put_char, tx_done, __count, \ 815 + __uart_port_tx(port, ch, 0, tx_ready, put_char, tx_done, __count, \ 825 816 __count--); \ 826 817 }) 827 818 ··· 835 826 * See uart_port_tx_limited() for more details. 836 827 */ 837 828 #define uart_port_tx(port, ch, tx_ready, put_char) \ 838 - __uart_port_tx(port, ch, tx_ready, put_char, ({}), true, ({})) 829 + __uart_port_tx(port, ch, 0, tx_ready, put_char, ({}), true, ({})) 839 830 831 + 832 + /** 833 + * uart_port_tx_flags -- transmit helper for uart_port with flags 834 + * @port: uart port 835 + * @ch: variable to store a character to be written to the HW 836 + * @flags: %UART_TX_NOSTOP or similar 837 + * @tx_ready: can HW accept more data function 838 + * @put_char: function to write a character 839 + * 840 + * See uart_port_tx_limited() for more details. 841 + */ 842 + #define uart_port_tx_flags(port, ch, flags, tx_ready, put_char) \ 843 + __uart_port_tx(port, ch, flags, tx_ready, put_char, ({}), true, ({})) 840 844 /* 841 845 * Baud rate helpers. 842 846 */