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

[PATCH] tty_driver refcounting

drivers/serial/68328serial.c converted to dynamic allocation
parent 15ccfaf0
...@@ -83,7 +83,7 @@ struct m68k_serial *m68k_consinfo = 0; ...@@ -83,7 +83,7 @@ struct m68k_serial *m68k_consinfo = 0;
extern wait_queue_head_t keypress_wait; extern wait_queue_head_t keypress_wait;
#endif #endif
struct tty_driver serial_driver; struct tty_driver *serial_driver;
/* serial subtype definitions */ /* serial subtype definitions */
#define SERIAL_TYPE_NORMAL 1 #define SERIAL_TYPE_NORMAL 1
...@@ -1415,6 +1415,24 @@ void startup_console(void) ...@@ -1415,6 +1415,24 @@ void startup_console(void)
#endif #endif
static struct tty_operations rs_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,
.set_ldisc = rs_set_ldisc,
};
/* rs_init inits the driver */ /* rs_init inits the driver */
static int __init static int __init
rs68328_init(void) rs68328_init(void)
...@@ -1422,42 +1440,31 @@ rs68328_init(void) ...@@ -1422,42 +1440,31 @@ rs68328_init(void)
int flags, i; int flags, i;
struct m68k_serial *info; struct m68k_serial *info;
serial_driver = alloc_tty_driver(NR_PORTS);
if (!serial_driver)
return -ENOMEM;
show_serial_version(); show_serial_version();
/* Initialize the tty_driver structure */ /* Initialize the tty_driver structure */
/* SPARC: Not all of this is exactly right for us. */ /* SPARC: Not all of this is exactly right for us. */
memset(&serial_driver, 0, sizeof(struct tty_driver)); serial_driver->name = "ttyS";
serial_driver.magic = TTY_DRIVER_MAGIC; 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 = NR_PORTS; 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 =
m68328_console_cbaud | CS8 | CREAD | HUPCL | CLOCAL; m68328_console_cbaud | CS8 | CREAD | HUPCL | CLOCAL;
serial_driver.flags = TTY_DRIVER_REAL_RAW; serial_driver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(serial_driver, &rs_ops);
serial_driver.open = rs_open;
serial_driver.close = rs_close; if (tty_register_driver(serial_driver)) {
serial_driver.write = rs_write; put_tty_driver(serial_driver);
serial_driver.flush_chars = rs_flush_chars; printk(KERN_ERR "Couldn't register serial driver\n");
serial_driver.write_room = rs_write_room; return -ENOMEM;
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.set_ldisc = rs_set_ldisc;
if (tty_register_driver(&serial_driver))
panic("Couldn't register serial driver\n");
save_flags(flags); cli(); save_flags(flags); cli();
...@@ -1482,7 +1489,7 @@ rs68328_init(void) ...@@ -1482,7 +1489,7 @@ rs68328_init(void)
info->line = i; info->line = i;
info->is_cons = 1; /* Means shortcuts work */ info->is_cons = 1; /* Means shortcuts work */
printk("%s%d at 0x%08x (irq = %d)", serial_driver.name, info->line, printk("%s%d at 0x%08x (irq = %d)", serial_driver->name, info->line,
info->port, info->irq); info->port, info->irq);
printk(" is a builtin MC68328 UART\n"); printk(" is a builtin MC68328 UART\n");
...@@ -1589,7 +1596,7 @@ int m68328_console_setup(struct console *cp, char *arg) ...@@ -1589,7 +1596,7 @@ int m68328_console_setup(struct console *cp, char *arg)
static struct tty_driver *m68328_console_device(struct console *c, int *index) static struct tty_driver *m68328_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