aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-02-10 04:44:08 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-11 13:51:22 -0500
commitd5c9ffc6c6d15d4f655236e26942a21ad61fe3ad (patch)
tree0fda7f4a171461ab95bb424f158949d53f223920
parentb4ac91a0eac36f347a509afda07e4305e931de61 (diff)
[PATCH] uml: console locking commentary and code cleanup
Remove the last vestiges of devfs from console registration. Change the name of the function, plus remove a couple of unused fields from the line_driver structure. struct lines is no longer needed, all traces of it are gone. The only way that I can see to mark a structure as being almost-const is to individually const the fields. This is the case for the line_driver structure, which has only one modifiable field - a list_head in a sub-structure. Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/um/drivers/line.c7
-rw-r--r--arch/um/drivers/ssl.c16
-rw-r--r--arch/um/drivers/stdio_console.c17
-rw-r--r--arch/um/include/line.h36
4 files changed, 31 insertions, 45 deletions
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index e620ed46ed3f..433e572fb196 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -707,10 +707,9 @@ int line_remove(struct line *lines, unsigned int num, int n, char **error_out)
707 return err; 707 return err;
708} 708}
709 709
710struct tty_driver *line_register_devfs(struct lines *set, 710struct tty_driver *register_lines(struct line_driver *line_driver,
711 struct line_driver *line_driver, 711 const struct tty_operations *ops,
712 const struct tty_operations *ops, 712 struct line *lines, int nlines)
713 struct line *lines, int nlines)
714{ 713{
715 int i; 714 int i;
716 struct tty_driver *driver = alloc_tty_driver(nlines); 715 struct tty_driver *driver = alloc_tty_driver(nlines);
diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c
index 475de52783e4..fc22b9bd9153 100644
--- a/arch/um/drivers/ssl.c
+++ b/arch/um/drivers/ssl.c
@@ -51,6 +51,8 @@ static int ssl_config(char *str, char **error_out);
51static int ssl_get_config(char *dev, char *str, int size, char **error_out); 51static int ssl_get_config(char *dev, char *str, int size, char **error_out);
52static int ssl_remove(int n, char **error_out); 52static int ssl_remove(int n, char **error_out);
53 53
54
55/* Const, except for .mc.list */
54static struct line_driver driver = { 56static struct line_driver driver = {
55 .name = "UML serial line", 57 .name = "UML serial line",
56 .device_name = "ttyS", 58 .device_name = "ttyS",
@@ -62,8 +64,6 @@ static struct line_driver driver = {
62 .read_irq_name = "ssl", 64 .read_irq_name = "ssl",
63 .write_irq = SSL_WRITE_IRQ, 65 .write_irq = SSL_WRITE_IRQ,
64 .write_irq_name = "ssl-write", 66 .write_irq_name = "ssl-write",
65 .symlink_from = "serial",
66 .symlink_to = "tts",
67 .mc = { 67 .mc = {
68 .list = LIST_HEAD_INIT(driver.mc.list), 68 .list = LIST_HEAD_INIT(driver.mc.list),
69 .name = "ssl", 69 .name = "ssl",
@@ -74,14 +74,12 @@ static struct line_driver driver = {
74 }, 74 },
75}; 75};
76 76
77/* The array is initialized by line_init, which is an initcall. The 77/* The array is initialized by line_init, at initcall time. The
78 * individual elements are protected by individual semaphores. 78 * elements are locked individually as needed.
79 */ 79 */
80static struct line serial_lines[NR_PORTS] = 80static struct line serial_lines[NR_PORTS] =
81 { [0 ... NR_PORTS - 1] = LINE_INIT(CONFIG_SSL_CHAN, &driver) }; 81 { [0 ... NR_PORTS - 1] = LINE_INIT(CONFIG_SSL_CHAN, &driver) };
82 82
83static struct lines lines = LINES_INIT(NR_PORTS);
84
85static int ssl_config(char *str, char **error_out) 83static int ssl_config(char *str, char **error_out)
86{ 84{
87 return line_config(serial_lines, ARRAY_SIZE(serial_lines), str, &opts, 85 return line_config(serial_lines, ARRAY_SIZE(serial_lines), str, &opts,
@@ -175,6 +173,7 @@ static int ssl_console_setup(struct console *co, char *options)
175 return console_open_chan(line, co); 173 return console_open_chan(line, co);
176} 174}
177 175
176/* No locking for register_console call - relies on single-threaded initcalls */
178static struct console ssl_cons = { 177static struct console ssl_cons = {
179 .name = "ttyS", 178 .name = "ttyS",
180 .write = ssl_console_write, 179 .write = ssl_console_write,
@@ -190,9 +189,8 @@ static int ssl_init(void)
190 189
191 printk(KERN_INFO "Initializing software serial port version %d\n", 190 printk(KERN_INFO "Initializing software serial port version %d\n",
192 ssl_version); 191 ssl_version);
193 ssl_driver = line_register_devfs(&lines, &driver, &ssl_ops, 192 ssl_driver = register_lines(&driver, &ssl_ops, serial_lines,
194 serial_lines, 193 ARRAY_SIZE(serial_lines));
195 ARRAY_SIZE(serial_lines));
196 194
197 lines_init(serial_lines, ARRAY_SIZE(serial_lines), &opts); 195 lines_init(serial_lines, ARRAY_SIZE(serial_lines), &opts);
198 196
diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
index a83c42c263b3..8dccdd193d94 100644
--- a/arch/um/drivers/stdio_console.c
+++ b/arch/um/drivers/stdio_console.c
@@ -55,6 +55,8 @@ static int con_config(char *str, char **error_out);
55static int con_get_config(char *dev, char *str, int size, char **error_out); 55static int con_get_config(char *dev, char *str, int size, char **error_out);
56static int con_remove(int n, char **con_remove); 56static int con_remove(int n, char **con_remove);
57 57
58
59/* Const, except for .mc.list */
58static struct line_driver driver = { 60static struct line_driver driver = {
59 .name = "UML console", 61 .name = "UML console",
60 .device_name = "tty", 62 .device_name = "tty",
@@ -66,8 +68,6 @@ static struct line_driver driver = {
66 .read_irq_name = "console", 68 .read_irq_name = "console",
67 .write_irq = CONSOLE_WRITE_IRQ, 69 .write_irq = CONSOLE_WRITE_IRQ,
68 .write_irq_name = "console-write", 70 .write_irq_name = "console-write",
69 .symlink_from = "ttys",
70 .symlink_to = "vc",
71 .mc = { 71 .mc = {
72 .name = "con", 72 .name = "con",
73 .config = con_config, 73 .config = con_config,
@@ -77,10 +77,8 @@ static struct line_driver driver = {
77 }, 77 },
78}; 78};
79 79
80static struct lines console_lines = LINES_INIT(MAX_TTYS); 80/* The array is initialized by line_init, at initcall time. The
81 81 * elements are locked individually as needed.
82/* The array is initialized by line_init, which is an initcall. The
83 * individual elements are protected by individual semaphores.
84 */ 82 */
85static struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver), 83static struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver),
86 [ 1 ... MAX_TTYS - 1 ] = 84 [ 1 ... MAX_TTYS - 1 ] =
@@ -148,6 +146,7 @@ static int uml_console_setup(struct console *co, char *options)
148 return console_open_chan(line, co); 146 return console_open_chan(line, co);
149} 147}
150 148
149/* No locking for register_console call - relies on single-threaded initcalls */
151static struct console stdiocons = { 150static struct console stdiocons = {
152 .name = "tty", 151 .name = "tty",
153 .write = uml_console_write, 152 .write = uml_console_write,
@@ -155,16 +154,14 @@ static struct console stdiocons = {
155 .setup = uml_console_setup, 154 .setup = uml_console_setup,
156 .flags = CON_PRINTBUFFER, 155 .flags = CON_PRINTBUFFER,
157 .index = -1, 156 .index = -1,
158 .data = &vts,
159}; 157};
160 158
161int stdio_init(void) 159int stdio_init(void)
162{ 160{
163 char *new_title; 161 char *new_title;
164 162
165 console_driver = line_register_devfs(&console_lines, &driver, 163 console_driver = register_lines(&driver, &console_ops, vts,
166 &console_ops, vts, 164 ARRAY_SIZE(vts));
167 ARRAY_SIZE(vts));
168 if (console_driver == NULL) 165 if (console_driver == NULL)
169 return -1; 166 return -1;
170 printk(KERN_INFO "Initialized stdio console driver\n"); 167 printk(KERN_INFO "Initialized stdio console driver\n");
diff --git a/arch/um/include/line.h b/arch/um/include/line.h
index a2486b4cc9fe..3477a858eaa9 100644
--- a/arch/um/include/line.h
+++ b/arch/um/include/line.h
@@ -15,19 +15,18 @@
15#include "chan_user.h" 15#include "chan_user.h"
16#include "mconsole_kern.h" 16#include "mconsole_kern.h"
17 17
18/* There's only one modifiable field in this - .mc.list */
18struct line_driver { 19struct line_driver {
19 char *name; 20 const char *name;
20 char *device_name; 21 const char *device_name;
21 short major; 22 const short major;
22 short minor_start; 23 const short minor_start;
23 short type; 24 const short type;
24 short subtype; 25 const short subtype;
25 int read_irq; 26 const int read_irq;
26 char *read_irq_name; 27 const char *read_irq_name;
27 int write_irq; 28 const int write_irq;
28 char *write_irq_name; 29 const char *write_irq_name;
29 char *symlink_from;
30 char *symlink_to;
31 struct mc_device mc; 30 struct mc_device mc;
32}; 31};
33 32
@@ -67,12 +66,6 @@ struct line {
67 .lock = SPIN_LOCK_UNLOCKED, \ 66 .lock = SPIN_LOCK_UNLOCKED, \
68 .driver = d } 67 .driver = d }
69 68
70struct lines {
71 int num;
72};
73
74#define LINES_INIT(n) { .num = n }
75
76extern void line_close(struct tty_struct *tty, struct file * filp); 69extern void line_close(struct tty_struct *tty, struct file * filp);
77extern int line_open(struct line *lines, struct tty_struct *tty); 70extern int line_open(struct line *lines, struct tty_struct *tty);
78extern int line_setup(struct line *lines, unsigned int sizeof_lines, 71extern int line_setup(struct line *lines, unsigned int sizeof_lines,
@@ -94,10 +87,9 @@ extern char *add_xterm_umid(char *base);
94extern int line_setup_irq(int fd, int input, int output, struct line *line, 87extern int line_setup_irq(int fd, int input, int output, struct line *line,
95 void *data); 88 void *data);
96extern void line_close_chan(struct line *line); 89extern void line_close_chan(struct line *line);
97extern struct tty_driver * line_register_devfs(struct lines *set, 90extern struct tty_driver *register_lines(struct line_driver *line_driver,
98 struct line_driver *line_driver, 91 const struct tty_operations *driver,
99 const struct tty_operations *driver, 92 struct line *lines, int nlines);
100 struct line *lines, int nlines);
101extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts); 93extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts);
102extern void close_lines(struct line *lines, int nlines); 94extern void close_lines(struct line *lines, int nlines);
103 95