aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
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/bluetooth
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/bluetooth')
-rw-r--r--drivers/bluetooth/hci_ldisc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 48ad2a7ab080..0d4da5e14ba0 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -357,22 +357,26 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)
357 * 357 *
358 * Return Value: None 358 * Return Value: None
359 */ 359 */
360static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count) 360static unsigned int hci_uart_tty_receive(struct tty_struct *tty,
361 const u8 *data, char *flags, int count)
361{ 362{
362 struct hci_uart *hu = (void *)tty->disc_data; 363 struct hci_uart *hu = (void *)tty->disc_data;
364 int received;
363 365
364 if (!hu || tty != hu->tty) 366 if (!hu || tty != hu->tty)
365 return; 367 return -ENODEV;
366 368
367 if (!test_bit(HCI_UART_PROTO_SET, &hu->flags)) 369 if (!test_bit(HCI_UART_PROTO_SET, &hu->flags))
368 return; 370 return -EINVAL;
369 371
370 spin_lock(&hu->rx_lock); 372 spin_lock(&hu->rx_lock);
371 hu->proto->recv(hu, (void *) data, count); 373 received = hu->proto->recv(hu, (void *) data, count);
372 hu->hdev->stat.byte_rx += count; 374 hu->hdev->stat.byte_rx += count;
373 spin_unlock(&hu->rx_lock); 375 spin_unlock(&hu->rx_lock);
374 376
375 tty_unthrottle(tty); 377 tty_unthrottle(tty);
378
379 return received;
376} 380}
377 381
378static int hci_uart_register_dev(struct hci_uart *hu) 382static int hci_uart_register_dev(struct hci_uart *hu)