Skip to content

Commit 47b0e94

Browse files
geertugregkh
authored andcommitted
serial: sh-sci: Use tty_insert_flip_string() for DMA receive
Switch from using tty_buffer_request_room() and looping over tty_insert_flip_char() to tty_insert_flip_string(). Keep track of buffer overruns in the icount structure, like serial_core.c does. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0533502 commit 47b0e94

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

drivers/tty/serial/sh-sci.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,22 +1306,18 @@ static int sci_dma_rx_push(struct sci_port *s, struct scatterlist *sg,
13061306
{
13071307
struct uart_port *port = &s->port;
13081308
struct tty_port *tport = &port->state->port;
1309-
int i, room;
1309+
int copied;
13101310

1311-
room = tty_buffer_request_room(tport, count);
1312-
1313-
if (room < count)
1311+
copied = tty_insert_flip_string(tport, sg_virt(sg), count);
1312+
if (copied < count) {
13141313
dev_warn(port->dev, "Rx overrun: dropping %zu bytes\n",
1315-
count - room);
1316-
if (!room)
1317-
return room;
1318-
1319-
for (i = 0; i < room; i++)
1320-
tty_insert_flip_char(tport, ((u8 *)sg_virt(sg))[i], TTY_NORMAL);
1314+
count - copied);
1315+
port->icount.buf_overrun++;
1316+
}
13211317

1322-
port->icount.rx += room;
1318+
port->icount.rx += copied;
13231319

1324-
return room;
1320+
return copied;
13251321
}
13261322

13271323
static int sci_dma_rx_find_active(struct sci_port *s)

0 commit comments

Comments
 (0)