aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/slip.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2011-03-21 06:25:08 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-04-22 20:31:53 -0400
commitb1c43f82c5aa265442f82dba31ce985ebb7aa71c (patch)
tree8b344d8d5355b30e8deff901180edc708a653227 /drivers/net/slip.c
parente9a470f445271eb157ee860a93b062324402fc3a (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/slip.c')
-rw-r--r--drivers/net/slip.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 86cbb9ea2f26..86718d358395 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -670,16 +670,17 @@ static void sl_setup(struct net_device *dev)
670 * in parallel 670 * in parallel
671 */ 671 */
672 672
673static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp, 673static unsigned int slip_receive_buf(struct tty_struct *tty,
674 char *fp, int count) 674 const unsigned char *cp, char *fp, int count)
675{ 675{
676 struct slip *sl = tty->disc_data; 676 struct slip *sl = tty->disc_data;
677 int bytes = count;
677 678
678 if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev)) 679 if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev))
679 return; 680 return -ENODEV;
680 681
681 /* Read the characters out of the buffer */ 682 /* Read the characters out of the buffer */
682 while (count--) { 683 while (bytes--) {
683 if (fp && *fp++) { 684 if (fp && *fp++) {
684 if (!test_and_set_bit(SLF_ERROR, &sl->flags)) 685 if (!test_and_set_bit(SLF_ERROR, &sl->flags))
685 sl->dev->stats.rx_errors++; 686 sl->dev->stats.rx_errors++;
@@ -693,6 +694,8 @@ static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp,
693#endif 694#endif
694 slip_unesc(sl, *cp++); 695 slip_unesc(sl, *cp++);
695 } 696 }
697
698 return count;
696} 699}
697 700
698/************************************ 701/************************************