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 7e1d19805aa4795e2d23a3f1077d54f2c9b6b2a1..da10e975829f927ff1a63e604a40c173218e4c94 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 04a792749816d2d8794a3db125f10b64d3b83f57..3106df98558aaa760d8c017f28ba9b668370ea02 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;