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

Configure Feed

Select the types of activity you want to include in your feed.

serial: Consolidate BOTH_EMPTY use

Per file BOTH_EMPTY defines are littering our source code here and
there. Define once in serial.h and create helper for the check
too.

Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20220624205424.12686-7-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ilpo Järvinen and committed by
Greg Kroah-Hartman
34619de1 eb47b59a

+31 -33
+5 -4
arch/mips/ath79/early_printk.c
··· 8 8 9 9 #include <linux/io.h> 10 10 #include <linux/errno.h> 11 + #include <linux/serial.h> 11 12 #include <linux/serial_reg.h> 12 13 #include <asm/addrspace.h> 13 14 #include <asm/setup.h> ··· 30 29 } while (1); 31 30 } 32 31 33 - #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) 34 - 35 32 static void prom_putchar_ar71xx(char ch) 36 33 { 37 34 void __iomem *base = (void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE)); 38 35 39 - prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY); 36 + prom_putchar_wait(base + UART_LSR * 4, UART_LSR_BOTH_EMPTY, 37 + UART_LSR_BOTH_EMPTY); 40 38 __raw_writel((unsigned char)ch, base + UART_TX * 4); 41 - prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY); 39 + prom_putchar_wait(base + UART_LSR * 4, UART_LSR_BOTH_EMPTY, 40 + UART_LSR_BOTH_EMPTY); 42 41 } 43 42 44 43 static void prom_putchar_ar933x(char ch)
+1 -2
drivers/accessibility/speakup/serialio.h
··· 33 33 #define NUM_DISABLE_TIMEOUTS 3 34 34 /* buffer timeout in ms */ 35 35 #define SPK_TIMEOUT 100 36 - #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) 37 36 38 37 #define spk_serial_tx_busy() \ 39 - ((inb(speakup_info.port_tts + UART_LSR) & BOTH_EMPTY) != BOTH_EMPTY) 38 + (!uart_lsr_tx_empty(inb(speakup_info.port_tts + UART_LSR))) 40 39 41 40 #endif
+1 -3
drivers/tty/serial/8250/8250_early.c
··· 84 84 } 85 85 } 86 86 87 - #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) 88 - 89 87 static void serial_putc(struct uart_port *port, unsigned char c) 90 88 { 91 89 unsigned int status; ··· 92 94 93 95 for (;;) { 94 96 status = serial8250_early_in(port, UART_LSR); 95 - if ((status & BOTH_EMPTY) == BOTH_EMPTY) 97 + if (uart_lsr_tx_empty(status)) 96 98 break; 97 99 cpu_relax(); 98 100 }
+5 -7
drivers/tty/serial/8250/8250_port.c
··· 50 50 #define DEBUG_AUTOCONF(fmt...) do { } while (0) 51 51 #endif 52 52 53 - #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) 54 - 55 53 /* 56 54 * Here we define the default xmit fifo size used for each type of UART. 57 55 */ ··· 1841 1843 if (uart_circ_empty(xmit)) 1842 1844 break; 1843 1845 if ((up->capabilities & UART_CAP_HFIFO) && 1844 - (serial_in(up, UART_LSR) & BOTH_EMPTY) != BOTH_EMPTY) 1846 + !uart_lsr_tx_empty(serial_in(up, UART_LSR))) 1845 1847 break; 1846 1848 /* The BCM2835 MINI UART THRE bit is really a not-full bit. */ 1847 1849 if ((up->capabilities & UART_CAP_MINI) && ··· 2001 2003 2002 2004 serial8250_rpm_put(up); 2003 2005 2004 - return (lsr & BOTH_EMPTY) == BOTH_EMPTY ? TIOCSER_TEMT : 0; 2006 + return uart_lsr_tx_empty(lsr) ? TIOCSER_TEMT : 0; 2005 2007 } 2006 2008 2007 2009 unsigned int serial8250_do_get_mctrl(struct uart_port *port) ··· 2149 2151 else 2150 2152 serial_port_out(port, UART_IER, 0); 2151 2153 2152 - wait_for_xmitr(up, BOTH_EMPTY); 2154 + wait_for_xmitr(up, UART_LSR_BOTH_EMPTY); 2153 2155 /* 2154 2156 * Send the character out. 2155 2157 */ ··· 2159 2161 * Finally, wait for transmitter to become empty 2160 2162 * and restore the IER 2161 2163 */ 2162 - wait_for_xmitr(up, BOTH_EMPTY); 2164 + wait_for_xmitr(up, UART_LSR_BOTH_EMPTY); 2163 2165 serial_port_out(port, UART_IER, ier); 2164 2166 serial8250_rpm_put(up); 2165 2167 } ··· 3429 3431 * Finally, wait for transmitter to become empty 3430 3432 * and restore the IER 3431 3433 */ 3432 - wait_for_xmitr(up, BOTH_EMPTY); 3434 + wait_for_xmitr(up, UART_LSR_BOTH_EMPTY); 3433 3435 3434 3436 if (em485) { 3435 3437 mdelay(port->rs485.delay_rts_after_send);
+3 -4
drivers/tty/serial/omap-serial.c
··· 19 19 #include <linux/module.h> 20 20 #include <linux/init.h> 21 21 #include <linux/console.h> 22 + #include <linux/serial.h> 22 23 #include <linux/serial_reg.h> 23 24 #include <linux/delay.h> 24 25 #include <linux/slab.h> ··· 1103 1102 return up->name; 1104 1103 } 1105 1104 1106 - #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) 1107 - 1108 1105 static void __maybe_unused wait_for_xmitr(struct uart_omap_port *up) 1109 1106 { 1110 1107 unsigned int status, tmout = 10000; ··· 1117 1118 if (--tmout == 0) 1118 1119 break; 1119 1120 udelay(1); 1120 - } while ((status & BOTH_EMPTY) != BOTH_EMPTY); 1121 + } while (!uart_lsr_tx_empty(status)); 1121 1122 1122 1123 /* Wait up to 1s for flow control if necessary */ 1123 1124 if (up->port.flags & UPF_CONS_FLOW) { ··· 1185 1186 1186 1187 for (;;) { 1187 1188 status = omap_serial_early_in(port, UART_LSR); 1188 - if ((status & BOTH_EMPTY) == BOTH_EMPTY) 1189 + if (uart_lsr_tx_empty(status)) 1189 1190 break; 1190 1191 cpu_relax(); 1191 1192 }
+3 -4
drivers/tty/serial/pch_uart.c
··· 3 3 *Copyright (C) 2011 LAPIS Semiconductor Co., Ltd. 4 4 */ 5 5 #include <linux/kernel.h> 6 + #include <linux/serial.h> 6 7 #include <linux/serial_reg.h> 7 8 #include <linux/slab.h> 8 9 #include <linux/module.h> ··· 189 188 #define PCH_UART_HAL_OUT (PCH_UART_MCR_OUT) 190 189 #define PCH_UART_HAL_LOOP (PCH_UART_MCR_LOOP) 191 190 #define PCH_UART_HAL_AFE (PCH_UART_MCR_AFE) 192 - 193 - #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) 194 191 195 192 #define DEFAULT_UARTCLK 1843200 /* 1.8432 MHz */ 196 193 #define CMITC_UARTCLK 192000000 /* 192.0000 MHz */ ··· 1515 1516 * Finally, wait for transmitter to become empty 1516 1517 * and restore the IER 1517 1518 */ 1518 - wait_for_xmitr(priv, BOTH_EMPTY); 1519 + wait_for_xmitr(priv, UART_LSR_BOTH_EMPTY); 1519 1520 iowrite8(ier, priv->membase + UART_IER); 1520 1521 } 1521 1522 #endif /* CONFIG_CONSOLE_POLL */ ··· 1601 1602 * Finally, wait for transmitter to become empty 1602 1603 * and restore the IER 1603 1604 */ 1604 - wait_for_xmitr(priv, BOTH_EMPTY); 1605 + wait_for_xmitr(priv, UART_LSR_BOTH_EMPTY); 1605 1606 iowrite8(ier, priv->membase + UART_IER); 1606 1607 1607 1608 if (port_locked)
+2 -3
drivers/tty/serial/pxa.c
··· 23 23 #include <linux/init.h> 24 24 #include <linux/console.h> 25 25 #include <linux/sysrq.h> 26 + #include <linux/serial.h> 26 27 #include <linux/serial_reg.h> 27 28 #include <linux/circ_buf.h> 28 29 #include <linux/delay.h> ··· 576 575 577 576 #ifdef CONFIG_SERIAL_PXA_CONSOLE 578 577 579 - #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) 580 - 581 578 /* 582 579 * Wait for transmitter & holding register to empty 583 580 */ ··· 593 594 if (--tmout == 0) 594 595 break; 595 596 udelay(1); 596 - } while ((status & BOTH_EMPTY) != BOTH_EMPTY); 597 + } while (!uart_lsr_tx_empty(status)); 597 598 598 599 /* Wait up to 1s for flow control if necessary */ 599 600 if (up->port.flags & UPF_CONS_FLOW) {
+1 -3
drivers/tty/serial/sunsu.c
··· 1249 1249 1250 1250 #ifdef CONFIG_SERIAL_SUNSU_CONSOLE 1251 1251 1252 - #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) 1253 - 1254 1252 /* 1255 1253 * Wait for transmitter & holding register to empty 1256 1254 */ ··· 1266 1268 if (--tmout == 0) 1267 1269 break; 1268 1270 udelay(1); 1269 - } while ((status & BOTH_EMPTY) != BOTH_EMPTY); 1271 + } while (!uart_lsr_tx_empty(status)); 1270 1272 1271 1273 /* Wait up to 1s for flow control if necessary */ 1272 1274 if (up->port.flags & UPF_CONS_FLOW) {
+1 -3
drivers/tty/serial/vr41xx_siu.c
··· 703 703 704 704 #ifdef CONFIG_SERIAL_VR41XX_CONSOLE 705 705 706 - #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) 707 - 708 706 static void wait_for_xmitr(struct uart_port *port) 709 707 { 710 708 int timeout = 10000; ··· 713 715 if (lsr & UART_LSR_BI) 714 716 lsr_break_flag[port->line] = UART_LSR_BI; 715 717 716 - if ((lsr & BOTH_EMPTY) == BOTH_EMPTY) 718 + if (uart_lsr_tx_empty(lsr)) 717 719 break; 718 720 } while (timeout-- > 0); 719 721
+9
include/linux/serial.h
··· 10 10 #define _LINUX_SERIAL_H 11 11 12 12 #include <uapi/linux/serial.h> 13 + #include <uapi/linux/serial_reg.h> 13 14 14 15 /* Helper for dealing with UART_LCR_WLEN* defines */ 15 16 #define UART_LCR_WLEN(x) ((x) - 5) 17 + 18 + /* FIFO and shifting register empty */ 19 + #define UART_LSR_BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) 20 + 21 + static inline bool uart_lsr_tx_empty(u16 lsr) 22 + { 23 + return (lsr & UART_LSR_BOTH_EMPTY) == UART_LSR_BOTH_EMPTY; 24 + } 16 25 17 26 /* 18 27 * Counters of the input lines (CTS, DSR, RI, CD) interrupts