]> git.itanic.dy.fi Git - linux-stable/blobdiff - include/linux/serial_core.h
serial: Create uart_xmit_advance()
[linux-stable] / include / linux / serial_core.h
index fde258b3decd502110cff11811ed4e2fb66cbdbb..037a8d81a66cfa6d2bf173210d5ac6bb9d3b0252 100644 (file)
@@ -302,6 +302,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;