Commit 568b33db authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] tty_driver refcounting

drivers/tc/zs.c converted to dynamic allocation
parent 4b1fa7e1
...@@ -180,7 +180,7 @@ static unsigned char zs_init_regs[16] __initdata = { ...@@ -180,7 +180,7 @@ static unsigned char zs_init_regs[16] __initdata = {
DECLARE_TASK_QUEUE(tq_zs_serial); DECLARE_TASK_QUEUE(tq_zs_serial);
struct tty_driver serial_driver; static struct tty_driver *serial_driver;
/* serial subtype definitions */ /* serial subtype definitions */
#define SERIAL_TYPE_NORMAL 1 #define SERIAL_TYPE_NORMAL 1
...@@ -1800,6 +1800,25 @@ static void __init probe_sccs(void) ...@@ -1800,6 +1800,25 @@ static void __init probe_sccs(void)
restore_flags(flags); */ restore_flags(flags); */
} }
static struct tty_operations serial_ops = {
.open = rs_open,
.close = rs_close,
.write = rs_write,
.flush_chars = rs_flush_chars,
.write_room = rs_write_room,
.chars_in_buffer = rs_chars_in_buffer,
.flush_buffer = rs_flush_buffer,
.ioctl = rs_ioctl,
.throttle = rs_throttle,
.unthrottle = rs_unthrottle,
.set_termios = rs_set_termios,
.stop = rs_stop,
.start = rs_start,
.hangup = rs_hangup,
.break_ctl = rs_break,
.wait_until_sent = rs_wait_until_sent,
};
/* zs_init inits the driver */ /* zs_init inits the driver */
int __init zs_init(void) int __init zs_init(void)
{ {
...@@ -1817,45 +1836,29 @@ int __init zs_init(void) ...@@ -1817,45 +1836,29 @@ int __init zs_init(void)
if (zs_chain == 0) if (zs_chain == 0)
probe_sccs(); probe_sccs();
serial_driver = alloc_tty_driver(zs_channels_found);
if (!serial_driver)
return -ENOMEM;
show_serial_version(); show_serial_version();
/* Initialize the tty_driver structure */ /* Initialize the tty_driver structure */
/* Not all of this is exactly right for us. */ /* Not all of this is exactly right for us. */
memset(&serial_driver, 0, sizeof(struct tty_driver)); serial_driver->owner = THIS_MODULE;
serial_driver.magic = TTY_DRIVER_MAGIC; serial_driver->devfs_name = "tts/";
serial_driver.owner = THIS_MODULE; serial_driver->name = "ttyS";
serial_driver.devfs_name = "tts/"; serial_driver->major = TTY_MAJOR;
serial_driver.name = "ttyS"; serial_driver->minor_start = 64;
serial_driver.major = TTY_MAJOR; serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
serial_driver.minor_start = 64; serial_driver->subtype = SERIAL_TYPE_NORMAL;
serial_driver.num = zs_channels_found; serial_driver->init_termios = tty_std_termios;
serial_driver.type = TTY_DRIVER_TYPE_SERIAL; serial_driver->init_termios.c_cflag =
serial_driver.subtype = SERIAL_TYPE_NORMAL;
serial_driver.init_termios = tty_std_termios;
serial_driver.init_termios.c_cflag =
B9600 | CS8 | CREAD | HUPCL | CLOCAL; B9600 | CS8 | CREAD | HUPCL | CLOCAL;
serial_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; serial_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
tty_set_operations(serial_driver, &serial_ops);
serial_driver.open = rs_open;
serial_driver.close = rs_close; if (tty_register_driver(serial_driver))
serial_driver.write = rs_write;
serial_driver.flush_chars = rs_flush_chars;
serial_driver.write_room = rs_write_room;
serial_driver.chars_in_buffer = rs_chars_in_buffer;
serial_driver.flush_buffer = rs_flush_buffer;
serial_driver.ioctl = rs_ioctl;
serial_driver.throttle = rs_throttle;
serial_driver.unthrottle = rs_unthrottle;
serial_driver.set_termios = rs_set_termios;
serial_driver.stop = rs_stop;
serial_driver.start = rs_start;
serial_driver.hangup = rs_hangup;
serial_driver.break_ctl = rs_break;
serial_driver.wait_until_sent = rs_wait_until_sent;
if (tty_register_driver(&serial_driver))
panic("Couldn't register serial driver\n"); panic("Couldn't register serial driver\n");
save_flags(flags); cli(); save_flags(flags); cli();
...@@ -1899,7 +1902,7 @@ int __init zs_init(void) ...@@ -1899,7 +1902,7 @@ int __init zs_init(void)
printk("ttyS%02d at 0x%08x (irq = %d)", info->line, printk("ttyS%02d at 0x%08x (irq = %d)", info->line,
info->port, info->irq); info->port, info->irq);
printk(" is a Z85C30 SCC\n"); printk(" is a Z85C30 SCC\n");
tty_register_device(&serial_driver, info->line, NULL); tty_register_device(serial_driver, info->line, NULL);
} }
restore_flags(flags); restore_flags(flags);
...@@ -2051,7 +2054,7 @@ static void serial_console_write(struct console *co, const char *s, ...@@ -2051,7 +2054,7 @@ static void serial_console_write(struct console *co, const char *s,
static struct tty_driver *serial_console_device(struct console *c, int *index) static struct tty_driver *serial_console_device(struct console *c, int *index)
{ {
*index = c->index; *index = c->index;
return &serial_driver; return serial_driver;
} }
/* /*
......
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