serial: usbtty: Send urb data in correct order
authorPali Rohár <pali@kernel.org>
Sun, 7 Feb 2021 13:50:02 +0000 (14:50 +0100)
committerMarek Vasut <marex@denx.de>
Wed, 3 Mar 2021 03:12:45 +0000 (04:12 +0100)
commit7f840c1b264e04e697c7c0010d1bfe6049c76758
tree70481471019904b98aaf2304953f90d0aae8a04c
parentd3fb8fee7d8225845cedfd0b9d23b2a8d6f8c6ee
serial: usbtty: Send urb data in correct order

Function next_urb() selects the last urb data buffer from linked list to
which next data from usbtty's puts function should be appended.

But to check if TX data still exists it is needed to look at the first urb
data buffer from linked list. So check for endpoint->tx_urb (first from the
linked list) instead of current_urb (the last from the linked list).

Successful call to udc_endpoint_write() may invalidate active urb and
allocate new urb in queue which invalidates pointer returned by next_urb()
function.

So call next_urb() prior putting data into urb buffer and call it every
time after using udc_endpoint_write() function to prevent sending data from
usbtty's puts function in incorrect order.

This patch fixes issue that usbtty code does not transmit data when they
are waiting in the tx queue.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
drivers/serial/usbtty.c