提交 23198fda 编写于 作者: A Alan Cox 提交者: Linus Torvalds

tty: fix chars_in_buffers

This function does not have an error return and returning an error is
instead interpreted as having a lot of pending bytes.

Reported by Jeff Harris who provided a list of some of the remaining
offenders.
Signed-off-by: NAlan Cox <alan@linux.intel.com>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 25470256
...@@ -552,7 +552,7 @@ static int hvc_chars_in_buffer(struct tty_struct *tty) ...@@ -552,7 +552,7 @@ static int hvc_chars_in_buffer(struct tty_struct *tty)
struct hvc_struct *hp = tty->driver_data; struct hvc_struct *hp = tty->driver_data;
if (!hp) if (!hp)
return -1; return 0;
return hp->n_outbuf; return hp->n_outbuf;
} }
......
...@@ -1866,16 +1866,14 @@ static s32 ntty_chars_in_buffer(struct tty_struct *tty) ...@@ -1866,16 +1866,14 @@ static s32 ntty_chars_in_buffer(struct tty_struct *tty)
{ {
struct port *port = tty->driver_data; struct port *port = tty->driver_data;
struct nozomi *dc = get_dc_by_tty(tty); struct nozomi *dc = get_dc_by_tty(tty);
s32 rval; s32 rval = 0;
if (unlikely(!dc || !port)) { if (unlikely(!dc || !port)) {
rval = -ENODEV;
goto exit_in_buffer; goto exit_in_buffer;
} }
if (unlikely(!port->port.count)) { if (unlikely(!port->port.count)) {
dev_err(&dc->pdev->dev, "No tty open?\n"); dev_err(&dc->pdev->dev, "No tty open?\n");
rval = -ENODEV;
goto exit_in_buffer; goto exit_in_buffer;
} }
......
...@@ -320,10 +320,10 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty) ...@@ -320,10 +320,10 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
struct ipw_tty *tty = linux_tty->driver_data; struct ipw_tty *tty = linux_tty->driver_data;
if (!tty) if (!tty)
return -ENODEV; return 0;
if (!tty->open_count) if (!tty->open_count)
return -EINVAL; return 0;
return tty->tx_bytes_queued; return tty->tx_bytes_queued;
} }
......
...@@ -408,6 +408,8 @@ static int if_write_room(struct tty_struct *tty) ...@@ -408,6 +408,8 @@ static int if_write_room(struct tty_struct *tty)
return retval; return retval;
} }
/* FIXME: This function does not have error returns */
static int if_chars_in_buffer(struct tty_struct *tty) static int if_chars_in_buffer(struct tty_struct *tty)
{ {
struct cardstate *cs; struct cardstate *cs;
......
...@@ -750,7 +750,7 @@ static int acm_tty_chars_in_buffer(struct tty_struct *tty) ...@@ -750,7 +750,7 @@ static int acm_tty_chars_in_buffer(struct tty_struct *tty)
{ {
struct acm *acm = tty->driver_data; struct acm *acm = tty->driver_data;
if (!ACM_READY(acm)) if (!ACM_READY(acm))
return -EINVAL; return 0;
/* /*
* This is inaccurate (overcounts), but it works. * This is inaccurate (overcounts), but it works.
*/ */
......
...@@ -521,7 +521,7 @@ static int mos7720_chars_in_buffer(struct tty_struct *tty) ...@@ -521,7 +521,7 @@ static int mos7720_chars_in_buffer(struct tty_struct *tty)
mos7720_port = usb_get_serial_port_data(port); mos7720_port = usb_get_serial_port_data(port);
if (mos7720_port == NULL) { if (mos7720_port == NULL) {
dbg("%s:leaving ...........", __func__); dbg("%s:leaving ...........", __func__);
return -ENODEV; return 0;
} }
for (i = 0; i < NUM_URBS; ++i) { for (i = 0; i < NUM_URBS; ++i) {
......
...@@ -727,7 +727,7 @@ static int ti_write_room(struct tty_struct *tty) ...@@ -727,7 +727,7 @@ static int ti_write_room(struct tty_struct *tty)
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
if (tport == NULL) if (tport == NULL)
return -ENODEV; return 0;
spin_lock_irqsave(&tport->tp_lock, flags); spin_lock_irqsave(&tport->tp_lock, flags);
room = ti_buf_space_avail(tport->tp_write_buf); room = ti_buf_space_avail(tport->tp_write_buf);
...@@ -748,7 +748,7 @@ static int ti_chars_in_buffer(struct tty_struct *tty) ...@@ -748,7 +748,7 @@ static int ti_chars_in_buffer(struct tty_struct *tty)
dbg("%s - port %d", __func__, port->number); dbg("%s - port %d", __func__, port->number);
if (tport == NULL) if (tport == NULL)
return -ENODEV; return 0;
spin_lock_irqsave(&tport->tp_lock, flags); spin_lock_irqsave(&tport->tp_lock, flags);
chars = ti_buf_data_avail(tport->tp_write_buf); chars = ti_buf_data_avail(tport->tp_write_buf);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册