From 43574c1afea4f798592c03cf4d4ecea4fd0a8416 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 9 Sep 2011 17:25:00 -0400 Subject: um: get rid of the init_prio mess make line_setup() act on a separate array of conf strings + default conf, have lines array initialized explicitly by that data, bury LINE_INIT() macro from hell. Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/drivers/stdio_console.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'arch/um/drivers/stdio_console.c') diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c index 088776f01908..6d244f470968 100644 --- a/arch/um/drivers/stdio_console.c +++ b/arch/um/drivers/stdio_console.c @@ -76,9 +76,9 @@ static struct line_driver driver = { /* The array is initialized by line_init, at initcall time. The * elements are locked individually as needed. */ -static struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver), - [ 1 ... MAX_TTYS - 1 ] = - LINE_INIT(CONFIG_CON_CHAN, &driver) }; +static char *vt_conf[MAX_TTYS]; +static char *def_conf; +static struct line vts[MAX_TTYS]; static int con_config(char *str, char **error_out) { @@ -160,7 +160,22 @@ static struct console stdiocons = { static int stdio_init(void) { char *new_title; - + int i; + + for (i = 0; i < MAX_TTYS; i++) { + char *s = vt_conf[i]; + if (!s) + s = def_conf; + if (!s) + s = i ? CONFIG_CON_CHAN : CONFIG_CON_ZERO_CHAN; + if (s && strcmp(s, "none") != 0) { + vts[i].init_str = s; + vts[i].valid = 1; + } + spin_lock_init(&vts[i].lock); + spin_lock_init(&vts[i].count_lock); + vts[i].driver = &driver; + } console_driver = register_lines(&driver, &console_ops, vts, ARRAY_SIZE(vts)); if (console_driver == NULL) @@ -189,14 +204,7 @@ __uml_exitcall(console_exit); static int console_chan_setup(char *str) { - char *error; - int ret; - - ret = line_setup(vts, ARRAY_SIZE(vts), str, &error); - if(ret < 0) - printk(KERN_ERR "Failed to set up console with " - "configuration string \"%s\" : %s\n", str, error); - + line_setup(vt_conf, MAX_TTYS, &def_conf, str, "console"); return 1; } __setup("con", console_chan_setup); -- cgit v1.2.1 From d8c215adbf3901aa7d00a0f17f08d77be689f838 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 9 Sep 2011 17:36:37 -0400 Subject: um: convert count_lock to mutex, fix a race in line_open() If two processes are opening the same line, the second to get into line_open() will decide that it doesn't need to do anything (correctly) or wait for anything. The latter, unfortunately, is incorrect - the first opener might not be through yet. We need to have exclusion covering the entire line_init(), including the blocking parts. Moreover, the next patch will need to widen the exclusion on mconsole side of things, also including the blocking bits, so let's just convert that sucker to mutex... Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/drivers/stdio_console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/um/drivers/stdio_console.c') diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c index 6d244f470968..f8d4325b28b7 100644 --- a/arch/um/drivers/stdio_console.c +++ b/arch/um/drivers/stdio_console.c @@ -173,7 +173,7 @@ static int stdio_init(void) vts[i].valid = 1; } spin_lock_init(&vts[i].lock); - spin_lock_init(&vts[i].count_lock); + mutex_init(&vts[i].count_lock); vts[i].driver = &driver; } console_driver = register_lines(&driver, &console_ops, vts, -- cgit v1.2.1 From cfe6b7c79daa0efa27f474f1fe2a88fd7af5cc47 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 9 Sep 2011 19:45:42 -0400 Subject: um: switch line.c tty drivers to dynamic device creation Current code doesn't update the symlinks in /sys/dev/char when we add/remove tty lines. Fixing that allows to stop messing with ->valid before the driver registration, which is a Good Thing(tm) - we shouldn't have it set before we really have the things set up and ready for line_open(). We need tty_driver available to call tty_{un,}register_device(), so we just stash a reference to it into struct line_driver. Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/drivers/stdio_console.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'arch/um/drivers/stdio_console.c') diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c index f8d4325b28b7..32bd040138f0 100644 --- a/arch/um/drivers/stdio_console.c +++ b/arch/um/drivers/stdio_console.c @@ -27,12 +27,6 @@ #define MAX_TTYS (16) -/* Referenced only by tty_driver below - presumably it's locked correctly - * by the tty driver. - */ - -static struct tty_driver *console_driver; - static void stdio_announce(char *dev_name, int dev) { printk(KERN_INFO "Virtual console %d assigned device '%s'\n", dev, @@ -137,7 +131,7 @@ static void uml_console_write(struct console *console, const char *string, static struct tty_driver *uml_console_device(struct console *c, int *index) { *index = c->index; - return console_driver; + return driver.driver; } static int uml_console_setup(struct console *co, char *options) @@ -160,6 +154,7 @@ static struct console stdiocons = { static int stdio_init(void) { char *new_title; + int err; int i; for (i = 0; i < MAX_TTYS; i++) { @@ -168,18 +163,16 @@ static int stdio_init(void) s = def_conf; if (!s) s = i ? CONFIG_CON_CHAN : CONFIG_CON_ZERO_CHAN; - if (s && strcmp(s, "none") != 0) { + if (s && strcmp(s, "none") != 0) vts[i].init_str = s; - vts[i].valid = 1; - } spin_lock_init(&vts[i].lock); mutex_init(&vts[i].count_lock); vts[i].driver = &driver; } - console_driver = register_lines(&driver, &console_ops, vts, + err = register_lines(&driver, &console_ops, vts, ARRAY_SIZE(vts)); - if (console_driver == NULL) - return -1; + if (err) + return err; printk(KERN_INFO "Initialized stdio console driver\n"); new_title = add_xterm_umid(opts.xterm_title); -- cgit v1.2.1 From 04292b2cf8f02a33cfc1054c0c51aa8c77731813 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 9 Sep 2011 20:07:05 -0400 Subject: um: get rid of lines_init() move config-independent parts of initialization into register_lines(), call setup_one_line() after it instead of abusing ->init_str. Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/drivers/stdio_console.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'arch/um/drivers/stdio_console.c') diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c index 32bd040138f0..fe581209d629 100644 --- a/arch/um/drivers/stdio_console.c +++ b/arch/um/drivers/stdio_console.c @@ -157,29 +157,28 @@ static int stdio_init(void) int err; int i; - for (i = 0; i < MAX_TTYS; i++) { - char *s = vt_conf[i]; - if (!s) - s = def_conf; - if (!s) - s = i ? CONFIG_CON_CHAN : CONFIG_CON_ZERO_CHAN; - if (s && strcmp(s, "none") != 0) - vts[i].init_str = s; - spin_lock_init(&vts[i].lock); - mutex_init(&vts[i].count_lock); - vts[i].driver = &driver; - } err = register_lines(&driver, &console_ops, vts, ARRAY_SIZE(vts)); if (err) return err; + printk(KERN_INFO "Initialized stdio console driver\n"); new_title = add_xterm_umid(opts.xterm_title); if(new_title != NULL) opts.xterm_title = new_title; - lines_init(vts, ARRAY_SIZE(vts), &opts); + for (i = 0; i < MAX_TTYS; i++) { + char *error; + char *s = vt_conf[i]; + if (!s) + s = def_conf; + if (!s) + s = i ? CONFIG_CON_CHAN : CONFIG_CON_ZERO_CHAN; + if (setup_one_line(vts, i, s, &opts, &error)) + printk(KERN_ERR "setup_one_line failed for " + "device %d : %s\n", i, error); + } con_init_done = 1; register_console(&stdiocons); -- cgit v1.2.1 From bed5e39c56f3fe792e336cfa2670001d78f1d44c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 8 Sep 2011 10:49:34 -0400 Subject: um: switch users of ->chan_list to ->chan_{in,out} (easy cases) Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- arch/um/drivers/stdio_console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/um/drivers/stdio_console.c') diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c index fe581209d629..7663541c372e 100644 --- a/arch/um/drivers/stdio_console.c +++ b/arch/um/drivers/stdio_console.c @@ -124,7 +124,7 @@ static void uml_console_write(struct console *console, const char *string, unsigned long flags; spin_lock_irqsave(&line->lock, flags); - console_write_chan(&line->chan_list, string, len); + console_write_chan(line->chan_out, string, len); spin_unlock_irqrestore(&line->lock, flags); } -- cgit v1.2.1