aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-09-09 20:07:05 -0400
committerRichard Weinberger <richard@nod.at>2012-03-24 19:29:53 -0400
commit04292b2cf8f02a33cfc1054c0c51aa8c77731813 (patch)
treeff04fb51c5de7bd646d09d29d9d0ed012ca5a0df
parentcfe6b7c79daa0efa27f474f1fe2a88fd7af5cc47 (diff)
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 <viro@zeniv.linux.org.uk> Signed-off-by: Richard Weinberger <richard@nod.at>
-rw-r--r--arch/um/drivers/line.c31
-rw-r--r--arch/um/drivers/line.h3
-rw-r--r--arch/um/drivers/ssl.c20
-rw-r--r--arch/um/drivers/stdio_console.c25
4 files changed, 33 insertions, 46 deletions
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 015209a98815..002d4a968ae6 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -481,8 +481,8 @@ void close_lines(struct line *lines, int nlines)
481 close_chan(&lines[i].chan_list, 0); 481 close_chan(&lines[i].chan_list, 0);
482} 482}
483 483
484static int setup_one_line(struct line *lines, int n, char *init, 484int setup_one_line(struct line *lines, int n, char *init,
485 const struct chan_opts *opts, char **error_out) 485 const struct chan_opts *opts, char **error_out)
486{ 486{
487 struct line *line = &lines[n]; 487 struct line *line = &lines[n];
488 struct tty_driver *driver = line->driver->driver; 488 struct tty_driver *driver = line->driver->driver;
@@ -658,6 +658,7 @@ int register_lines(struct line_driver *line_driver,
658{ 658{
659 struct tty_driver *driver = alloc_tty_driver(nlines); 659 struct tty_driver *driver = alloc_tty_driver(nlines);
660 int err; 660 int err;
661 int i;
661 662
662 if (!driver) 663 if (!driver)
663 return -ENOMEM; 664 return -ENOMEM;
@@ -670,6 +671,13 @@ int register_lines(struct line_driver *line_driver,
670 driver->subtype = line_driver->subtype; 671 driver->subtype = line_driver->subtype;
671 driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 672 driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
672 driver->init_termios = tty_std_termios; 673 driver->init_termios = tty_std_termios;
674
675 for (i = 0; i < nlines; i++) {
676 spin_lock_init(&lines[i].lock);
677 mutex_init(&lines[i].count_lock);
678 lines[i].driver = line_driver;
679 INIT_LIST_HEAD(&lines[i].chan_list);
680 }
673 tty_set_operations(driver, ops); 681 tty_set_operations(driver, ops);
674 682
675 err = tty_register_driver(driver); 683 err = tty_register_driver(driver);
@@ -688,25 +696,6 @@ int register_lines(struct line_driver *line_driver,
688static DEFINE_SPINLOCK(winch_handler_lock); 696static DEFINE_SPINLOCK(winch_handler_lock);
689static LIST_HEAD(winch_handlers); 697static LIST_HEAD(winch_handlers);
690 698
691void lines_init(struct line *lines, int nlines, struct chan_opts *opts)
692{
693 struct line *line;
694 char *error;
695 int i;
696
697 for(i = 0; i < nlines; i++) {
698 line = &lines[i];
699 INIT_LIST_HEAD(&line->chan_list);
700
701 if (line->init_str == NULL)
702 continue;
703
704 if (setup_one_line(lines, i, line->init_str, opts, &error))
705 printk(KERN_ERR "setup_one_line failed for "
706 "device %d : %s\n", i, error);
707 }
708}
709
710struct winch { 699struct winch {
711 struct list_head list; 700 struct list_head list;
712 int fd; 701 int fd;
diff --git a/arch/um/drivers/line.h b/arch/um/drivers/line.h
index e3f86065e049..95991994a93b 100644
--- a/arch/um/drivers/line.h
+++ b/arch/um/drivers/line.h
@@ -82,7 +82,8 @@ extern void line_close_chan(struct line *line);
82extern int register_lines(struct line_driver *line_driver, 82extern int register_lines(struct line_driver *line_driver,
83 const struct tty_operations *driver, 83 const struct tty_operations *driver,
84 struct line *lines, int nlines); 84 struct line *lines, int nlines);
85extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts); 85extern int setup_one_line(struct line *lines, int n, char *init,
86 const struct chan_opts *opts, char **error_out);
86extern void close_lines(struct line *lines, int nlines); 87extern void close_lines(struct line *lines, int nlines);
87 88
88extern int line_config(struct line *lines, unsigned int sizeof_lines, 89extern int line_config(struct line *lines, unsigned int sizeof_lines,
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)
187 printk(KERN_INFO "Initializing software serial port version %d\n", 187 printk(KERN_INFO "Initializing software serial port version %d\n",
188 ssl_version); 188 ssl_version);
189 189
190 for (i = 0; i < NR_PORTS; i++) {
191 char *s = conf[i];
192 if (!s)
193 s = def_conf;
194 if (s && strcmp(s, "none") != 0)
195 serial_lines[i].init_str = s;
196 spin_lock_init(&serial_lines[i].lock);
197 mutex_init(&serial_lines[i].count_lock);
198 serial_lines[i].driver = &driver;
199 }
200 err = register_lines(&driver, &ssl_ops, serial_lines, 190 err = register_lines(&driver, &ssl_ops, serial_lines,
201 ARRAY_SIZE(serial_lines)); 191 ARRAY_SIZE(serial_lines));
202 if (err) 192 if (err)
@@ -206,7 +196,15 @@ static int ssl_init(void)
206 if (new_title != NULL) 196 if (new_title != NULL)
207 opts.xterm_title = new_title; 197 opts.xterm_title = new_title;
208 198
209 lines_init(serial_lines, ARRAY_SIZE(serial_lines), &opts); 199 for (i = 0; i < NR_PORTS; i++) {
200 char *error;
201 char *s = conf[i];
202 if (!s)
203 s = def_conf;
204 if (setup_one_line(serial_lines, i, s, &opts, &error))
205 printk(KERN_ERR "setup_one_line failed for "
206 "device %d : %s\n", i, error);
207 }
210 208
211 ssl_init_done = 1; 209 ssl_init_done = 1;
212 register_console(&ssl_cons); 210 register_console(&ssl_cons);
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)
157 int err; 157 int err;
158 int i; 158 int i;
159 159
160 for (i = 0; i < MAX_TTYS; i++) {
161 char *s = vt_conf[i];
162 if (!s)
163 s = def_conf;
164 if (!s)
165 s = i ? CONFIG_CON_CHAN : CONFIG_CON_ZERO_CHAN;
166 if (s && strcmp(s, "none") != 0)
167 vts[i].init_str = s;
168 spin_lock_init(&vts[i].lock);
169 mutex_init(&vts[i].count_lock);
170 vts[i].driver = &driver;
171 }
172 err = register_lines(&driver, &console_ops, vts, 160 err = register_lines(&driver, &console_ops, vts,
173 ARRAY_SIZE(vts)); 161 ARRAY_SIZE(vts));
174 if (err) 162 if (err)
175 return err; 163 return err;
164
176 printk(KERN_INFO "Initialized stdio console driver\n"); 165 printk(KERN_INFO "Initialized stdio console driver\n");
177 166
178 new_title = add_xterm_umid(opts.xterm_title); 167 new_title = add_xterm_umid(opts.xterm_title);
179 if(new_title != NULL) 168 if(new_title != NULL)
180 opts.xterm_title = new_title; 169 opts.xterm_title = new_title;
181 170
182 lines_init(vts, ARRAY_SIZE(vts), &opts); 171 for (i = 0; i < MAX_TTYS; i++) {
172 char *error;
173 char *s = vt_conf[i];
174 if (!s)
175 s = def_conf;
176 if (!s)
177 s = i ? CONFIG_CON_CHAN : CONFIG_CON_ZERO_CHAN;
178 if (setup_one_line(vts, i, s, &opts, &error))
179 printk(KERN_ERR "setup_one_line failed for "
180 "device %d : %s\n", i, error);
181 }
183 182
184 con_init_done = 1; 183 con_init_done = 1;
185 register_console(&stdiocons); 184 register_console(&stdiocons);