/* This routine returns the numbers of characters the tty driver will accept for queuing to be written. This number is subject to change as output buffers get emptied, or if the output flow control is acted. This is not an exact number because not every character needs the same space in the sccb. The worst case is a string of newlines. Every newlines creates a new mto which needs 8 bytes.  */
static int sclp_tty_write_room(struct tty_struct *tty)
/* This routine returns the numbers of characters the tty driver will accept for queuing to be written. This number is subject to change as output buffers get emptied, or if the output flow control is acted. This is not an exact number because not every character needs the same space in the sccb. The worst case is a string of newlines. Every newlines creates a new mto which needs 8 bytes.  */
static int sclp_tty_write_room(struct tty_struct *tty)
{
	unsigned long flags;
	struct list_head *l;
	int count;
	spin_lock_irqsave(&sclp_tty_lock, flags);
	count = 0;
	if (sclp_ttybuf != NULL)
		count = sclp_buffer_space(sclp_ttybuf) / sizeof(struct mto);
	list_for_each(l, &sclp_tty_pages)
		count += NR_EMPTY_MTO_PER_SCCB;
	spin_unlock_irqrestore(&sclp_tty_lock, flags);
	return count;
}