Commit fdfb719e authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman
Browse files

tty: Remove chars_in_buffer() line discipline method



The chars_in_buffer() line discipline method serves no functional
purpose, other than as a (dubious) debugging aid for mostly bit-rotting
drivers. Despite being documented as an optional method, every caller
is unconditionally executed (although conditionally compiled).
Furthermore, direct tty->ldisc access without an ldisc ref is unsafe.
Lastly, N_TTY's chars_in_buffer() has warned of removal since 3.12.

Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 582e20a0
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -72,9 +72,6 @@ flush_buffer() - (optional) May be called at any point between
			open and close, and instructs the line discipline
			to empty its input buffer.

chars_in_buffer() -	(optional) Report the number of bytes in the input
			buffer.

set_termios()	-	(optional) Called on termios structure changes.
			The caller passes the old termios data and the
			current data is in the tty. Called under the
+2 −4
Original line number Diff line number Diff line
@@ -965,8 +965,7 @@ static void rs_throttle(struct tty_struct * tty)
	struct serial_state *info = tty->driver_data;
	unsigned long flags;
#ifdef SERIAL_DEBUG_THROTTLE
	printk("throttle %s: %d....\n", tty_name(tty),
	       tty->ldisc.chars_in_buffer(tty));
	printk("throttle %s ....\n", tty_name(tty));
#endif

	if (serial_paranoia_check(info, tty->name, "rs_throttle"))
@@ -988,8 +987,7 @@ static void rs_unthrottle(struct tty_struct * tty)
	struct serial_state *info = tty->driver_data;
	unsigned long flags;
#ifdef SERIAL_DEBUG_THROTTLE
	printk("unthrottle %s: %d....\n", tty_name(tty),
	       tty->ldisc.chars_in_buffer(tty));
	printk("unthrottle %s ....\n", tty_name(tty));
#endif

	if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
+4 −4
Original line number Diff line number Diff line
@@ -2852,8 +2852,8 @@ static void cy_throttle(struct tty_struct *tty)
	unsigned long flags;

#ifdef CY_DEBUG_THROTTLE
	printk(KERN_DEBUG "cyc:throttle %s: %ld...ttyC%d\n", tty_name(tty),
			tty->ldisc.chars_in_buffer(tty), info->line);
	printk(KERN_DEBUG "cyc:throttle %s ...ttyC%d\n", tty_name(tty),
			 info->line);
#endif

	if (serial_paranoia_check(info, tty->name, "cy_throttle"))
@@ -2891,8 +2891,8 @@ static void cy_unthrottle(struct tty_struct *tty)
	unsigned long flags;

#ifdef CY_DEBUG_THROTTLE
	printk(KERN_DEBUG "cyc:unthrottle %s: %ld...ttyC%d\n",
		tty_name(tty), tty_chars_in_buffer(tty), info->line);
	printk(KERN_DEBUG "cyc:unthrottle %s ...ttyC%d\n",
		tty_name(tty), info->line);
#endif

	if (serial_paranoia_check(info, tty->name, "cy_unthrottle"))
+0 −16
Original line number Diff line number Diff line
@@ -2303,21 +2303,6 @@ static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp,
	/* If clogged call tty_throttle(tty); */
}

/**
 *	gsmld_chars_in_buffer	-	report available bytes
 *	@tty: tty device
 *
 *	Report the number of characters buffered to be delivered to user
 *	at this instant in time.
 *
 *	Locking: gsm lock
 */

static ssize_t gsmld_chars_in_buffer(struct tty_struct *tty)
{
	return 0;
}

/**
 *	gsmld_flush_buffer	-	clean input queue
 *	@tty:	terminal device
@@ -2830,7 +2815,6 @@ static struct tty_ldisc_ops tty_ldisc_packet = {
	.open            = gsmld_open,
	.close           = gsmld_close,
	.flush_buffer    = gsmld_flush_buffer,
	.chars_in_buffer = gsmld_chars_in_buffer,
	.read            = gsmld_read,
	.write           = gsmld_write,
	.ioctl           = gsmld_ioctl,
+0 −23
Original line number Diff line number Diff line
@@ -380,28 +380,6 @@ static void n_tty_flush_buffer(struct tty_struct *tty)
	up_write(&tty->termios_rwsem);
}

/**
 *	n_tty_chars_in_buffer	-	report available bytes
 *	@tty: tty device
 *
 *	Report the number of characters buffered to be delivered to user
 *	at this instant in time.
 *
 *	Locking: exclusive termios_rwsem
 */

static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty)
{
	ssize_t n;

	WARN_ONCE(1, "%s is deprecated and scheduled for removal.", __func__);

	down_write(&tty->termios_rwsem);
	n = chars_in_buffer(tty);
	up_write(&tty->termios_rwsem);
	return n;
}

/**
 *	is_utf8_continuation	-	utf8 multibyte check
 *	@c: byte to check
@@ -2525,7 +2503,6 @@ struct tty_ldisc_ops tty_ldisc_N_TTY = {
	.open            = n_tty_open,
	.close           = n_tty_close,
	.flush_buffer    = n_tty_flush_buffer,
	.chars_in_buffer = n_tty_chars_in_buffer,
	.read            = n_tty_read,
	.write           = n_tty_write,
	.ioctl           = n_tty_ioctl,
Loading