/* This routine returns the number of characters in the write buffer of the SCLP driver. The provided number includes all characters that are stored in the SCCB (will be written next time the SCLP is not busy) as well as characters in the write buffer (will not be written as long as there is a final line feed missing).  */
static int sclp_tty_chars_in_buffer(struct tty_struct *tty)
/* This routine returns the number of characters in the write buffer of the SCLP driver. The provided number includes all characters that are stored in the SCCB (will be written next time the SCLP is not busy) as well as characters in the write buffer (will not be written as long as there is a final line feed missing).  */
static int sclp_tty_chars_in_buffer(struct tty_struct *tty)
{
	unsigned long flags;
	struct list_head *l;
	struct sclp_buffer *t;
	int count;
	spin_lock_irqsave(&sclp_tty_lock, flags);
	count = 0;
	if (sclp_ttybuf != NULL)
		count = sclp_chars_in_buffer(sclp_ttybuf);
	list_for_each(l, &sclp_tty_outqueue) {
		t = list_entry(l, struct sclp_buffer, list);
		count += sclp_chars_in_buffer(t);
	}
	spin_unlock_irqrestore(&sclp_tty_lock, flags);
	return count;
}