Commit 5d85b66a authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] tty_driver refcounting

arch/v850/kernel/{memcons,simcons}.c converted to dynamic allocation
parent 174cc1e5
......@@ -58,11 +58,12 @@ static void memcons_write (struct console *co, const char *buf, unsigned len)
len -= write (buf, len);
}
extern struct tty_driver tty_driver;
static struct tty_driver *tty_driver;
static struct tty_driver *memcons_device (struct console *co, int *index)
{
*index = co->index;
return &tty_driver;
return tty_driver;
}
static struct console memcons =
......@@ -82,8 +83,6 @@ void memcons_setup (void)
/* Higher level TTY interface. */
static struct tty_driver tty_driver = { 0 };
int memcons_tty_open (struct tty_struct *tty, struct file *filp)
{
return 0;
......@@ -106,21 +105,32 @@ int memcons_tty_chars_in_buffer (struct tty_struct *tty)
return 0;
}
static struct tty_operations ops = {
.open = memcons_tty_open,
.write = memcons_tty_write,
.write_room = memcons_tty_write_room,
.chars_in_buffer = memcons_tty_chars_in_buffer,
};
int __init memcons_tty_init (void)
{
tty_driver.name = "memcons";
tty_driver.major = TTY_MAJOR;
tty_driver.minor_start = 64;
tty_driver.num = 1;
tty_driver.type = TTY_DRIVER_TYPE_SYSCONS;
tty_driver.init_termios = tty_std_termios;
tty_driver.open = memcons_tty_open;
tty_driver.write = memcons_tty_write;
tty_driver.write_room = memcons_tty_write_room;
tty_driver.chars_in_buffer = memcons_tty_chars_in_buffer;
tty_register_driver (&tty_driver);
int err;
struct tty_driver *driver = alloc_tty_driver(1);
if (!driver)
return -ENOMEM;
driver->name = "memcons";
driver->major = TTY_MAJOR;
driver->minor_start = 64;
driver->type = TTY_DRIVER_TYPE_SYSCONS;
driver->init_termios = tty_std_termios;
tty_set_operations(driver, &ops);
err = tty_register_driver(driver);
if (err) {
put_tty_driver(driver);
return err;
}
tty_driver = driver;
return 0;
}
__initcall (memcons_tty_init);
......@@ -35,11 +35,11 @@ static int simcons_read (struct console *co, const char *buf, unsigned len)
return V850_SIM_SYSCALL (read, 0, buf, len);
}
extern struct tty_driver tty_driver;
static struct tty_driver *tty_driver;
static struct tty_driver *simcons_device (struct console *c, int *index)
{
*index = c->index;
return &tty_driver;
return tty_driver;
}
static struct console simcons =
......@@ -54,8 +54,6 @@ static struct console simcons =
/* Higher level TTY interface. */
static struct tty_driver tty_driver = { 0 };
int simcons_tty_open (struct tty_struct *tty, struct file *filp)
{
return 0;
......@@ -79,22 +77,32 @@ int simcons_tty_chars_in_buffer (struct tty_struct *tty)
return 0;
}
static struct tty_operations ops = {
.open = simcons_tty_open,
.write = simcons_tty_write,
.write_room = simcons_tty_write_room,
.chars_in_buffer = simcons_tty_chars_in_buffer,
};
int __init simcons_tty_init (void)
{
tty_driver.name = "simcons";
tty_driver.major = TTY_MAJOR;
tty_driver.minor_start = 64;
tty_driver.num = 1;
tty_driver.type = TTY_DRIVER_TYPE_SYSCONS;
tty_driver.init_termios = tty_std_termios;
tty_driver.open = simcons_tty_open;
tty_driver.write = simcons_tty_write;
tty_driver.write_room = simcons_tty_write_room;
tty_driver.chars_in_buffer = simcons_tty_chars_in_buffer;
tty_register_driver (&tty_driver);
struct tty_driver *driver = alloc_tty_driver(1);
int err;
if (!driver)
return -ENOMEM;
driver->name = "simcons";
driver->major = TTY_MAJOR;
driver->minor_start = 64;
driver->type = TTY_DRIVER_TYPE_SYSCONS;
driver->init_termios = tty_std_termios;
tty_set_operations(driver, &ops);
err = tty_register_driver(driver);
if (err) {
put_tty_driver(driver);
return err;
}
tty_driver = driver;
return 0;
}
__initcall (simcons_tty_init);
......@@ -139,8 +147,8 @@ void simcons_poll_tty (struct tty_struct *tty)
void simcons_poll_ttys (void)
{
if (tty_driver.ttys[0])
simcons_poll_tty (tty_driver.ttys[0]);
if (tty_driver && tty_driver->ttys[0])
simcons_poll_tty (tty_driver->ttys[0]);
}
void simcons_setup (void)
......
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