Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc1e99d9 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman
Browse files

TTY: vt, add ->install



We need to initialize the console only on the first open. This is
usually what is done in the ->install hook. vt used to do this in
->open. Now we move it to ->install and use newly added helper for
install: tty_port_install. It ensures tty->port to be set properly.

Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 695586ca
Loading
Loading
Loading
Loading
+36 −24
Original line number Original line Diff line number Diff line
@@ -2792,22 +2792,29 @@ static void con_flush_chars(struct tty_struct *tty)
/*
/*
 * Allocate the console screen memory.
 * Allocate the console screen memory.
 */
 */
static int con_open(struct tty_struct *tty, struct file *filp)
static int con_install(struct tty_driver *driver, struct tty_struct *tty)
{
{
	unsigned int currcons = tty->index;
	unsigned int currcons = tty->index;
	int ret = 0;
	struct vc_data *vc;
	int ret;


	console_lock();
	console_lock();
	if (tty->driver_data == NULL) {
	ret = vc_allocate(currcons);
	ret = vc_allocate(currcons);
		if (ret == 0) {
	if (ret)
			struct vc_data *vc = vc_cons[currcons].d;
		goto unlock;

	vc = vc_cons[currcons].d;


	/* Still being freed */
	/* Still being freed */
	if (vc->port.tty) {
	if (vc->port.tty) {
				console_unlock();
		ret = -ERESTARTSYS;
				return -ERESTARTSYS;
		goto unlock;
	}
	}

	ret = tty_port_install(&vc->port, driver, tty);
	if (ret)
		goto unlock;

	tty->driver_data = vc;
	tty->driver_data = vc;
	vc->port.tty = tty;
	vc->port.tty = tty;


@@ -2819,13 +2826,17 @@ static int con_open(struct tty_struct *tty, struct file *filp)
		tty->termios->c_iflag |= IUTF8;
		tty->termios->c_iflag |= IUTF8;
	else
	else
		tty->termios->c_iflag &= ~IUTF8;
		tty->termios->c_iflag &= ~IUTF8;
unlock:
	console_unlock();
	console_unlock();
	return ret;
	return ret;
}
}

static int con_open(struct tty_struct *tty, struct file *filp)
{
	/* everything done in install */
	return 0;
}
}
	console_unlock();

	return ret;
}


static void con_close(struct tty_struct *tty, struct file *filp)
static void con_close(struct tty_struct *tty, struct file *filp)
{
{
@@ -2947,6 +2958,7 @@ static int __init con_init(void)
console_initcall(con_init);
console_initcall(con_init);


static const struct tty_operations con_ops = {
static const struct tty_operations con_ops = {
	.install = con_install,
	.open = con_open,
	.open = con_open,
	.close = con_close,
	.close = con_close,
	.write = con_write,
	.write = con_write,