Commit 44eeac38 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] tty_driver refcounting

drivers/char/serial167.c converted to dynamic allocation
parent 24408814
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
DECLARE_TASK_QUEUE(tq_cyclades); DECLARE_TASK_QUEUE(tq_cyclades);
struct tty_driver cy_serial_driver; static struct tty_driver *cy_serial_driver;
extern int serial_console; extern int serial_console;
static struct cyclades_port *serial_console_info = NULL; static struct cyclades_port *serial_console_info = NULL;
static unsigned int serial_console_cflag = 0; static unsigned int serial_console_cflag = 0;
...@@ -2288,6 +2288,23 @@ mvme167_serial_console_setup(int cflag) ...@@ -2288,6 +2288,23 @@ mvme167_serial_console_setup(int cflag)
rcor >> 5, rbpr); rcor >> 5, rbpr);
} /* serial_console_init */ } /* serial_console_init */
static struct tty_operations cy_ops = {
.open = cy_open,
.close = cy_close,
.write = cy_write,
.put_char = cy_put_char,
.flush_chars = cy_flush_chars,
.write_room = cy_write_room,
.chars_in_buffer = cy_chars_in_buffer,
.flush_buffer = cy_flush_buffer,
.ioctl = cy_ioctl,
.throttle = cy_throttle,
.unthrottle = cy_unthrottle,
.set_termios = cy_set_termios,
.stop = cy_stop,
.start = cy_start,
.hangup = cy_hangup,
};
/* The serial driver boot-time initialization code! /* The serial driver boot-time initialization code!
Hardware I/O ports are mapped to character special devices on a Hardware I/O ports are mapped to character special devices on a
first found, first allocated manner. That is, this code searches first found, first allocated manner. That is, this code searches
...@@ -2320,6 +2337,10 @@ serial167_init(void) ...@@ -2320,6 +2337,10 @@ serial167_init(void)
if (!(mvme16x_config &MVME16x_CONFIG_GOT_CD2401)) if (!(mvme16x_config &MVME16x_CONFIG_GOT_CD2401))
return 0; return 0;
cy_serial_driver = alloc_tty_driver(NR_PORTS);
if (!cy_serial_driver)
return -ENOMEM;
#if 0 #if 0
scrn[1] = '\0'; scrn[1] = '\0';
#endif #endif
...@@ -2340,39 +2361,23 @@ scrn[1] = '\0'; ...@@ -2340,39 +2361,23 @@ scrn[1] = '\0';
/* Initialize the tty_driver structure */ /* Initialize the tty_driver structure */
memset(&cy_serial_driver, 0, sizeof(struct tty_driver)); cy_serial_driver->owner = THIS_MODULE;
cy_serial_driver.magic = TTY_DRIVER_MAGIC; cy_serial_driver->devfs_name = "tts/";
cy_serial_driver.owner = THIS_MODULE; cy_serial_driver->name = "ttyS";
cy_serial_driver.devfs_name = "tts/"; cy_serial_driver->major = TTY_MAJOR;
cy_serial_driver.name = "ttyS"; cy_serial_driver->minor_start = 64;
cy_serial_driver.major = TTY_MAJOR; cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
cy_serial_driver.minor_start = 64; cy_serial_driver->subtype = SERIAL_TYPE_NORMAL;
cy_serial_driver.num = NR_PORTS; cy_serial_driver->init_termios = tty_std_termios;
cy_serial_driver.type = TTY_DRIVER_TYPE_SERIAL; cy_serial_driver->init_termios.c_cflag =
cy_serial_driver.subtype = SERIAL_TYPE_NORMAL;
cy_serial_driver.init_termios = tty_std_termios;
cy_serial_driver.init_termios.c_cflag =
B9600 | CS8 | CREAD | HUPCL | CLOCAL; B9600 | CS8 | CREAD | HUPCL | CLOCAL;
cy_serial_driver.flags = TTY_DRIVER_REAL_RAW; cy_serial_driver->flags = TTY_DRIVER_REAL_RAW;
cy_serial_driver.open = cy_open; tty_set_operations(cy_serial_driver, &cy_ops);
cy_serial_driver.close = cy_close;
cy_serial_driver.write = cy_write; ret = tty_register_driver(cy_serial_driver);
cy_serial_driver.put_char = cy_put_char;
cy_serial_driver.flush_chars = cy_flush_chars;
cy_serial_driver.write_room = cy_write_room;
cy_serial_driver.chars_in_buffer = cy_chars_in_buffer;
cy_serial_driver.flush_buffer = cy_flush_buffer;
cy_serial_driver.ioctl = cy_ioctl;
cy_serial_driver.throttle = cy_throttle;
cy_serial_driver.unthrottle = cy_unthrottle;
cy_serial_driver.set_termios = cy_set_termios;
cy_serial_driver.stop = cy_stop;
cy_serial_driver.start = cy_start;
cy_serial_driver.hangup = cy_hangup;
ret = tty_register_driver(&cy_serial_driver);
if (ret) { if (ret) {
printk(KERN_ERR "Couldn't register MVME166/7 serial driver\n"); printk(KERN_ERR "Couldn't register MVME166/7 serial driver\n");
put_tty_driver(cy_serial_driver);
return ret; return ret;
} }
...@@ -2486,8 +2491,9 @@ scrn[1] = '\0'; ...@@ -2486,8 +2491,9 @@ scrn[1] = '\0';
cleanup_irq_cd2401_errors: cleanup_irq_cd2401_errors:
free_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt); free_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt);
cleanup_serial_driver: cleanup_serial_driver:
if (tty_unregister_driver(&cy_serial_driver)) if (tty_unregister_driver(cy_serial_driver))
printk(KERN_ERR "Couldn't unregister MVME166/7 serial driver\n"); printk(KERN_ERR "Couldn't unregister MVME166/7 serial driver\n");
put_tty_driver(cy_serial_driver);
return ret; return ret;
} /* serial167_init */ } /* serial167_init */
...@@ -2735,7 +2741,7 @@ void serial167_console_write(struct console *co, const char *str, unsigned count ...@@ -2735,7 +2741,7 @@ void serial167_console_write(struct console *co, const char *str, unsigned count
static struct tty_driver *serial167_console_device(struct console *c, int *index) static struct tty_driver *serial167_console_device(struct console *c, int *index)
{ {
*index = c->index; *index = c->index;
return &cy_serial_driver; return cy_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