tty: make receive_buf() return the amout of bytes received
it makes it simpler to keep track of the amount of bytes received and simplifies how flush_to_ldisc counts the remaining bytes. It also fixes a bug of lost bytes on n_tty when flushing too many bytes via the USB serial gadget driver. Tested-by: Stefan Bigler <stefan.bigler@keymile.com> Tested-by: Toby Gray <toby.gray@realvnc.com> Signed-off-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
e9a470f445
commit
b1c43f82c5
@@ -357,22 +357,26 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)
|
||||
*
|
||||
* Return Value: None
|
||||
*/
|
||||
static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count)
|
||||
static unsigned int hci_uart_tty_receive(struct tty_struct *tty,
|
||||
const u8 *data, char *flags, int count)
|
||||
{
|
||||
struct hci_uart *hu = (void *)tty->disc_data;
|
||||
int received;
|
||||
|
||||
if (!hu || tty != hu->tty)
|
||||
return;
|
||||
return -ENODEV;
|
||||
|
||||
if (!test_bit(HCI_UART_PROTO_SET, &hu->flags))
|
||||
return;
|
||||
return -EINVAL;
|
||||
|
||||
spin_lock(&hu->rx_lock);
|
||||
hu->proto->recv(hu, (void *) data, count);
|
||||
received = hu->proto->recv(hu, (void *) data, count);
|
||||
hu->hdev->stat.byte_rx += count;
|
||||
spin_unlock(&hu->rx_lock);
|
||||
|
||||
tty_unthrottle(tty);
|
||||
|
||||
return received;
|
||||
}
|
||||
|
||||
static int hci_uart_register_dev(struct hci_uart *hu)
|
||||
|
Reference in New Issue
Block a user