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

[PATCH] tty_driver refcounting

drivers/char/serial_tx3912.c converted to dynamic allocation
parent 44eeac38
...@@ -59,7 +59,7 @@ static struct real_driver rs_real_driver = { ...@@ -59,7 +59,7 @@ static struct real_driver rs_real_driver = {
/* /*
* Structures and such for TTY sessions and usage counts * Structures and such for TTY sessions and usage counts
*/ */
static struct tty_driver rs_driver; static struct tty_driver *rs_driver;
struct rs_port *rs_ports; struct rs_port *rs_ports;
int rs_initialized = 0; int rs_initialized = 0;
...@@ -764,45 +764,48 @@ static int rs_init_portstructs(void) ...@@ -764,45 +764,48 @@ static int rs_init_portstructs(void)
return 0; return 0;
} }
static struct tty_operations rs_ops = {
.open = rs_open,
.close = gs_close,
.write = gs_write,
.put_char = gs_put_char,
.flush_chars = gs_flush_chars,
.write_room = gs_write_room,
.chars_in_buffer = gs_chars_in_buffer,
.flush_buffer = gs_flush_buffer,
.ioctl = rs_ioctl,
.throttle = rs_throttle,
.unthrottle = rs_unthrottle,
.set_termios = gs_set_termios,
.stop = gs_stop,
.start = gs_start,
.hangup = gs_hangup,
};
static int rs_init_drivers(void) static int rs_init_drivers(void)
{ {
int error; int error;
func_enter(); func_enter();
memset(&rs_driver, 0, sizeof(rs_driver)); rs_driver = alloc_tty_driver(TX3912_UART_NPORTS);
rs_driver.magic = TTY_DRIVER_MAGIC; if (!rs_driver)
rs_driver.owner = THIS_MODULE; return -ENOMEM;
rs_driver.driver_name = "serial"; rs_driver->owner = THIS_MODULE;
rs_driver.name = "ttyS"; rs_driver->driver_name = "serial";
rs_driver.major = TTY_MAJOR; rs_driver->name = "ttyS";
rs_driver.minor_start = 64; rs_driver->major = TTY_MAJOR;
rs_driver.num = TX3912_UART_NPORTS; rs_driver->minor_start = 64;
rs_driver.type = TTY_DRIVER_TYPE_SERIAL; rs_driver->type = TTY_DRIVER_TYPE_SERIAL;
rs_driver.subtype = SERIAL_TYPE_NORMAL; rs_driver->subtype = SERIAL_TYPE_NORMAL;
rs_driver.init_termios = tty_std_termios; rs_driver->init_termios = tty_std_termios;
rs_driver.init_termios.c_cflag = rs_driver->init_termios.c_cflag =
B115200 | CS8 | CREAD | HUPCL | CLOCAL; B115200 | CS8 | CREAD | HUPCL | CLOCAL;
tty_set_operations(rs_driver, &rs_ops);
rs_driver.open = rs_open; if ((error = tty_register_driver(rs_driver))) {
rs_driver.close = gs_close;
rs_driver.write = gs_write;
rs_driver.put_char = gs_put_char;
rs_driver.flush_chars = gs_flush_chars;
rs_driver.write_room = gs_write_room;
rs_driver.chars_in_buffer = gs_chars_in_buffer;
rs_driver.flush_buffer = gs_flush_buffer;
rs_driver.ioctl = rs_ioctl;
rs_driver.throttle = rs_throttle;
rs_driver.unthrottle = rs_unthrottle;
rs_driver.set_termios = gs_set_termios;
rs_driver.stop = gs_stop;
rs_driver.start = gs_start;
rs_driver.hangup = gs_hangup;
if ((error = tty_register_driver(&rs_driver))) {
printk(KERN_ERR "Couldn't register serial driver, error = %d\n", printk(KERN_ERR "Couldn't register serial driver, error = %d\n",
error); error);
put_tty_driver(rs_driver);
return 1; return 1;
} }
return 0; return 0;
...@@ -924,7 +927,7 @@ static void serial_console_write(struct console *co, const char *s, ...@@ -924,7 +927,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 &rs_driver; return rs_driver;
} }
static __init int serial_console_setup(struct console *co, char *options) static __init int serial_console_setup(struct console *co, char *options)
......
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