[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>
This commit is contained in:
parent
b4ac91a0ea
commit
d5c9ffc6c6
4 changed files with 31 additions and 45 deletions
|
@ -707,10 +707,9 @@ int line_remove(struct line *lines, unsigned int num, int n, char **error_out)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tty_driver *line_register_devfs(struct lines *set,
|
struct tty_driver *register_lines(struct line_driver *line_driver,
|
||||||
struct line_driver *line_driver,
|
const struct tty_operations *ops,
|
||||||
const struct tty_operations *ops,
|
struct line *lines, int nlines)
|
||||||
struct line *lines, int nlines)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct tty_driver *driver = alloc_tty_driver(nlines);
|
struct tty_driver *driver = alloc_tty_driver(nlines);
|
||||||
|
|
|
@ -51,6 +51,8 @@ static int ssl_config(char *str, char **error_out);
|
||||||
static int ssl_get_config(char *dev, char *str, int size, char **error_out);
|
static int ssl_get_config(char *dev, char *str, int size, char **error_out);
|
||||||
static int ssl_remove(int n, char **error_out);
|
static int ssl_remove(int n, char **error_out);
|
||||||
|
|
||||||
|
|
||||||
|
/* Const, except for .mc.list */
|
||||||
static struct line_driver driver = {
|
static struct line_driver driver = {
|
||||||
.name = "UML serial line",
|
.name = "UML serial line",
|
||||||
.device_name = "ttyS",
|
.device_name = "ttyS",
|
||||||
|
@ -62,8 +64,6 @@ static struct line_driver driver = {
|
||||||
.read_irq_name = "ssl",
|
.read_irq_name = "ssl",
|
||||||
.write_irq = SSL_WRITE_IRQ,
|
.write_irq = SSL_WRITE_IRQ,
|
||||||
.write_irq_name = "ssl-write",
|
.write_irq_name = "ssl-write",
|
||||||
.symlink_from = "serial",
|
|
||||||
.symlink_to = "tts",
|
|
||||||
.mc = {
|
.mc = {
|
||||||
.list = LIST_HEAD_INIT(driver.mc.list),
|
.list = LIST_HEAD_INIT(driver.mc.list),
|
||||||
.name = "ssl",
|
.name = "ssl",
|
||||||
|
@ -74,14 +74,12 @@ static struct line_driver driver = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The array is initialized by line_init, which is an initcall. The
|
/* The array is initialized by line_init, at initcall time. The
|
||||||
* individual elements are protected by individual semaphores.
|
* elements are locked individually as needed.
|
||||||
*/
|
*/
|
||||||
static struct line serial_lines[NR_PORTS] =
|
static struct line serial_lines[NR_PORTS] =
|
||||||
{ [0 ... NR_PORTS - 1] = LINE_INIT(CONFIG_SSL_CHAN, &driver) };
|
{ [0 ... NR_PORTS - 1] = LINE_INIT(CONFIG_SSL_CHAN, &driver) };
|
||||||
|
|
||||||
static struct lines lines = LINES_INIT(NR_PORTS);
|
|
||||||
|
|
||||||
static int ssl_config(char *str, char **error_out)
|
static int ssl_config(char *str, char **error_out)
|
||||||
{
|
{
|
||||||
return line_config(serial_lines, ARRAY_SIZE(serial_lines), str, &opts,
|
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)
|
||||||
return console_open_chan(line, co);
|
return console_open_chan(line, co);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* No locking for register_console call - relies on single-threaded initcalls */
|
||||||
static struct console ssl_cons = {
|
static struct console ssl_cons = {
|
||||||
.name = "ttyS",
|
.name = "ttyS",
|
||||||
.write = ssl_console_write,
|
.write = ssl_console_write,
|
||||||
|
@ -190,9 +189,8 @@ 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);
|
||||||
ssl_driver = line_register_devfs(&lines, &driver, &ssl_ops,
|
ssl_driver = register_lines(&driver, &ssl_ops, serial_lines,
|
||||||
serial_lines,
|
ARRAY_SIZE(serial_lines));
|
||||||
ARRAY_SIZE(serial_lines));
|
|
||||||
|
|
||||||
lines_init(serial_lines, ARRAY_SIZE(serial_lines), &opts);
|
lines_init(serial_lines, ARRAY_SIZE(serial_lines), &opts);
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,8 @@ static int con_config(char *str, char **error_out);
|
||||||
static int con_get_config(char *dev, char *str, int size, char **error_out);
|
static int con_get_config(char *dev, char *str, int size, char **error_out);
|
||||||
static int con_remove(int n, char **con_remove);
|
static int con_remove(int n, char **con_remove);
|
||||||
|
|
||||||
|
|
||||||
|
/* Const, except for .mc.list */
|
||||||
static struct line_driver driver = {
|
static struct line_driver driver = {
|
||||||
.name = "UML console",
|
.name = "UML console",
|
||||||
.device_name = "tty",
|
.device_name = "tty",
|
||||||
|
@ -66,8 +68,6 @@ static struct line_driver driver = {
|
||||||
.read_irq_name = "console",
|
.read_irq_name = "console",
|
||||||
.write_irq = CONSOLE_WRITE_IRQ,
|
.write_irq = CONSOLE_WRITE_IRQ,
|
||||||
.write_irq_name = "console-write",
|
.write_irq_name = "console-write",
|
||||||
.symlink_from = "ttys",
|
|
||||||
.symlink_to = "vc",
|
|
||||||
.mc = {
|
.mc = {
|
||||||
.name = "con",
|
.name = "con",
|
||||||
.config = con_config,
|
.config = con_config,
|
||||||
|
@ -77,10 +77,8 @@ static struct line_driver driver = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct lines console_lines = LINES_INIT(MAX_TTYS);
|
/* The array is initialized by line_init, at initcall time. The
|
||||||
|
* elements are locked individually as needed.
|
||||||
/* The array is initialized by line_init, which is an initcall. The
|
|
||||||
* individual elements are protected by individual semaphores.
|
|
||||||
*/
|
*/
|
||||||
static struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver),
|
static struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver),
|
||||||
[ 1 ... MAX_TTYS - 1 ] =
|
[ 1 ... MAX_TTYS - 1 ] =
|
||||||
|
@ -148,6 +146,7 @@ static int uml_console_setup(struct console *co, char *options)
|
||||||
return console_open_chan(line, co);
|
return console_open_chan(line, co);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* No locking for register_console call - relies on single-threaded initcalls */
|
||||||
static struct console stdiocons = {
|
static struct console stdiocons = {
|
||||||
.name = "tty",
|
.name = "tty",
|
||||||
.write = uml_console_write,
|
.write = uml_console_write,
|
||||||
|
@ -155,16 +154,14 @@ static struct console stdiocons = {
|
||||||
.setup = uml_console_setup,
|
.setup = uml_console_setup,
|
||||||
.flags = CON_PRINTBUFFER,
|
.flags = CON_PRINTBUFFER,
|
||||||
.index = -1,
|
.index = -1,
|
||||||
.data = &vts,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int stdio_init(void)
|
int stdio_init(void)
|
||||||
{
|
{
|
||||||
char *new_title;
|
char *new_title;
|
||||||
|
|
||||||
console_driver = line_register_devfs(&console_lines, &driver,
|
console_driver = register_lines(&driver, &console_ops, vts,
|
||||||
&console_ops, vts,
|
ARRAY_SIZE(vts));
|
||||||
ARRAY_SIZE(vts));
|
|
||||||
if (console_driver == NULL)
|
if (console_driver == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
printk(KERN_INFO "Initialized stdio console driver\n");
|
printk(KERN_INFO "Initialized stdio console driver\n");
|
||||||
|
|
|
@ -15,19 +15,18 @@
|
||||||
#include "chan_user.h"
|
#include "chan_user.h"
|
||||||
#include "mconsole_kern.h"
|
#include "mconsole_kern.h"
|
||||||
|
|
||||||
|
/* There's only one modifiable field in this - .mc.list */
|
||||||
struct line_driver {
|
struct line_driver {
|
||||||
char *name;
|
const char *name;
|
||||||
char *device_name;
|
const char *device_name;
|
||||||
short major;
|
const short major;
|
||||||
short minor_start;
|
const short minor_start;
|
||||||
short type;
|
const short type;
|
||||||
short subtype;
|
const short subtype;
|
||||||
int read_irq;
|
const int read_irq;
|
||||||
char *read_irq_name;
|
const char *read_irq_name;
|
||||||
int write_irq;
|
const int write_irq;
|
||||||
char *write_irq_name;
|
const char *write_irq_name;
|
||||||
char *symlink_from;
|
|
||||||
char *symlink_to;
|
|
||||||
struct mc_device mc;
|
struct mc_device mc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -67,12 +66,6 @@ struct line {
|
||||||
.lock = SPIN_LOCK_UNLOCKED, \
|
.lock = SPIN_LOCK_UNLOCKED, \
|
||||||
.driver = d }
|
.driver = d }
|
||||||
|
|
||||||
struct lines {
|
|
||||||
int num;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define LINES_INIT(n) { .num = n }
|
|
||||||
|
|
||||||
extern void line_close(struct tty_struct *tty, struct file * filp);
|
extern void line_close(struct tty_struct *tty, struct file * filp);
|
||||||
extern int line_open(struct line *lines, struct tty_struct *tty);
|
extern int line_open(struct line *lines, struct tty_struct *tty);
|
||||||
extern int line_setup(struct line *lines, unsigned int sizeof_lines,
|
extern int line_setup(struct line *lines, unsigned int sizeof_lines,
|
||||||
|
@ -94,10 +87,9 @@ extern char *add_xterm_umid(char *base);
|
||||||
extern int line_setup_irq(int fd, int input, int output, struct line *line,
|
extern int line_setup_irq(int fd, int input, int output, struct line *line,
|
||||||
void *data);
|
void *data);
|
||||||
extern void line_close_chan(struct line *line);
|
extern void line_close_chan(struct line *line);
|
||||||
extern struct tty_driver * line_register_devfs(struct lines *set,
|
extern struct tty_driver *register_lines(struct line_driver *line_driver,
|
||||||
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 void lines_init(struct line *lines, int nlines, struct chan_opts *opts);
|
||||||
extern void close_lines(struct line *lines, int nlines);
|
extern void close_lines(struct line *lines, int nlines);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue