Skip to content

Commit e77cab7

Browse files
ij-intelgregkh
authored andcommitted
serial: Create uart_xmit_advance()
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 <[email protected]> Cc: stable <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7e18e42 commit e77cab7

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

include/linux/serial_core.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,23 @@ struct uart_state {
624624
/* number of characters left in xmit buffer before we ask for more */
625625
#define WAKEUP_CHARS 256
626626

627+
/**
628+
* uart_xmit_advance - Advance xmit buffer and account Tx'ed chars
629+
* @up: uart_port structure describing the port
630+
* @chars: number of characters sent
631+
*
632+
* This function advances the tail of circular xmit buffer by the number of
633+
* @chars transmitted and handles accounting of transmitted bytes (into
634+
* @up's icount.tx).
635+
*/
636+
static inline void uart_xmit_advance(struct uart_port *up, unsigned int chars)
637+
{
638+
struct circ_buf *xmit = &up->state->xmit;
639+
640+
xmit->tail = (xmit->tail + chars) & (UART_XMIT_SIZE - 1);
641+
up->icount.tx += chars;
642+
}
643+
627644
struct module;
628645
struct tty_driver;
629646

0 commit comments

Comments
 (0)