aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/drivers/line.c69
-rw-r--r--arch/um/drivers/line.h13
-rw-r--r--arch/um/drivers/ssl.c28
-rw-r--r--arch/um/drivers/stdio_console.c32
4 files changed, 68 insertions, 74 deletions
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index b0022cf4efbb..3eea99e98a11 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -489,7 +489,7 @@ void close_lines(struct line *lines, int nlines)
489 close_chan(&lines[i].chan_list, 0); 489 close_chan(&lines[i].chan_list, 0);
490} 490}
491 491
492static int setup_one_line(struct line *lines, int n, char *init, int init_prio, 492static int setup_one_line(struct line *lines, int n, char *init,
493 char **error_out) 493 char **error_out)
494{ 494{
495 struct line *line = &lines[n]; 495 struct line *line = &lines[n];
@@ -502,14 +502,11 @@ static int setup_one_line(struct line *lines, int n, char *init, int init_prio,
502 goto out; 502 goto out;
503 } 503 }
504 504
505 if (line->init_pri <= init_prio) { 505 if (!strcmp(init, "none"))
506 line->init_pri = init_prio; 506 line->valid = 0;
507 if (!strcmp(init, "none")) 507 else {
508 line->valid = 0; 508 line->init_str = init;
509 else { 509 line->valid = 1;
510 line->init_str = init;
511 line->valid = 1;
512 }
513 } 510 }
514 err = 0; 511 err = 0;
515out: 512out:
@@ -524,47 +521,37 @@ out:
524 * @error_out is an error string in the case of failure; 521 * @error_out is an error string in the case of failure;
525 */ 522 */
526 523
527int line_setup(struct line *lines, unsigned int num, char *init, 524int line_setup(char **conf, unsigned int num, char **def,
528 char **error_out) 525 char *init, char *name)
529{ 526{
530 int i, n, err; 527 char *error;
531 char *end;
532 528
533 if (*init == '=') { 529 if (*init == '=') {
534 /* 530 /*
535 * We said con=/ssl= instead of con#=, so we are configuring all 531 * We said con=/ssl= instead of con#=, so we are configuring all
536 * consoles at once. 532 * consoles at once.
537 */ 533 */
538 n = -1; 534 *def = init + 1;
539 } 535 } else {
540 else { 536 char *end;
541 n = simple_strtoul(init, &end, 0); 537 unsigned n = simple_strtoul(init, &end, 0);
538
542 if (*end != '=') { 539 if (*end != '=') {
543 *error_out = "Couldn't parse device number"; 540 error = "Couldn't parse device number";
544 return -EINVAL; 541 goto out;
545 } 542 }
546 init = end; 543 if (n >= num) {
547 } 544 error = "Device number out of range";
548 init++; 545 goto out;
549
550 if (n >= (signed int) num) {
551 *error_out = "Device number out of range";
552 return -EINVAL;
553 }
554 else if (n >= 0) {
555 err = setup_one_line(lines, n, init, INIT_ONE, error_out);
556 if (err)
557 return err;
558 }
559 else {
560 for(i = 0; i < num; i++) {
561 err = setup_one_line(lines, i, init, INIT_ALL,
562 error_out);
563 if (err)
564 return err;
565 } 546 }
547 conf[n] = end + 1;
566 } 548 }
567 return n == -1 ? num : n; 549 return 0;
550
551out:
552 printk(KERN_ERR "Failed to set up %s with "
553 "configuration string \"%s\" : %s\n", name, init, error);
554 return -EINVAL;
568} 555}
569 556
570int line_config(struct line *lines, unsigned int num, char *str, 557int line_config(struct line *lines, unsigned int num, char *str,
@@ -595,7 +582,7 @@ int line_config(struct line *lines, unsigned int num, char *str,
595 *error_out = "Failed to allocate memory"; 582 *error_out = "Failed to allocate memory";
596 return -ENOMEM; 583 return -ENOMEM;
597 } 584 }
598 err = setup_one_line(lines, n, new, INIT_ONE, error_out); 585 err = setup_one_line(lines, n, new, error_out);
599 if (err) 586 if (err)
600 return err; 587 return err;
601 line = &lines[n]; 588 line = &lines[n];
@@ -654,7 +641,7 @@ int line_remove(struct line *lines, unsigned int num, int n, char **error_out)
654 *error_out = "Device number out of range"; 641 *error_out = "Device number out of range";
655 return -EINVAL; 642 return -EINVAL;
656 } 643 }
657 return setup_one_line(lines, n, "none", INIT_ONE, error_out); 644 return setup_one_line(lines, n, "none", error_out);
658} 645}
659 646
660struct tty_driver *register_lines(struct line_driver *line_driver, 647struct tty_driver *register_lines(struct line_driver *line_driver,
diff --git a/arch/um/drivers/line.h b/arch/um/drivers/line.h
index 63df3ca02ac2..0c4dadf5e03e 100644
--- a/arch/um/drivers/line.h
+++ b/arch/um/drivers/line.h
@@ -37,7 +37,6 @@ struct line {
37 int valid; 37 int valid;
38 38
39 char *init_str; 39 char *init_str;
40 int init_pri;
41 struct list_head chan_list; 40 struct list_head chan_list;
42 41
43 /*This lock is actually, mostly, local to*/ 42 /*This lock is actually, mostly, local to*/
@@ -58,18 +57,10 @@ struct line {
58 int have_irq; 57 int have_irq;
59}; 58};
60 59
61#define LINE_INIT(str, d) \
62 { .count_lock = __SPIN_LOCK_UNLOCKED((str).count_lock), \
63 .init_str = str, \
64 .init_pri = INIT_STATIC, \
65 .valid = 1, \
66 .lock = __SPIN_LOCK_UNLOCKED((str).lock), \
67 .driver = d }
68
69extern void line_close(struct tty_struct *tty, struct file * filp); 60extern void line_close(struct tty_struct *tty, struct file * filp);
70extern int line_open(struct line *lines, struct tty_struct *tty); 61extern int line_open(struct line *lines, struct tty_struct *tty);
71extern int line_setup(struct line *lines, unsigned int sizeof_lines, 62extern int line_setup(char **conf, unsigned nlines, char **def,
72 char *init, char **error_out); 63 char *init, char *name);
73extern int line_write(struct tty_struct *tty, const unsigned char *buf, 64extern int line_write(struct tty_struct *tty, const unsigned char *buf,
74 int len); 65 int len);
75extern int line_put_char(struct tty_struct *tty, unsigned char ch); 66extern int line_put_char(struct tty_struct *tty, unsigned char ch);
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 = {
71/* The array is initialized by line_init, at initcall time. The 71/* The array is initialized by line_init, at initcall time. The
72 * elements are locked individually as needed. 72 * elements are locked individually as needed.
73 */ 73 */
74static struct line serial_lines[NR_PORTS] = 74static char *conf[NR_PORTS];
75 { [0 ... NR_PORTS - 1] = LINE_INIT(CONFIG_SSL_CHAN, &driver) }; 75static char *def_conf = CONFIG_SSL_CHAN;
76static struct line serial_lines[NR_PORTS];
76 77
77static int ssl_config(char *str, char **error_out) 78static int ssl_config(char *str, char **error_out)
78{ 79{
@@ -186,9 +187,23 @@ static struct console ssl_cons = {
186static int ssl_init(void) 187static int ssl_init(void)
187{ 188{
188 char *new_title; 189 char *new_title;
190 int i;
189 191
190 printk(KERN_INFO "Initializing software serial port version %d\n", 192 printk(KERN_INFO "Initializing software serial port version %d\n",
191 ssl_version); 193 ssl_version);
194
195 for (i = 0; i < NR_PORTS; i++) {
196 char *s = conf[i];
197 if (!s)
198 s = def_conf;
199 if (s && strcmp(s, "none") != 0) {
200 serial_lines[i].init_str = s;
201 serial_lines[i].valid = 1;
202 }
203 spin_lock_init(&serial_lines[i].lock);
204 spin_lock_init(&serial_lines[i].count_lock);
205 serial_lines[i].driver = &driver;
206 }
192 ssl_driver = register_lines(&driver, &ssl_ops, serial_lines, 207 ssl_driver = register_lines(&driver, &ssl_ops, serial_lines,
193 ARRAY_SIZE(serial_lines)); 208 ARRAY_SIZE(serial_lines));
194 209
@@ -214,14 +229,7 @@ __uml_exitcall(ssl_exit);
214 229
215static int ssl_chan_setup(char *str) 230static int ssl_chan_setup(char *str)
216{ 231{
217 char *error; 232 line_setup(conf, NR_PORTS, &def_conf, str, "serial line");
218 int ret;
219
220 ret = line_setup(serial_lines, ARRAY_SIZE(serial_lines), str, &error);
221 if(ret < 0)
222 printk(KERN_ERR "Failed to set up serial line with "
223 "configuration string \"%s\" : %s\n", str, error);
224
225 return 1; 233 return 1;
226} 234}
227 235
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 = {
76/* The array is initialized by line_init, at initcall time. The 76/* The array is initialized by line_init, at initcall time. The
77 * elements are locked individually as needed. 77 * elements are locked individually as needed.
78 */ 78 */
79static struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver), 79static char *vt_conf[MAX_TTYS];
80 [ 1 ... MAX_TTYS - 1 ] = 80static char *def_conf;
81 LINE_INIT(CONFIG_CON_CHAN, &driver) }; 81static struct line vts[MAX_TTYS];
82 82
83static int con_config(char *str, char **error_out) 83static int con_config(char *str, char **error_out)
84{ 84{
@@ -160,7 +160,22 @@ static struct console stdiocons = {
160static int stdio_init(void) 160static int stdio_init(void)
161{ 161{
162 char *new_title; 162 char *new_title;
163 163 int i;
164
165 for (i = 0; i < MAX_TTYS; i++) {
166 char *s = vt_conf[i];
167 if (!s)
168 s = def_conf;
169 if (!s)
170 s = i ? CONFIG_CON_CHAN : CONFIG_CON_ZERO_CHAN;
171 if (s && strcmp(s, "none") != 0) {
172 vts[i].init_str = s;
173 vts[i].valid = 1;
174 }
175 spin_lock_init(&vts[i].lock);
176 spin_lock_init(&vts[i].count_lock);
177 vts[i].driver = &driver;
178 }
164 console_driver = register_lines(&driver, &console_ops, vts, 179 console_driver = register_lines(&driver, &console_ops, vts,
165 ARRAY_SIZE(vts)); 180 ARRAY_SIZE(vts));
166 if (console_driver == NULL) 181 if (console_driver == NULL)
@@ -189,14 +204,7 @@ __uml_exitcall(console_exit);
189 204
190static int console_chan_setup(char *str) 205static int console_chan_setup(char *str)
191{ 206{
192 char *error; 207 line_setup(vt_conf, MAX_TTYS, &def_conf, str, "console");
193 int ret;
194
195 ret = line_setup(vts, ARRAY_SIZE(vts), str, &error);
196 if(ret < 0)
197 printk(KERN_ERR "Failed to set up console with "
198 "configuration string \"%s\" : %s\n", str, error);
199
200 return 1; 208 return 1;
201} 209}
202__setup("con", console_chan_setup); 210__setup("con", console_chan_setup);