diff options
author | Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> | 2022-09-01 17:39:32 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-09-28 12:02:57 +0300 |
commit | 3b5fa3abe0105c022e47071394a3c4476d8035a7 (patch) | |
tree | 32befbb658083dee4ea790ca53f86bba14096766 /include | |
parent | 1c9b1d021181b0bf7f4cf2caa04f7fe358fdac49 (diff) | |
download | linux-3b5fa3abe0105c022e47071394a3c4476d8035a7.tar.xz |
serial: Create uart_xmit_advance()
commit e77cab77f2cb3a1ca2ba8df4af45bb35617ac16d upstream.
A very common pattern in the drivers is to advance xmit tail
index and do bookkeeping of Tx'ed characters. Create
uart_xmit_advance() to handle it.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20220901143934.8850-2-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/serial_core.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 3460b15a2607..af8143fb644c 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -306,6 +306,23 @@ struct uart_state { /* number of characters left in xmit buffer before we ask for more */ #define WAKEUP_CHARS 256 +/** + * uart_xmit_advance - Advance xmit buffer and account Tx'ed chars + * @up: uart_port structure describing the port + * @chars: number of characters sent + * + * This function advances the tail of circular xmit buffer by the number of + * @chars transmitted and handles accounting of transmitted bytes (into + * @up's icount.tx). + */ +static inline void uart_xmit_advance(struct uart_port *up, unsigned int chars) +{ + struct circ_buf *xmit = &up->state->xmit; + + xmit->tail = (xmit->tail + chars) & (UART_XMIT_SIZE - 1); + up->icount.tx += chars; +} + struct module; struct tty_driver; |