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

[PATCH] Serial: Move error path processing inline

With unlikely() there's no need for the error path to
use gotos.

Signed-off-by: Russell King <rmk@arm.linux.org.uk>

+52 -80
+28 -39
drivers/serial/clps711x.c
··· 116 116 * Note that the error handling code is 117 117 * out of the main execution path 118 118 */ 119 - if (unlikely(ch & UART_ANY_ERR)) 120 - goto handle_error; 119 + if (unlikely(ch & UART_ANY_ERR)) { 120 + if (ch & UARTDR_PARERR) 121 + port->icount.parity++; 122 + else if (ch & UARTDR_FRMERR) 123 + port->icount.frame++; 124 + if (ch & UARTDR_OVERR) 125 + port->icount.overrun++; 126 + 127 + ch &= port->read_status_mask; 128 + 129 + if (ch & UARTDR_PARERR) 130 + flg = TTY_PARITY; 131 + else if (ch & UARTDR_FRMERR) 132 + flg = TTY_FRAME; 133 + 134 + #ifdef SUPPORT_SYSRQ 135 + port->sysrq = 0; 136 + #endif 137 + } 121 138 122 139 if (uart_handle_sysrq_char(port, ch, regs)) 123 140 goto ignore_char; 124 141 125 - error_return: 126 - tty_insert_flip_char(tty, ch, flg); 127 - ignore_char: 128 - status = clps_readl(SYSFLG(port)); 129 - } 130 - out: 131 - tty_flip_buffer_push(tty); 132 - return IRQ_HANDLED; 133 - 134 - handle_error: 135 - if (ch & UARTDR_PARERR) 136 - port->icount.parity++; 137 - else if (ch & UARTDR_FRMERR) 138 - port->icount.frame++; 139 - if (ch & UARTDR_OVERR) 140 - port->icount.overrun++; 141 - 142 - if (ch & port->ignore_status_mask) { 143 - if (++ignored > 100) 144 - goto out; 145 - goto ignore_char; 146 - } 147 - ch &= port->read_status_mask; 148 - 149 - if (ch & UARTDR_PARERR) 150 - flg = TTY_PARITY; 151 - else if (ch & UARTDR_FRMERR) 152 - flg = TTY_FRAME; 153 - 154 - if (ch & UARTDR_OVERR) { 155 142 /* 156 143 * CHECK: does overrun affect the current character? 157 144 * ASSUMPTION: it does not. 158 145 */ 159 - tty_insert_flip_char(tty, ch, flg); 160 - ch = 0; 161 - flg = TTY_OVERRUN; 146 + if ((ch & port->ignore_status_mask & ~RXSTAT_OVERRUN) == 0) 147 + tty_insert_flip_char(tty, ch, flg); 148 + if ((ch & ~port->ignore_status_mask & RXSTAT_OVERRUN) == 0) 149 + tty_insert_flip_char(tty, 0, TTY_OVERRUN); 150 + 151 + ignore_char: 152 + status = clps_readl(SYSFLG(port)); 162 153 } 163 - #ifdef SUPPORT_SYSRQ 164 - port->sysrq = 0; 165 - #endif 166 - goto error_return; 154 + tty_flip_buffer_push(tty); 155 + return IRQ_HANDLED; 167 156 } 168 157 169 158 static irqreturn_t clps711xuart_int_tx(int irq, void *dev_id, struct pt_regs *regs)
+24 -41
drivers/serial/sa1100.c
··· 214 214 * note that the error handling code is 215 215 * out of the main execution path 216 216 */ 217 - if (status & UTSR1_TO_SM(UTSR1_PRE | UTSR1_FRE | UTSR1_ROR)) 218 - goto handle_error; 217 + if (status & UTSR1_TO_SM(UTSR1_PRE | UTSR1_FRE | UTSR1_ROR)) { 218 + if (status & UTSR1_TO_SM(UTSR1_PRE)) 219 + sport->port.icount.parity++; 220 + else if (status & UTSR1_TO_SM(UTSR1_FRE)) 221 + sport->port.icount.frame++; 222 + if (status & UTSR1_TO_SM(UTSR1_ROR)) 223 + sport->port.icount.overrun++; 224 + 225 + status &= sport->port.read_status_mask; 226 + 227 + if (status & UTSR1_TO_SM(UTSR1_PRE)) 228 + flg = TTY_PARITY; 229 + else if (status & UTSR1_TO_SM(UTSR1_FRE)) 230 + flg = TTY_FRAME; 231 + 232 + #ifdef SUPPORT_SYSRQ 233 + sport->port.sysrq = 0; 234 + #endif 235 + } 219 236 220 237 if (uart_handle_sysrq_char(&sport->port, ch, regs)) 221 238 goto ignore_char; 222 239 223 - error_return: 224 - tty_insert_flip_char(tty, ch, flg); 240 + if ((status & port->ignore_status_mask & ~UTSR1_TO_SM(UTSR1_ROR)) == 0) 241 + tty_insert_flip_char(tty, ch, flg); 242 + if (status & ~port->ignore_status_mask & UTSR1_TO_SM(UTSR1_ROR)) 243 + tty_insert_flip_char(tty, 0, TTY_OVERRUN); 244 + 225 245 ignore_char: 226 246 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | 227 247 UTSR0_TO_SM(UART_GET_UTSR0(sport)); 228 248 } 229 - out: 230 249 tty_flip_buffer_push(tty); 231 - return; 232 - 233 - handle_error: 234 - if (status & UTSR1_TO_SM(UTSR1_PRE)) 235 - sport->port.icount.parity++; 236 - else if (status & UTSR1_TO_SM(UTSR1_FRE)) 237 - sport->port.icount.frame++; 238 - if (status & UTSR1_TO_SM(UTSR1_ROR)) 239 - sport->port.icount.overrun++; 240 - 241 - if (status & sport->port.ignore_status_mask) { 242 - if (++ignored > 100) 243 - goto out; 244 - goto ignore_char; 245 - } 246 - 247 - status &= sport->port.read_status_mask; 248 - 249 - if (status & UTSR1_TO_SM(UTSR1_PRE)) 250 - flg = TTY_PARITY; 251 - else if (status & UTSR1_TO_SM(UTSR1_FRE)) 252 - flg = TTY_FRAME; 253 - 254 - if (status & UTSR1_TO_SM(UTSR1_ROR)) { 255 - /* 256 - * overrun does *not* affect the character 257 - * we read from the FIFO 258 - */ 259 - tty_insert_flip_char(tty, ch, flg); 260 - ch = 0; 261 - flg = TTY_OVERRUN; 262 - } 263 - #ifdef SUPPORT_SYSRQ 264 - sport->port.sysrq = 0; 265 - #endif 266 - goto error_return; 267 250 } 268 251 269 252 static void sa1100_tx_chars(struct sa1100_port *sport)