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
@@ -670,16 +670,17 @@ static void sl_setup(struct net_device *dev)
|
||||
* in parallel
|
||||
*/
|
||||
|
||||
static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp,
|
||||
char *fp, int count)
|
||||
static unsigned int slip_receive_buf(struct tty_struct *tty,
|
||||
const unsigned char *cp, char *fp, int count)
|
||||
{
|
||||
struct slip *sl = tty->disc_data;
|
||||
int bytes = count;
|
||||
|
||||
if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev))
|
||||
return;
|
||||
return -ENODEV;
|
||||
|
||||
/* Read the characters out of the buffer */
|
||||
while (count--) {
|
||||
while (bytes--) {
|
||||
if (fp && *fp++) {
|
||||
if (!test_and_set_bit(SLF_ERROR, &sl->flags))
|
||||
sl->dev->stats.rx_errors++;
|
||||
@@ -693,6 +694,8 @@ static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp,
|
||||
#endif
|
||||
slip_unesc(sl, *cp++);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/************************************
|
||||
|
||||
Reference in New Issue
Block a user