Skip to content

Commit

Permalink
serial: sh-sci: Use tty_insert_flip_string() for DMA receive
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Geert Uytterhoeven authored and Greg Kroah-Hartman committed Oct 4, 2015
1 parent 0533502 commit 47b0e94
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions drivers/tty/serial/sh-sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1306,22 +1306,18 @@ static int sci_dma_rx_push(struct sci_port *s, struct scatterlist *sg,
{
struct uart_port *port = &s->port;
struct tty_port *tport = &port->state->port;
int i, room;
int copied;

room = tty_buffer_request_room(tport, count);

if (room < count)
copied = tty_insert_flip_string(tport, sg_virt(sg), count);
if (copied < count) {
dev_warn(port->dev, "Rx overrun: dropping %zu bytes\n",
count - room);
if (!room)
return room;

for (i = 0; i < room; i++)
tty_insert_flip_char(tport, ((u8 *)sg_virt(sg))[i], TTY_NORMAL);
count - copied);
port->icount.buf_overrun++;
}

port->icount.rx += room;
port->icount.rx += copied;

return room;
return copied;
}

static int sci_dma_rx_find_active(struct sci_port *s)
Expand Down

0 comments on commit 47b0e94

Please sign in to comment.