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/ssl.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'arch/um/drivers/ssl.c') diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c index 9d8c20af6f80..445288ff0650 100644 --- a/arch/um/drivers/ssl.c +++ b/arch/um/drivers/ssl.c @@ -71,8 +71,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 serial_lines[NR_PORTS] = - { [0 ... NR_PORTS - 1] = LINE_INIT(CONFIG_SSL_CHAN, &driver) }; +static char *conf[NR_PORTS]; +static char *def_conf = CONFIG_SSL_CHAN; +static struct line serial_lines[NR_PORTS]; static int ssl_config(char *str, char **error_out) { @@ -186,9 +187,23 @@ static struct console ssl_cons = { static int ssl_init(void) { char *new_title; + int i; printk(KERN_INFO "Initializing software serial port version %d\n", ssl_version); + + for (i = 0; i < NR_PORTS; i++) { + char *s = conf[i]; + if (!s) + s = def_conf; + if (s && strcmp(s, "none") != 0) { + serial_lines[i].init_str = s; + serial_lines[i].valid = 1; + } + spin_lock_init(&serial_lines[i].lock); + spin_lock_init(&serial_lines[i].count_lock); + serial_lines[i].driver = &driver; + } ssl_driver = register_lines(&driver, &ssl_ops, serial_lines, ARRAY_SIZE(serial_lines)); @@ -214,14 +229,7 @@ __uml_exitcall(ssl_exit); static int ssl_chan_setup(char *str) { - char *error; - int ret; - - ret = line_setup(serial_lines, ARRAY_SIZE(serial_lines), str, &error); - if(ret < 0) - printk(KERN_ERR "Failed to set up serial line with " - "configuration string \"%s\" : %s\n", str, error); - + line_setup(conf, NR_PORTS, &def_conf, str, "serial line"); return 1; } -- cgit v1.2.3 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/ssl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/um/drivers/ssl.c') diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c index 445288ff0650..23cffd6d85af 100644 --- a/arch/um/drivers/ssl.c +++ b/arch/um/drivers/ssl.c @@ -201,7 +201,7 @@ static int ssl_init(void) serial_lines[i].valid = 1; } spin_lock_init(&serial_lines[i].lock); - spin_lock_init(&serial_lines[i].count_lock); + mutex_init(&serial_lines[i].count_lock); serial_lines[i].driver = &driver; } ssl_driver = register_lines(&driver, &ssl_ops, serial_lines, -- cgit v1.2.3 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/ssl.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'arch/um/drivers/ssl.c') diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c index 23cffd6d85af..6398a47d035b 100644 --- a/arch/um/drivers/ssl.c +++ b/arch/um/drivers/ssl.c @@ -20,12 +20,6 @@ static const int ssl_version = 1; -/* Referenced only by tty_driver below - presumably it's locked correctly - * by the tty driver. - */ - -static struct tty_driver *ssl_driver; - #define NR_PORTS 64 static void ssl_announce(char *dev_name, int dev) @@ -164,7 +158,7 @@ static void ssl_console_write(struct console *c, const char *string, static struct tty_driver *ssl_console_device(struct console *c, int *index) { *index = c->index; - return ssl_driver; + return driver.driver; } static int ssl_console_setup(struct console *co, char *options) @@ -187,6 +181,7 @@ static struct console ssl_cons = { static int ssl_init(void) { char *new_title; + int err; int i; printk(KERN_INFO "Initializing software serial port version %d\n", @@ -196,16 +191,16 @@ static int ssl_init(void) char *s = conf[i]; if (!s) s = def_conf; - if (s && strcmp(s, "none") != 0) { + if (s && strcmp(s, "none") != 0) serial_lines[i].init_str = s; - serial_lines[i].valid = 1; - } spin_lock_init(&serial_lines[i].lock); mutex_init(&serial_lines[i].count_lock); serial_lines[i].driver = &driver; } - ssl_driver = register_lines(&driver, &ssl_ops, serial_lines, + err = register_lines(&driver, &ssl_ops, serial_lines, ARRAY_SIZE(serial_lines)); + if (err) + return err; new_title = add_xterm_umid(opts.xterm_title); if (new_title != NULL) -- cgit v1.2.3 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/ssl.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'arch/um/drivers/ssl.c') diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c index 6398a47d035b..d0b5ccf2379f 100644 --- a/arch/um/drivers/ssl.c +++ b/arch/um/drivers/ssl.c @@ -187,16 +187,6 @@ static int ssl_init(void) printk(KERN_INFO "Initializing software serial port version %d\n", ssl_version); - for (i = 0; i < NR_PORTS; i++) { - char *s = conf[i]; - if (!s) - s = def_conf; - if (s && strcmp(s, "none") != 0) - serial_lines[i].init_str = s; - spin_lock_init(&serial_lines[i].lock); - mutex_init(&serial_lines[i].count_lock); - serial_lines[i].driver = &driver; - } err = register_lines(&driver, &ssl_ops, serial_lines, ARRAY_SIZE(serial_lines)); if (err) @@ -206,7 +196,15 @@ static int ssl_init(void) if (new_title != NULL) opts.xterm_title = new_title; - lines_init(serial_lines, ARRAY_SIZE(serial_lines), &opts); + for (i = 0; i < NR_PORTS; i++) { + char *error; + char *s = conf[i]; + if (!s) + s = def_conf; + if (setup_one_line(serial_lines, i, s, &opts, &error)) + printk(KERN_ERR "setup_one_line failed for " + "device %d : %s\n", i, error); + } ssl_init_done = 1; register_console(&ssl_cons); -- cgit v1.2.3 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/ssl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/um/drivers/ssl.c') diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c index d0b5ccf2379f..e09801a1327b 100644 --- a/arch/um/drivers/ssl.c +++ b/arch/um/drivers/ssl.c @@ -151,7 +151,7 @@ static void ssl_console_write(struct console *c, 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.3