Commit 04292b2c authored by Al Viro's avatar Al Viro Committed by Richard Weinberger

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: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent cfe6b7c7
...@@ -481,8 +481,8 @@ void close_lines(struct line *lines, int nlines) ...@@ -481,8 +481,8 @@ void close_lines(struct line *lines, int nlines)
close_chan(&lines[i].chan_list, 0); close_chan(&lines[i].chan_list, 0);
} }
static int setup_one_line(struct line *lines, int n, char *init, int setup_one_line(struct line *lines, int n, char *init,
const struct chan_opts *opts, char **error_out) const struct chan_opts *opts, char **error_out)
{ {
struct line *line = &lines[n]; struct line *line = &lines[n];
struct tty_driver *driver = line->driver->driver; struct tty_driver *driver = line->driver->driver;
...@@ -658,6 +658,7 @@ int register_lines(struct line_driver *line_driver, ...@@ -658,6 +658,7 @@ int register_lines(struct line_driver *line_driver,
{ {
struct tty_driver *driver = alloc_tty_driver(nlines); struct tty_driver *driver = alloc_tty_driver(nlines);
int err; int err;
int i;
if (!driver) if (!driver)
return -ENOMEM; return -ENOMEM;
...@@ -670,6 +671,13 @@ int register_lines(struct line_driver *line_driver, ...@@ -670,6 +671,13 @@ int register_lines(struct line_driver *line_driver,
driver->subtype = line_driver->subtype; driver->subtype = line_driver->subtype;
driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
driver->init_termios = tty_std_termios; driver->init_termios = tty_std_termios;
for (i = 0; i < nlines; i++) {
spin_lock_init(&lines[i].lock);
mutex_init(&lines[i].count_lock);
lines[i].driver = line_driver;
INIT_LIST_HEAD(&lines[i].chan_list);
}
tty_set_operations(driver, ops); tty_set_operations(driver, ops);
err = tty_register_driver(driver); err = tty_register_driver(driver);
...@@ -688,25 +696,6 @@ int register_lines(struct line_driver *line_driver, ...@@ -688,25 +696,6 @@ int register_lines(struct line_driver *line_driver,
static DEFINE_SPINLOCK(winch_handler_lock); static DEFINE_SPINLOCK(winch_handler_lock);
static LIST_HEAD(winch_handlers); static LIST_HEAD(winch_handlers);
void lines_init(struct line *lines, int nlines, struct chan_opts *opts)
{
struct line *line;
char *error;
int i;
for(i = 0; i < nlines; i++) {
line = &lines[i];
INIT_LIST_HEAD(&line->chan_list);
if (line->init_str == NULL)
continue;
if (setup_one_line(lines, i, line->init_str, opts, &error))
printk(KERN_ERR "setup_one_line failed for "
"device %d : %s\n", i, error);
}
}
struct winch { struct winch {
struct list_head list; struct list_head list;
int fd; int fd;
......
...@@ -82,7 +82,8 @@ extern void line_close_chan(struct line *line); ...@@ -82,7 +82,8 @@ extern void line_close_chan(struct line *line);
extern int register_lines(struct line_driver *line_driver, extern int register_lines(struct line_driver *line_driver,
const struct tty_operations *driver, const struct tty_operations *driver,
struct line *lines, int nlines); struct line *lines, int nlines);
extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts); extern int setup_one_line(struct line *lines, int n, char *init,
const struct chan_opts *opts, char **error_out);
extern void close_lines(struct line *lines, int nlines); extern void close_lines(struct line *lines, int nlines);
extern int line_config(struct line *lines, unsigned int sizeof_lines, extern int line_config(struct line *lines, unsigned int sizeof_lines,
......
...@@ -187,16 +187,6 @@ static int ssl_init(void) ...@@ -187,16 +187,6 @@ static int ssl_init(void)
printk(KERN_INFO "Initializing software serial port version %d\n", printk(KERN_INFO "Initializing software serial port version %d\n",
ssl_version); 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, err = register_lines(&driver, &ssl_ops, serial_lines,
ARRAY_SIZE(serial_lines)); ARRAY_SIZE(serial_lines));
if (err) if (err)
...@@ -206,7 +196,15 @@ static int ssl_init(void) ...@@ -206,7 +196,15 @@ static int ssl_init(void)
if (new_title != NULL) if (new_title != NULL)
opts.xterm_title = new_title; 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; ssl_init_done = 1;
register_console(&ssl_cons); register_console(&ssl_cons);
......
...@@ -157,29 +157,28 @@ static int stdio_init(void) ...@@ -157,29 +157,28 @@ static int stdio_init(void)
int err; int err;
int i; 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, err = register_lines(&driver, &console_ops, vts,
ARRAY_SIZE(vts)); ARRAY_SIZE(vts));
if (err) if (err)
return err; return err;
printk(KERN_INFO "Initialized stdio console driver\n"); printk(KERN_INFO "Initialized stdio console driver\n");
new_title = add_xterm_umid(opts.xterm_title); new_title = add_xterm_umid(opts.xterm_title);
if(new_title != NULL) if(new_title != NULL)
opts.xterm_title = new_title; 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; con_init_done = 1;
register_console(&stdiocons); register_console(&stdiocons);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment