/* tty->count serves to decide whether the device should be enabled or disabled on the host. If it's equal to 1, then we are doing the first open or last close. Otherwise, open and close just return.  */
int line_open(struct line *lines, struct tty_struct *tty)
/* tty->count serves to decide whether the device should be enabled or disabled on the host. If it's equal to 1, then we are doing the first open or last close. Otherwise, open and close just return.  */
int line_open(struct line *lines, struct tty_struct *tty)
{
	struct line *line = &lines[tty->index];
	int err = -ENODEV;
	spin_lock(&line->count_lock);
	if (!line->valid)
		goto out_unlock;
	err = 0;
	if (tty->count > 1)
		goto out_unlock;
	spin_unlock(&line->count_lock);
	tty->driver_data = line;
	line->tty = tty;
	err = enable_chan(line);
	if (err)
		return err;
	INIT_DELAYED_WORK(&line->task, line_timer_cb);
	if (!line->sigio) {
		chan_enable_winch(&line->chan_list, tty);
		line->sigio = 1;
	}
	chan_window_size(&line->chan_list, &tty->winsize.ws_row,
			 &tty->winsize.ws_col);
	return err;
out_unlock:
	spin_unlock(&line->count_lock);
	return err;
}