aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/serio/serport.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/input/serio/serport.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/input/serio/serport.c')
-rw-r--r--drivers/input/serio/serport.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index 8755f5f3ad37..f3698967edf6 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -120,17 +120,21 @@ static void serport_ldisc_close(struct tty_struct *tty)
120 * 'interrupt' routine. 120 * 'interrupt' routine.
121 */ 121 */
122 122
123static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) 123static unsigned int serport_ldisc_receive(struct tty_struct *tty,
124 const unsigned char *cp, char *fp, int count)
124{ 125{
125 struct serport *serport = (struct serport*) tty->disc_data; 126 struct serport *serport = (struct serport*) tty->disc_data;
126 unsigned long flags; 127 unsigned long flags;
127 unsigned int ch_flags; 128 unsigned int ch_flags;
129 int ret = 0;
128 int i; 130 int i;
129 131
130 spin_lock_irqsave(&serport->lock, flags); 132 spin_lock_irqsave(&serport->lock, flags);
131 133
132 if (!test_bit(SERPORT_ACTIVE, &serport->flags)) 134 if (!test_bit(SERPORT_ACTIVE, &serport->flags)) {
135 ret = -EINVAL;
133 goto out; 136 goto out;
137 }
134 138
135 for (i = 0; i < count; i++) { 139 for (i = 0; i < count; i++) {
136 switch (fp[i]) { 140 switch (fp[i]) {
@@ -152,6 +156,8 @@ static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *c
152 156
153out: 157out:
154 spin_unlock_irqrestore(&serport->lock, flags); 158 spin_unlock_irqrestore(&serport->lock, flags);
159
160 return ret == 0 ? count : ret;
155} 161}
156 162
157/* 163/*