tty: fix chars_in_buffers
authorAlan Cox <alan@linux.intel.com>
Mon, 20 Jul 2009 15:05:27 +0000 (16:05 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 20 Jul 2009 23:38:43 +0000 (16:38 -0700)
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: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/char/hvc_console.c
drivers/char/nozomi.c
drivers/char/pcmcia/ipwireless/tty.c
drivers/isdn/gigaset/interface.c
drivers/usb/class/cdc-acm.c
drivers/usb/serial/mos7720.c
drivers/usb/serial/ti_usb_3410_5052.c

index 94e7e3c8c05ad3f0720aaae3d6df588eebd2d50b..d97779ef72cb2846dabe8487ebf4cc0b4c7c6bf3 100644 (file)
@@ -552,7 +552,7 @@ static int hvc_chars_in_buffer(struct tty_struct *tty)
        struct hvc_struct *hp = tty->driver_data;
 
        if (!hp)
-               return -1;
+               return 0;
        return hp->n_outbuf;
 }
 
index 280b41c507a723b12a62560f67d325151cbf979d..ec58d8c387ff2303f67db428622f68b7eff76057 100644 (file)
@@ -1866,16 +1866,14 @@ static s32 ntty_chars_in_buffer(struct tty_struct *tty)
 {
        struct port *port = tty->driver_data;
        struct nozomi *dc = get_dc_by_tty(tty);
-       s32 rval;
+       s32 rval = 0;
 
        if (unlikely(!dc || !port)) {
-               rval = -ENODEV;
                goto exit_in_buffer;
        }
 
        if (unlikely(!port->port.count)) {
                dev_err(&dc->pdev->dev, "No tty open?\n");
-               rval = -ENODEV;
                goto exit_in_buffer;
        }
 
index 569f2f7743a78ddc80f4e7714c6456506b8a4995..674b3ab3587d505458fbdb802fc0a7cbcdf7d2eb 100644 (file)
@@ -320,10 +320,10 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
        struct ipw_tty *tty = linux_tty->driver_data;
 
        if (!tty)
-               return -ENODEV;
+               return 0;
 
        if (!tty->open_count)
-               return -EINVAL;
+               return 0;
 
        return tty->tx_bytes_queued;
 }
index 1ebfcab746623d8fd09acf35d6b753afc0963c12..8ff7e35c70696de765b8ab3dc2e4b61a02ee3356 100644 (file)
@@ -408,6 +408,8 @@ static int if_write_room(struct tty_struct *tty)
        return retval;
 }
 
+/* FIXME: This function does not have error returns */
+
 static int if_chars_in_buffer(struct tty_struct *tty)
 {
        struct cardstate *cs;
index 5b15d9d8896b9b0efe08a7d44303486e6f290811..e1f89416ef8cdf6235b2cfcebdbda23ab213f7e7 100644 (file)
@@ -750,7 +750,7 @@ static int acm_tty_chars_in_buffer(struct tty_struct *tty)
 {
        struct acm *acm = tty->driver_data;
        if (!ACM_READY(acm))
-               return -EINVAL;
+               return 0;
        /*
         * This is inaccurate (overcounts), but it works.
         */
index bfc5ce000ef92e8d664407dfd62dbf0ba4592832..ccd4dd340d2cff34ed7cedcd9c108a8be5e856f6 100644 (file)
@@ -521,7 +521,7 @@ static int mos7720_chars_in_buffer(struct tty_struct *tty)
        mos7720_port = usb_get_serial_port_data(port);
        if (mos7720_port == NULL) {
                dbg("%s:leaving ...........", __func__);
-               return -ENODEV;
+               return 0;
        }
 
        for (i = 0; i < NUM_URBS; ++i) {
index 14971a926990575aa6afd30c5c364d4b7f1e8539..3bc609fe2242a574643fe84353cf9de665fc25e3 100644 (file)
@@ -727,7 +727,7 @@ static int ti_write_room(struct tty_struct *tty)
        dbg("%s - port %d", __func__, port->number);
 
        if (tport == NULL)
-               return -ENODEV;
+               return 0;
 
        spin_lock_irqsave(&tport->tp_lock, flags);
        room = ti_buf_space_avail(tport->tp_write_buf);
@@ -748,7 +748,7 @@ static int ti_chars_in_buffer(struct tty_struct *tty)
        dbg("%s - port %d", __func__, port->number);
 
        if (tport == NULL)
-               return -ENODEV;
+               return 0;
 
        spin_lock_irqsave(&tport->tp_lock, flags);
        chars = ti_buf_data_avail(tport->tp_write_buf);