Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b1c43f82 authored by Felipe Balbi's avatar Felipe Balbi Committed by Greg Kroah-Hartman
Browse files

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: default avatarStefan Bigler <stefan.bigler@keymile.com>
Tested-by: default avatarToby Gray <toby.gray@realvnc.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e9a470f4
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -357,22 +357,26 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)
 *     
 * Return Value:    None
 */
static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count)
static unsigned int hci_uart_tty_receive(struct tty_struct *tty,
		const u8 *data, char *flags, int count)
{
	struct hci_uart *hu = (void *)tty->disc_data;
	int received;

	if (!hu || tty != hu->tty)
		return;
		return -ENODEV;

	if (!test_bit(HCI_UART_PROTO_SET, &hu->flags))
		return;
		return -EINVAL;

	spin_lock(&hu->rx_lock);
	hu->proto->recv(hu, (void *) data, count);
	received = hu->proto->recv(hu, (void *) data, count);
	hu->hdev->stat.byte_rx += count;
	spin_unlock(&hu->rx_lock);

	tty_unthrottle(tty);

	return received;
}

static int hci_uart_register_dev(struct hci_uart *hu)
+8 −2
Original line number Diff line number Diff line
@@ -120,17 +120,21 @@ static void serport_ldisc_close(struct tty_struct *tty)
 * 'interrupt' routine.
 */

static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count)
static unsigned int serport_ldisc_receive(struct tty_struct *tty,
		const unsigned char *cp, char *fp, int count)
{
	struct serport *serport = (struct serport*) tty->disc_data;
	unsigned long flags;
	unsigned int ch_flags;
	int ret = 0;
	int i;

	spin_lock_irqsave(&serport->lock, flags);

	if (!test_bit(SERPORT_ACTIVE, &serport->flags))
	if (!test_bit(SERPORT_ACTIVE, &serport->flags)) {
		ret = -EINVAL;
		goto out;
	}

	for (i = 0; i < count; i++) {
		switch (fp[i]) {
@@ -152,6 +156,8 @@ static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *c

out:
	spin_unlock_irqrestore(&serport->lock, flags);

	return ret == 0 ? count : ret;
}

/*
+5 −3
Original line number Diff line number Diff line
@@ -674,7 +674,7 @@ gigaset_tty_ioctl(struct tty_struct *tty, struct file *file,
 *	cflags	buffer containing error flags for received characters (ignored)
 *	count	number of received characters
 */
static void
static unsigned int
gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
		    char *cflags, int count)
{
@@ -683,12 +683,12 @@ gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
	struct inbuf_t *inbuf;

	if (!cs)
		return;
		return -ENODEV;
	inbuf = cs->inbuf;
	if (!inbuf) {
		dev_err(cs->dev, "%s: no inbuf\n", __func__);
		cs_put(cs);
		return;
		return -EINVAL;
	}

	tail = inbuf->tail;
@@ -725,6 +725,8 @@ gigaset_tty_receive(struct tty_struct *tty, const unsigned char *buf,
	gig_dbg(DEBUG_INTR, "%s-->BH", __func__);
	gigaset_schedule_event(cs);
	cs_put(cs);

	return count;
}

/*
+4 −2
Original line number Diff line number Diff line
@@ -744,8 +744,8 @@ static void st_tty_close(struct tty_struct *tty)
	pr_debug("%s: done ", __func__);
}

static void st_tty_receive(struct tty_struct *tty, const unsigned char *data,
			   char *tty_flags, int count)
static unsigned int st_tty_receive(struct tty_struct *tty,
		const unsigned char *data, char *tty_flags, int count)
{
#ifdef VERBOSE
	print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE,
@@ -758,6 +758,8 @@ static void st_tty_receive(struct tty_struct *tty, const unsigned char *data,
	 */
	st_recv(tty->disc_data, data, count);
	pr_debug("done %s", __func__);

	return count;
}

/* wake-up function called in from the TTY layer
+4 −2
Original line number Diff line number Diff line
@@ -167,8 +167,8 @@ static inline void debugfs_tx(struct ser_device *ser, const u8 *data, int size)

#endif

static void ldisc_receive(struct tty_struct *tty, const u8 *data,
			char *flags, int count)
static unsigned int ldisc_receive(struct tty_struct *tty,
		const u8 *data, char *flags, int count)
{
	struct sk_buff *skb = NULL;
	struct ser_device *ser;
@@ -215,6 +215,8 @@ static void ldisc_receive(struct tty_struct *tty, const u8 *data,
	} else
		++ser->dev->stats.rx_dropped;
	update_tty_status(ser);

	return count;
}

static int handle_tx(struct ser_device *ser)
Loading