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

[PATCH] tty_driver refcounting

arch/cris/drivers/serial.c converted to dynamic allocation
parent 6b98d858
...@@ -335,7 +335,7 @@ static char *serial_version = "$Revision: 1.3 $"; ...@@ -335,7 +335,7 @@ static char *serial_version = "$Revision: 1.3 $";
static DECLARE_TASK_QUEUE(tq_serial); static DECLARE_TASK_QUEUE(tq_serial);
struct tty_driver serial_driver; static struct tty_driver *serial_driver;
/* serial subtype definitions */ /* serial subtype definitions */
#ifndef SERIAL_TYPE_NORMAL #ifndef SERIAL_TYPE_NORMAL
...@@ -3419,11 +3419,36 @@ show_serial_version(void) ...@@ -3419,11 +3419,36 @@ show_serial_version(void)
/* rs_init inits the driver at boot (using the module_init chain) */ /* rs_init inits the driver at boot (using the module_init chain) */
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,
.break_ctl = rs_break,
.send_xchar = rs_send_xchar,
.wait_until_sent = rs_wait_until_sent,
.read_proc = rs_read_proc,
};
static int __init static int __init
rs_init(void) rs_init(void)
{ {
int i; int i;
struct e100_serial *info; struct e100_serial *info;
struct tty_driver *driver = alloc_tty_driver(NR_PORTS);
if (!driver)
return -ENOMEM;
show_serial_version(); show_serial_version();
...@@ -3439,48 +3464,20 @@ rs_init(void) ...@@ -3439,48 +3464,20 @@ rs_init(void)
/* Initialize the tty_driver structure */ /* Initialize the tty_driver structure */
memset(&serial_driver, 0, sizeof(struct tty_driver)); driver->driver_name = "serial";
serial_driver.magic = TTY_DRIVER_MAGIC; driver->name = "ttyS";
#if (LINUX_VERSION_CODE > 0x20100) driver->major = TTY_MAJOR;
serial_driver.driver_name = "serial"; driver->minor_start = 64;
#endif driver->type = TTY_DRIVER_TYPE_SERIAL;
serial_driver.name = "ttyS"; driver->subtype = SERIAL_TYPE_NORMAL;
serial_driver.major = TTY_MAJOR; driver->init_termios = tty_std_termios;
serial_driver.minor_start = 64; driver->init_termios.c_cflag =
serial_driver.num = NR_PORTS; /* etrax100 has 4 serial ports */
serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
serial_driver.subtype = SERIAL_TYPE_NORMAL;
serial_driver.init_termios = tty_std_termios;
serial_driver.init_termios.c_cflag =
B115200 | CS8 | CREAD | HUPCL | CLOCAL; /* is normally B9600 default... */ B115200 | CS8 | CREAD | HUPCL | CLOCAL; /* is normally B9600 default... */
serial_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS; driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_NO_DEVFS;
tty_set_operations(driver, &rs_ops);
serial_driver.open = rs_open; if (tty_register_driver(driver))
serial_driver.close = rs_close;
serial_driver.write = rs_write;
/* should we have an rs_put_char as well here ? */
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;
#if (LINUX_VERSION_CODE >= 131394) /* Linux 2.1.66 */
serial_driver.break_ctl = rs_break;
#endif
#if (LINUX_VERSION_CODE >= 131343)
serial_driver.send_xchar = rs_send_xchar;
serial_driver.wait_until_sent = rs_wait_until_sent;
serial_driver.read_proc = rs_read_proc;
#endif
if (tty_register_driver(&serial_driver))
panic("Couldn't register serial driver\n"); panic("Couldn't register serial driver\n");
serial_driver = driver;
/* do some initializing for the separate ports */ /* do some initializing for the separate ports */
...@@ -3520,7 +3517,7 @@ rs_init(void) ...@@ -3520,7 +3517,7 @@ rs_init(void)
if (info->enabled) { if (info->enabled) {
printk(KERN_INFO "%s%d at 0x%x is a builtin UART with DMA\n", printk(KERN_INFO "%s%d at 0x%x is a builtin UART with DMA\n",
serial_driver.name, info->line, (unsigned int)info->port); serial_driver->name, info->line, (unsigned int)info->port);
} }
} }
......
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