Commit 51491305 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] tty_driver refcounting

arch/um/drivers/* converted to dynamic allocation
parent bb6b371b
...@@ -399,12 +399,17 @@ int line_remove(struct line *lines, int num, char *str) ...@@ -399,12 +399,17 @@ int line_remove(struct line *lines, int num, char *str)
return(line_setup(lines, num, config, 0)); return(line_setup(lines, num, config, 0));
} }
void line_register_devfs(struct lines *set, struct line_driver *line_driver, struct tty_driver *line_register_devfs(struct lines *set,
struct tty_driver *driver, struct line *lines, struct line_driver *line_driver,
struct tty_operations *ops, struct line *lines,
int nlines) int nlines)
{ {
int err, i; int err, i;
char *from, *to; char *from, *to;
struct tty_driver *driver = alloc_tty_driver(nlines);
if (!driver)
return NULL;
driver->driver_name = line_driver->name; driver->driver_name = line_driver->name;
driver->name = line_driver->devfs_name; driver->name = line_driver->devfs_name;
...@@ -412,11 +417,9 @@ void line_register_devfs(struct lines *set, struct line_driver *line_driver, ...@@ -412,11 +417,9 @@ void line_register_devfs(struct lines *set, struct line_driver *line_driver,
driver->minor_start = line_driver->minor_start; driver->minor_start = line_driver->minor_start;
driver->type = line_driver->type; driver->type = line_driver->type;
driver->subtype = line_driver->subtype; driver->subtype = line_driver->subtype;
driver->magic = TTY_DRIVER_MAGIC;
driver->flags = TTY_DRIVER_REAL_RAW; driver->flags = TTY_DRIVER_REAL_RAW;
driver->num = set->num;
driver->write_room = line_write_room;
driver->init_termios = tty_std_termios; driver->init_termios = tty_std_termios;
tty_set_operations(driver, ops);
if (tty_register_driver(driver)) if (tty_register_driver(driver))
panic("line_register_devfs : Couldn't register driver\n"); panic("line_register_devfs : Couldn't register driver\n");
...@@ -433,6 +436,7 @@ void line_register_devfs(struct lines *set, struct line_driver *line_driver, ...@@ -433,6 +436,7 @@ void line_register_devfs(struct lines *set, struct line_driver *line_driver,
} }
mconsole_register_dev(&line_driver->mc); mconsole_register_dev(&line_driver->mc);
return driver;
} }
void lines_init(struct line *lines, int nlines) void lines_init(struct line *lines, int nlines)
......
...@@ -29,7 +29,7 @@ static int ssl_version = 1; ...@@ -29,7 +29,7 @@ static int ssl_version = 1;
* by the tty driver. * by the tty driver.
*/ */
static struct tty_driver ssl_driver; static struct tty_driver *ssl_driver;
#define NR_PORTS 64 #define NR_PORTS 64
...@@ -189,7 +189,7 @@ void ssl_hangup(struct tty_struct *tty) ...@@ -189,7 +189,7 @@ void ssl_hangup(struct tty_struct *tty)
{ {
} }
static struct tty_driver ssl_driver = { static struct tty_operations ssl_ops = {
.open = ssl_open, .open = ssl_open,
.close = ssl_close, .close = ssl_close,
.write = ssl_write, .write = ssl_write,
...@@ -203,7 +203,8 @@ static struct tty_driver ssl_driver = { ...@@ -203,7 +203,8 @@ static struct tty_driver ssl_driver = {
.set_termios = ssl_set_termios, .set_termios = ssl_set_termios,
.stop = ssl_stop, .stop = ssl_stop,
.start = ssl_start, .start = ssl_start,
.hangup = ssl_hangup .hangup = ssl_hangup,
.write_room = line_write_room,
}; };
/* Changed by ssl_init and referenced by ssl_exit, which are both serialized /* Changed by ssl_init and referenced by ssl_exit, which are both serialized
...@@ -218,8 +219,8 @@ int ssl_init(void) ...@@ -218,8 +219,8 @@ 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);
line_register_devfs(&lines, &driver, &ssl_driver, serial_lines, ssl_driver = line_register_devfs(&lines, &driver, &ssl_ops,
sizeof(serial_lines)/sizeof(serial_lines[0])); serial_lines, sizeof(serial_lines)/sizeof(serial_lines[0]));
lines_init(serial_lines, sizeof(serial_lines)/sizeof(serial_lines[0])); lines_init(serial_lines, sizeof(serial_lines)/sizeof(serial_lines[0]));
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
* by the tty driver. * by the tty driver.
*/ */
static struct tty_driver console_driver; static struct tty_driver *console_driver;
static struct chan_ops init_console_ops = { static struct chan_ops init_console_ops = {
.type = "you shouldn't see this", .type = "you shouldn't see this",
...@@ -165,8 +165,8 @@ int stdio_init(void) ...@@ -165,8 +165,8 @@ int stdio_init(void)
printk(KERN_INFO "Initializing stdio console driver\n"); printk(KERN_INFO "Initializing stdio console driver\n");
line_register_devfs(&console_lines, &driver, &console_driver, vts, console_driver = line_register_devfs(&console_lines, &driver,
sizeof(vts)/sizeof(vts[0])); &console_ops, vts, sizeof(vts)/sizeof(vts[0]));
lines_init(vts, sizeof(vts)/sizeof(vts[0])); lines_init(vts, sizeof(vts)/sizeof(vts[0]));
...@@ -188,18 +188,19 @@ static void console_write(struct console *console, const char *string, ...@@ -188,18 +188,19 @@ static void console_write(struct console *console, const char *string,
if(con_init_done) up(&vts[console->index].sem); if(con_init_done) up(&vts[console->index].sem);
} }
static struct tty_driver console_driver = { static struct tty_operations console_ops = {
.open = con_open, .open = con_open,
.close = con_close, .close = con_close,
.write = con_write, .write = con_write,
.chars_in_buffer = chars_in_buffer, .chars_in_buffer = chars_in_buffer,
.set_termios = set_termios .set_termios = set_termios,
.write_room = line_write_room,
}; };
static struct tty_driver *console_device(struct console *c, int *index) static struct tty_driver *console_device(struct console *c, int *index)
{ {
*index = c->index; *index = c->index;
return &console_driver; return console_driver;
} }
static int console_setup(struct console *co, char *options) static int console_setup(struct console *co, char *options)
......
...@@ -81,9 +81,10 @@ extern char *add_xterm_umid(char *base); ...@@ -81,9 +81,10 @@ extern char *add_xterm_umid(char *base);
extern int line_setup_irq(int fd, int input, int output, void *data); extern int line_setup_irq(int fd, int input, int output, void *data);
extern void line_close_chan(struct line *line); extern void line_close_chan(struct line *line);
extern void line_disable(struct line *line, int current_irq); extern void line_disable(struct line *line, int current_irq);
extern void line_register_devfs(struct lines *set, extern struct tty_driver * line_register_devfs(struct lines *set,
struct line_driver *line_driver, struct line_driver *line_driver,
struct tty_driver *driver, struct line *lines, struct tty_operations *driver,
struct line *lines,
int nlines); int nlines);
extern void lines_init(struct line *lines, int nlines); extern void lines_init(struct line *lines, int nlines);
extern void close_lines(struct line *lines, int nlines); extern void close_lines(struct line *lines, int nlines);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment