/* Calculate how much is left in device This method is called by the upper tty layer. #according to sources N_TTY.c it expects a value >= 0 and does not check for negative values.  */
static int ntty_write_room(struct tty_struct *tty)
/* Calculate how much is left in device This method is called by the upper tty layer. #according to sources N_TTY.c it expects a value >= 0 and does not check for negative values.  */
static int ntty_write_room(struct tty_struct *tty)
{
	struct port *port = tty->driver_data;
	int room = 0;
	const struct nozomi *dc = get_dc_by_tty(tty);
	if (!dc || !port)
		return 0;
	if (!mutex_trylock(&port->tty_sem))
		return 0;
	if (!port->port.count)
		goto exit;
	room = port->fifo_ul.size - kfifo_len(&port->fifo_ul);
exit:
	mutex_unlock(&port->tty_sem);
	return room;
}