Commit 6b98d858 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] tty_driver refcounting

arch/alpha/kernel/srmcons.c converted to dynamic allocation
parent cb81a46d
......@@ -264,16 +264,9 @@ srmcons_close(struct tty_struct *tty, struct file *filp)
}
static struct tty_driver srmcons_driver = {
.driver_name = "srm",
.name = "srm",
.magic = TTY_DRIVER_MAGIC,
.major = 0, /* dynamic */
.minor_start = 0,
.num = MAX_SRM_CONSOLE_DEVICES,
.type = TTY_DRIVER_TYPE_SYSTEM,
.subtype = SYSTEM_TYPE_SYSCONS,
static struct tty_driver *srmcons_driver;
static struct tty_operations srmcons_ops = {
.open = srmcons_open,
.close = srmcons_close,
.write = srmcons_write,
......@@ -285,8 +278,25 @@ static int __init
srmcons_init(void)
{
if (srm_is_registered_console) {
srmcons_driver.init_termios = tty_std_termios;
return tty_register_driver(&srmcons_driver);
struct tty_driver *driver;
int err;
driver = alloc_tty_driver(MAX_SRM_CONSOLE_DEVICES);
if (!driver)
return -ENOMEM;
driver->driver_name = "srm";
driver->name = "srm";
driver->major = 0; /* dynamic */
driver->minor_start = 0;
driver->type = TTY_DRIVER_TYPE_SYSTEM;
driver->subtype = SYSTEM_TYPE_SYSCONS;
driver->init_termios = tty_std_termios;
err = tty_register_driver(driver);
if (err) {
put_tty_driver(driver);
return err;
}
srmcons_driver = driver;
}
return -ENODEV;
......@@ -312,7 +322,7 @@ static struct tty_driver *
srm_console_device(struct console *co, int *index)
{
*index = co->index;
return &srmcons_driver;
return srmcons_driver;
}
static int __init
......
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