/* Open the high-level part of the X.25 channel. This function is called by the TTY module when the X.25 line discipline is called for. Because we are sure the tty line exists, we only have to link it to a free X.25 channel...  */
static int x25_asy_open_tty(struct tty_struct *tty)
/* Open the high-level part of the X.25 channel. This function is called by the TTY module when the X.25 line discipline is called for. Because we are sure the tty line exists, we only have to link it to a free X.25 channel...  */
static int x25_asy_open_tty(struct tty_struct *tty)
{
	struct x25_asy *sl = tty->disc_data;
	int err;
	if (tty->ops->write == NULL)
		return -EOPNOTSUPP;
	if (sl && sl->magic == X25_ASY_MAGIC)
		return -EEXIST;
	sl = x25_asy_alloc();
	if (sl == NULL)
		return -ENFILE;
	sl->tty = tty;
	tty->disc_data = sl;
	tty->receive_room = 65536;
	tty_driver_flush_buffer(tty);
	tty_ldisc_flush(tty);
	sl->dev->type = ARPHRD_X25;
	err = x25_asy_open(sl->dev);
	if (err)
		return err;
	return sl->dev->base_addr;
}