diff options
author | Felipe Balbi <balbi@ti.com> | 2011-03-21 06:25:08 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-04-22 20:31:53 -0400 |
commit | b1c43f82c5aa265442f82dba31ce985ebb7aa71c (patch) | |
tree | 8b344d8d5355b30e8deff901180edc708a653227 /drivers/net/can | |
parent | e9a470f445271eb157ee860a93b062324402fc3a (diff) |
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>
Diffstat (limited to 'drivers/net/can')
-rw-r--r-- | drivers/net/can/slcan.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index b423965a78d1..c600954998d5 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c | |||
@@ -425,16 +425,17 @@ static void slc_setup(struct net_device *dev) | |||
425 | * in parallel | 425 | * in parallel |
426 | */ | 426 | */ |
427 | 427 | ||
428 | static void slcan_receive_buf(struct tty_struct *tty, | 428 | static unsigned int slcan_receive_buf(struct tty_struct *tty, |
429 | const unsigned char *cp, char *fp, int count) | 429 | const unsigned char *cp, char *fp, int count) |
430 | { | 430 | { |
431 | struct slcan *sl = (struct slcan *) tty->disc_data; | 431 | struct slcan *sl = (struct slcan *) tty->disc_data; |
432 | int bytes = count; | ||
432 | 433 | ||
433 | if (!sl || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev)) | 434 | if (!sl || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev)) |
434 | return; | 435 | return -ENODEV; |
435 | 436 | ||
436 | /* Read the characters out of the buffer */ | 437 | /* Read the characters out of the buffer */ |
437 | while (count--) { | 438 | while (bytes--) { |
438 | if (fp && *fp++) { | 439 | if (fp && *fp++) { |
439 | if (!test_and_set_bit(SLF_ERROR, &sl->flags)) | 440 | if (!test_and_set_bit(SLF_ERROR, &sl->flags)) |
440 | sl->dev->stats.rx_errors++; | 441 | sl->dev->stats.rx_errors++; |
@@ -443,6 +444,8 @@ static void slcan_receive_buf(struct tty_struct *tty, | |||
443 | } | 444 | } |
444 | slcan_unesc(sl, *cp++); | 445 | slcan_unesc(sl, *cp++); |
445 | } | 446 | } |
447 | |||
448 | return count; | ||
446 | } | 449 | } |
447 | 450 | ||
448 | /************************************ | 451 | /************************************ |