Skip to content

Commit

Permalink
Merge tag 'tty-4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…git/gregkh/tty

Pull tty/serial fixes from Greg KH:
 "Here are some tty/serial driver fixes for 4.4-rc6 that resolve some
  reported problems.  All of these have been in linux-next.  The details
  are in the shortlog"

* tag 'tty-4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
  tty: Fix GPF in flush_to_ldisc()
  serial: earlycon: Add missing spinlock initialization
  serial: sh-sci: Fix length of scatterlist
  n_tty: Fix poll() after buffer-limited eof push read
  serial: 8250_uniphier: fix dl_read and dl_write functions
  • Loading branch information
torvalds committed Dec 20, 2015
2 parents 24b0d5e + 9ce119f commit 69c37a9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
22 changes: 9 additions & 13 deletions drivers/tty/n_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -2054,13 +2054,13 @@ static int canon_copy_from_read_buf(struct tty_struct *tty,
size_t eol;
size_t tail;
int ret, found = 0;
bool eof_push = 0;

/* N.B. avoid overrun if nr == 0 */
n = min(*nr, smp_load_acquire(&ldata->canon_head) - ldata->read_tail);
if (!n)
if (!*nr)
return 0;

n = min(*nr + 1, smp_load_acquire(&ldata->canon_head) - ldata->read_tail);

tail = ldata->read_tail & (N_TTY_BUF_SIZE - 1);
size = min_t(size_t, tail + n, N_TTY_BUF_SIZE);

Expand All @@ -2081,12 +2081,11 @@ static int canon_copy_from_read_buf(struct tty_struct *tty,
n = eol - tail;
if (n > N_TTY_BUF_SIZE)
n += N_TTY_BUF_SIZE;
n += found;
c = n;
c = n + found;

if (found && !ldata->push && read_buf(ldata, eol) == __DISABLED_CHAR) {
n--;
eof_push = !n && ldata->read_tail != ldata->line_start;
if (!found || read_buf(ldata, eol) != __DISABLED_CHAR) {
c = min(*nr, c);
n = c;
}

n_tty_trace("%s: eol:%zu found:%d n:%zu c:%zu size:%zu more:%zu\n",
Expand Down Expand Up @@ -2116,7 +2115,7 @@ static int canon_copy_from_read_buf(struct tty_struct *tty,
ldata->push = 0;
tty_audit_push(tty);
}
return eof_push ? -EAGAIN : 0;
return 0;
}

extern ssize_t redirected_tty_write(struct file *, const char __user *,
Expand Down Expand Up @@ -2273,10 +2272,7 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,

if (ldata->icanon && !L_EXTPROC(tty)) {
retval = canon_copy_from_read_buf(tty, &b, &nr);
if (retval == -EAGAIN) {
retval = 0;
continue;
} else if (retval)
if (retval)
break;
} else {
int uncopied;
Expand Down
8 changes: 6 additions & 2 deletions drivers/tty/serial/8250/8250_uniphier.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,16 @@ static void uniphier_serial_out(struct uart_port *p, int offset, int value)
*/
static int uniphier_serial_dl_read(struct uart_8250_port *up)
{
return readl(up->port.membase + UNIPHIER_UART_DLR);
int offset = UNIPHIER_UART_DLR << up->port.regshift;

return readl(up->port.membase + offset);
}

static void uniphier_serial_dl_write(struct uart_8250_port *up, int value)
{
writel(value, up->port.membase + UNIPHIER_UART_DLR);
int offset = UNIPHIER_UART_DLR << up->port.regshift;

writel(value, up->port.membase + offset);
}

static int uniphier_of_serial_setup(struct device *dev, struct uart_port *port,
Expand Down
2 changes: 2 additions & 0 deletions drivers/tty/serial/earlycon.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match)
if (buf && !parse_options(&early_console_dev, buf))
buf = NULL;

spin_lock_init(&port->lock);
port->uartclk = BASE_BAUD * 16;
if (port->mapbase)
port->membase = earlycon_map(port->mapbase, 64);
Expand Down Expand Up @@ -202,6 +203,7 @@ int __init of_setup_earlycon(unsigned long addr,
int err;
struct uart_port *port = &early_console_dev.port;

spin_lock_init(&port->lock);
port->iotype = UPIO_MEM;
port->mapbase = addr;
port->uartclk = BASE_BAUD * 16;
Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/serial/sh-sci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ static void sci_request_dma(struct uart_port *port)
sg_init_table(sg, 1);
s->rx_buf[i] = buf;
sg_dma_address(sg) = dma;
sg->length = s->buf_len_rx;
sg_dma_len(sg) = s->buf_len_rx;

buf += s->buf_len_rx;
dma += s->buf_len_rx;
Expand Down
2 changes: 1 addition & 1 deletion drivers/tty/tty_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ receive_buf(struct tty_struct *tty, struct tty_buffer *head, int count)
count = disc->ops->receive_buf2(tty, p, f, count);
else {
count = min_t(int, count, tty->receive_room);
if (count)
if (count && disc->ops->receive_buf)
disc->ops->receive_buf(tty, p, f, count);
}
return count;
Expand Down

0 comments on commit 69c37a9

Please sign in to comment.