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

[PATCH] tty_driver refcounting

drivers/sbus/char/aurora.c converted to dynamic allocation
parent 568b33db
...@@ -85,7 +85,7 @@ int irqhit=0; ...@@ -85,7 +85,7 @@ int irqhit=0;
#define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif #endif
static struct tty_driver aurora_driver; static struct tty_driver *aurora_driver;
static struct Aurora_board aurora_board[AURORA_NBOARD] = { static struct Aurora_board aurora_board[AURORA_NBOARD] = {
{0,}, {0,},
}; };
...@@ -2252,6 +2252,24 @@ static void do_softint(void *private_) ...@@ -2252,6 +2252,24 @@ static void do_softint(void *private_)
#endif #endif
} }
static struct tty_operations aurora_ops = {
.open = aurora_open,
.close = aurora_close,
.write = aurora_write,
.put_char = aurora_put_char,
.flush_chars = aurora_flush_chars,
.write_room = aurora_write_room,
.chars_in_buffer = aurora_chars_in_buffer,
.flush_buffer = aurora_flush_buffer,
.ioctl = aurora_ioctl,
.throttle = aurora_throttle,
.unthrottle = aurora_unthrottle,
.set_termios = aurora_set_termios,
.stop = aurora_stop,
.start = aurora_start,
.hangup = aurora_hangup,
};
static int aurora_init_drivers(void) static int aurora_init_drivers(void)
{ {
int error; int error;
...@@ -2266,38 +2284,25 @@ static int aurora_init_drivers(void) ...@@ -2266,38 +2284,25 @@ static int aurora_init_drivers(void)
return 1; return 1;
} }
init_bh(AURORA_BH, do_aurora_bh); init_bh(AURORA_BH, do_aurora_bh);
/* memset(IRQ_to_board, 0, sizeof(IRQ_to_board));*/ aurora_driver = alloc_tty_driver(AURORA_INPORTS);
memset(&aurora_driver, 0, sizeof(aurora_driver)); if (!aurora_driver) {
aurora_driver.magic = TTY_DRIVER_MAGIC; printk(KERN_ERR "aurora: Couldn't allocate tty driver.\n");
aurora_driver.owner = THIS_MODULE; free_page((unsigned long) tmp_buf);
aurora_driver.name = "ttyA"; return 1;
aurora_driver.major = AURORA_MAJOR; }
aurora_driver.num = AURORA_TNPORTS; aurora_driver->owner = THIS_MODULE;
aurora_driver.type = TTY_DRIVER_TYPE_SERIAL; aurora_driver->name = "ttyA";
aurora_driver.subtype = SERIAL_TYPE_NORMAL; aurora_driver->major = AURORA_MAJOR;
aurora_driver.init_termios = tty_std_termios; aurora_driver->type = TTY_DRIVER_TYPE_SERIAL;
aurora_driver.init_termios.c_cflag = aurora_driver->subtype = SERIAL_TYPE_NORMAL;
aurora_driver->init_termios = tty_std_termios;
aurora_driver->init_termios.c_cflag =
B9600 | CS8 | CREAD | HUPCL | CLOCAL; B9600 | CS8 | CREAD | HUPCL | CLOCAL;
aurora_driver.flags = TTY_DRIVER_REAL_RAW; aurora_driver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(aurora_driver, &aurora_ops);
aurora_driver.open = aurora_open; error = tty_register_driver(aurora_driver);
aurora_driver.close = aurora_close;
aurora_driver.write = aurora_write;
aurora_driver.put_char = aurora_put_char;
aurora_driver.flush_chars = aurora_flush_chars;
aurora_driver.write_room = aurora_write_room;
aurora_driver.chars_in_buffer = aurora_chars_in_buffer;
aurora_driver.flush_buffer = aurora_flush_buffer;
aurora_driver.ioctl = aurora_ioctl;
aurora_driver.throttle = aurora_throttle;
aurora_driver.unthrottle = aurora_unthrottle;
aurora_driver.set_termios = aurora_set_termios;
aurora_driver.stop = aurora_stop;
aurora_driver.start = aurora_start;
aurora_driver.hangup = aurora_hangup;
error = tty_register_driver(&aurora_driver);
if (error) { if (error) {
put_tty_driver(aurora_driver);
free_page((unsigned long) tmp_buf); free_page((unsigned long) tmp_buf);
printk(KERN_ERR "aurora: Couldn't register aurora driver, error = %d\n", printk(KERN_ERR "aurora: Couldn't register aurora driver, error = %d\n",
error); error);
...@@ -2328,7 +2333,8 @@ static void aurora_release_drivers(void) ...@@ -2328,7 +2333,8 @@ static void aurora_release_drivers(void)
printk("aurora_release_drivers: start\n"); printk("aurora_release_drivers: start\n");
#endif #endif
free_page((unsigned long)tmp_buf); free_page((unsigned long)tmp_buf);
tty_unregister_driver(&aurora_driver); tty_unregister_driver(aurora_driver);
put_tty_driver(aurora_driver);
#ifdef AURORA_DEBUG #ifdef AURORA_DEBUG
printk("aurora_release_drivers: end\n"); printk("aurora_release_drivers: end\n");
#endif #endif
......
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