OSDN Git Service

tty: make everyone's chars_in_buffer return >= 0
authorJiri Slaby <jslaby@suse.cz>
Tue, 2 Mar 2021 06:22:13 +0000 (07:22 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Mar 2021 08:34:09 +0000 (09:34 +0100)
The tty line disciplines don't expect tty_operations::chars_in_buffer to
return negative values. Fix the two drivers which violate this.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20210302062214.29627-43-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/n_gsm.c
drivers/tty/vcc.c

index 7e1d198..da10e97 100644 (file)
@@ -3056,7 +3056,7 @@ static int gsmtty_chars_in_buffer(struct tty_struct *tty)
 {
        struct gsm_dlci *dlci = tty->driver_data;
        if (dlci->state == DLCI_CLOSED)
-               return -EINVAL;
+               return 0;
        return kfifo_len(&dlci->fifo);
 }
 
index 04a7927..3106df9 100644 (file)
@@ -896,7 +896,7 @@ static int vcc_chars_in_buffer(struct tty_struct *tty)
        port = vcc_get_ne(tty->index);
        if (unlikely(!port)) {
                pr_err("VCC: chars_in_buffer: Failed to find VCC port\n");
-               return -ENODEV;
+               return 0;
        }
 
        num = port->chars_in_buffer;