hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/tty/serial/altera_uart.c
....@@ -199,9 +199,8 @@
199199 */
200200 }
201201
202
-static void altera_uart_rx_chars(struct altera_uart *pp)
202
+static void altera_uart_rx_chars(struct uart_port *port)
203203 {
204
- struct uart_port *port = &pp->port;
205204 unsigned char ch, flag;
206205 unsigned short status;
207206
....@@ -248,9 +247,8 @@
248247 spin_lock(&port->lock);
249248 }
250249
251
-static void altera_uart_tx_chars(struct altera_uart *pp)
250
+static void altera_uart_tx_chars(struct uart_port *port)
252251 {
253
- struct uart_port *port = &pp->port;
254252 struct circ_buf *xmit = &port->state->xmit;
255253
256254 if (port->x_char) {
....@@ -274,26 +272,25 @@
274272 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
275273 uart_write_wakeup(port);
276274
277
- if (xmit->head == xmit->tail) {
278
- pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK;
279
- altera_uart_update_ctrl_reg(pp);
280
- }
275
+ if (uart_circ_empty(xmit))
276
+ altera_uart_stop_tx(port);
281277 }
282278
283279 static irqreturn_t altera_uart_interrupt(int irq, void *data)
284280 {
285281 struct uart_port *port = data;
286282 struct altera_uart *pp = container_of(port, struct altera_uart, port);
283
+ unsigned long flags;
287284 unsigned int isr;
288285
289286 isr = altera_uart_readl(port, ALTERA_UART_STATUS_REG) & pp->imr;
290287
291
- spin_lock(&port->lock);
288
+ spin_lock_irqsave(&port->lock, flags);
292289 if (isr & ALTERA_UART_STATUS_RRDY_MSK)
293
- altera_uart_rx_chars(pp);
290
+ altera_uart_rx_chars(port);
294291 if (isr & ALTERA_UART_STATUS_TRDY_MSK)
295
- altera_uart_tx_chars(pp);
296
- spin_unlock(&port->lock);
292
+ altera_uart_tx_chars(port);
293
+ spin_unlock_irqrestore(&port->lock, flags);
297294
298295 return IRQ_RETVAL(isr);
299296 }