aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2006-01-06 03:18:55 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:33:46 -0500
commit1f80171e81ed0d08dcdb6efe239d7b929aef498f (patch)
treef6f72268ddee265b46ceb698cdff6daa7cba6250 /arch/um
parent418e55d49b0ec7d2e7a033f2dd083f5b2ab7d119 (diff)
[PATCH] uml: move console configuration
This patch changes when console devices are configured in order to prepare the ground for the next patch. parse_chan_pair is now done earlier, when initcalls are run, rather than when the device is opened. When a host device disappears, the channel list is closed, but not freed. This is required by the previous change. line_config now takes the options structure as an argument, and line_open doesn't. Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/drivers/chan_kern.c14
-rw-r--r--arch/um/drivers/line.c34
-rw-r--r--arch/um/drivers/ssl.c6
-rw-r--r--arch/um/drivers/stdio_console.c6
-rw-r--r--arch/um/include/line.h7
5 files changed, 35 insertions, 32 deletions
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 59c9b3f7c840..31b69c4ea800 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -311,14 +311,12 @@ int console_write_chan(struct list_head *chans, const char *buf, int len)
311int console_open_chan(struct line *line, struct console *co, 311int console_open_chan(struct line *line, struct console *co,
312 struct chan_opts *opts) 312 struct chan_opts *opts)
313{ 313{
314 if (!list_empty(&line->chan_list)) 314 int err;
315 return 0; 315
316 err = open_chan(&line->chan_list);
317 if(err)
318 return err;
316 319
317 if (0 != parse_chan_pair(line->init_str, &line->chan_list,
318 co->index, opts))
319 return -1;
320 if (0 != open_chan(&line->chan_list))
321 return -1;
322 printk("Console initialized on /dev/%s%d\n",co->name,co->index); 320 printk("Console initialized on /dev/%s%d\n",co->name,co->index);
323 return 0; 321 return 0;
324} 322}
@@ -596,13 +594,11 @@ void chan_interrupt(struct list_head *chans, struct work_struct *task,
596 tty_hangup(tty); 594 tty_hangup(tty);
597 line_disable(tty, irq); 595 line_disable(tty, irq);
598 close_chan(chans); 596 close_chan(chans);
599 free_chan(chans);
600 return; 597 return;
601 } 598 }
602 else { 599 else {
603 if(chan->ops->close != NULL) 600 if(chan->ops->close != NULL)
604 chan->ops->close(chan->fd, chan->data); 601 chan->ops->close(chan->fd, chan->data);
605 free_one_chan(chan);
606 } 602 }
607 } 603 }
608 } 604 }
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 1352a212964a..da81d22ec04a 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -419,8 +419,7 @@ void line_disable(struct tty_struct *tty, int current_irq)
419 line->have_irq = 0; 419 line->have_irq = 0;
420} 420}
421 421
422int line_open(struct line *lines, struct tty_struct *tty, 422int line_open(struct line *lines, struct tty_struct *tty)
423 struct chan_opts *opts)
424{ 423{
425 struct line *line; 424 struct line *line;
426 int err = 0; 425 int err = 0;
@@ -436,13 +435,11 @@ int line_open(struct line *lines, struct tty_struct *tty,
436 err = -ENODEV; 435 err = -ENODEV;
437 goto out; 436 goto out;
438 } 437 }
439 if (list_empty(&line->chan_list)) { 438
440 err = parse_chan_pair(line->init_str, &line->chan_list, 439 err = open_chan(&line->chan_list);
441 tty->index, opts); 440 if(err)
442 if(err) goto out; 441 goto out;
443 err = open_chan(&line->chan_list); 442
444 if(err) goto out;
445 }
446 /* Here the interrupt is registered.*/ 443 /* Here the interrupt is registered.*/
447 enable_chan(&line->chan_list, tty); 444 enable_chan(&line->chan_list, tty);
448 INIT_WORK(&line->task, line_timer_cb, tty); 445 INIT_WORK(&line->task, line_timer_cb, tty);
@@ -558,8 +555,10 @@ int line_setup(struct line *lines, unsigned int num, char *init)
558 return n == -1 ? num : n; 555 return n == -1 ? num : n;
559} 556}
560 557
561int line_config(struct line *lines, unsigned int num, char *str) 558int line_config(struct line *lines, unsigned int num, char *str,
559 struct chan_opts *opts)
562{ 560{
561 struct line *line;
563 char *new; 562 char *new;
564 int n; 563 int n;
565 564
@@ -572,10 +571,14 @@ int line_config(struct line *lines, unsigned int num, char *str)
572 new = kstrdup(str, GFP_KERNEL); 571 new = kstrdup(str, GFP_KERNEL);
573 if(new == NULL){ 572 if(new == NULL){
574 printk("line_config - kstrdup failed\n"); 573 printk("line_config - kstrdup failed\n");
575 return -ENOMEM; 574 return 1;
576 } 575 }
577 n = line_setup(lines, num, new); 576 n = line_setup(lines, num, new);
578 return n < 0 ? n : 0; 577 if(n < 0)
578 return 1;
579
580 line = &lines[n];
581 return parse_chan_pair(line->init_str, &line->chan_list, n, opts);
579} 582}
580 583
581int line_get_config(char *name, struct line *lines, unsigned int num, char *str, 584int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
@@ -677,7 +680,7 @@ struct tty_driver *line_register_devfs(struct lines *set,
677static DEFINE_SPINLOCK(winch_handler_lock); 680static DEFINE_SPINLOCK(winch_handler_lock);
678static LIST_HEAD(winch_handlers); 681static LIST_HEAD(winch_handlers);
679 682
680void lines_init(struct line *lines, int nlines) 683void lines_init(struct line *lines, int nlines, struct chan_opts *opts)
681{ 684{
682 struct line *line; 685 struct line *line;
683 int i; 686 int i;
@@ -692,6 +695,11 @@ void lines_init(struct line *lines, int nlines)
692 line->init_str = kstrdup(line->init_str, GFP_KERNEL); 695 line->init_str = kstrdup(line->init_str, GFP_KERNEL);
693 if(line->init_str == NULL) 696 if(line->init_str == NULL)
694 printk("lines_init - kstrdup returned NULL\n"); 697 printk("lines_init - kstrdup returned NULL\n");
698
699 if(parse_chan_pair(line->init_str, &line->chan_list, i, opts)){
700 printk("parse_chan_pair failed for device %d\n", i);
701 line->valid = 0;
702 }
695 } 703 }
696} 704}
697 705
diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c
index e1895d9babbe..6823dc5d665c 100644
--- a/arch/um/drivers/ssl.c
+++ b/arch/um/drivers/ssl.c
@@ -84,7 +84,7 @@ static struct lines lines = LINES_INIT(NR_PORTS);
84 84
85static int ssl_config(char *str) 85static int ssl_config(char *str)
86{ 86{
87 return line_config(serial_lines, ARRAY_SIZE(serial_lines), str); 87 return line_config(serial_lines, ARRAY_SIZE(serial_lines), str, &opts);
88} 88}
89 89
90static int ssl_get_config(char *dev, char *str, int size, char **error_out) 90static int ssl_get_config(char *dev, char *str, int size, char **error_out)
@@ -100,7 +100,7 @@ static int ssl_remove(int n)
100 100
101int ssl_open(struct tty_struct *tty, struct file *filp) 101int ssl_open(struct tty_struct *tty, struct file *filp)
102{ 102{
103 return line_open(serial_lines, tty, &opts); 103 return line_open(serial_lines, tty);
104} 104}
105 105
106#if 0 106#if 0
@@ -202,7 +202,7 @@ int ssl_init(void)
202 serial_lines, 202 serial_lines,
203 ARRAY_SIZE(serial_lines)); 203 ARRAY_SIZE(serial_lines));
204 204
205 lines_init(serial_lines, ARRAY_SIZE(serial_lines)); 205 lines_init(serial_lines, ARRAY_SIZE(serial_lines), &opts);
206 206
207 new_title = add_xterm_umid(opts.xterm_title); 207 new_title = add_xterm_umid(opts.xterm_title);
208 if (new_title != NULL) 208 if (new_title != NULL)
diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
index 72000d3a19ee..6d4edda9b510 100644
--- a/arch/um/drivers/stdio_console.c
+++ b/arch/um/drivers/stdio_console.c
@@ -91,7 +91,7 @@ struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver),
91 91
92static int con_config(char *str) 92static int con_config(char *str)
93{ 93{
94 return line_config(vts, ARRAY_SIZE(vts), str); 94 return line_config(vts, ARRAY_SIZE(vts), str, &opts);
95} 95}
96 96
97static int con_get_config(char *dev, char *str, int size, char **error_out) 97static int con_get_config(char *dev, char *str, int size, char **error_out)
@@ -106,7 +106,7 @@ static int con_remove(int n)
106 106
107static int con_open(struct tty_struct *tty, struct file *filp) 107static int con_open(struct tty_struct *tty, struct file *filp)
108{ 108{
109 return line_open(vts, tty, &opts); 109 return line_open(vts, tty);
110} 110}
111 111
112static int con_init_done = 0; 112static int con_init_done = 0;
@@ -169,7 +169,7 @@ int stdio_init(void)
169 return -1; 169 return -1;
170 printk(KERN_INFO "Initialized stdio console driver\n"); 170 printk(KERN_INFO "Initialized stdio console driver\n");
171 171
172 lines_init(vts, ARRAY_SIZE(vts)); 172 lines_init(vts, ARRAY_SIZE(vts), &opts);
173 173
174 new_title = add_xterm_umid(opts.xterm_title); 174 new_title = add_xterm_umid(opts.xterm_title);
175 if(new_title != NULL) 175 if(new_title != NULL)
diff --git a/arch/um/include/line.h b/arch/um/include/line.h
index 351d3ac30b78..474398ba1207 100644
--- a/arch/um/include/line.h
+++ b/arch/um/include/line.h
@@ -74,8 +74,7 @@ struct lines {
74#define LINES_INIT(n) { num : n } 74#define LINES_INIT(n) { num : n }
75 75
76extern void line_close(struct tty_struct *tty, struct file * filp); 76extern void line_close(struct tty_struct *tty, struct file * filp);
77extern int line_open(struct line *lines, struct tty_struct *tty, 77extern int line_open(struct line *lines, struct tty_struct *tty);
78 struct chan_opts *opts);
79extern int line_setup(struct line *lines, unsigned int sizeof_lines, 78extern int line_setup(struct line *lines, unsigned int sizeof_lines,
80 char *init); 79 char *init);
81extern int line_write(struct tty_struct *tty, const unsigned char *buf, 80extern int line_write(struct tty_struct *tty, const unsigned char *buf,
@@ -99,11 +98,11 @@ extern struct tty_driver * line_register_devfs(struct lines *set,
99 struct tty_operations *driver, 98 struct tty_operations *driver,
100 struct line *lines, 99 struct line *lines,
101 int nlines); 100 int nlines);
102extern void lines_init(struct line *lines, int nlines); 101extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts);
103extern void close_lines(struct line *lines, int nlines); 102extern void close_lines(struct line *lines, int nlines);
104 103
105extern int line_config(struct line *lines, unsigned int sizeof_lines, 104extern int line_config(struct line *lines, unsigned int sizeof_lines,
106 char *str); 105 char *str, struct chan_opts *opts);
107extern int line_id(char **str, int *start_out, int *end_out); 106extern int line_id(char **str, int *start_out, int *end_out);
108extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n); 107extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n);
109extern int line_get_config(char *dev, struct line *lines, 108extern int line_get_config(char *dev, struct line *lines,