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

[PATCH] tty_driver refcounting

drivers/char/vme_scc.c converted to dynamic allocation
parent af0076e5
......@@ -90,7 +90,7 @@ static irqreturn_t scc_spcond_int(int irq, void *data, struct pt_regs *fp);
static void scc_setsignals(struct scc_port *port, int dtr, int rts);
static void scc_break_ctl(struct tty_struct *tty, int break_state);
static struct tty_driver scc_driver;
static struct tty_driver *scc_driver;
struct scc_port scc_ports[2];
......@@ -115,6 +115,25 @@ static struct real_driver scc_real_driver = {
};
static struct tty_operations scc_ops = {
.open = scc_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 = scc_ioctl,
.throttle = scc_throttle,
.unthrottle = scc_unthrottle,
.set_termios = gs_set_termios,
.stop = gs_stop,
.start = gs_start,
.hangup = gs_hangup,
.break_ctl = scc_break_ctl,
};
/*----------------------------------------------------------------------------
* vme_scc_init() and support functions
*---------------------------------------------------------------------------*/
......@@ -123,42 +142,27 @@ static int scc_init_drivers(void)
{
int error;
memset(&scc_driver, 0, sizeof(scc_driver));
scc_driver.magic = TTY_DRIVER_MAGIC;
scc_driver.owner = THIS_MODULE;
scc_driver.driver_name = "scc";
scc_driver.name = "ttyS";
scc_driver.devfs_name = "tts/";
scc_driver.major = TTY_MAJOR;
scc_driver.minor_start = SCC_MINOR_BASE;
scc_driver.num = 2;
scc_driver.type = TTY_DRIVER_TYPE_SERIAL;
scc_driver.subtype = SERIAL_TYPE_NORMAL;
scc_driver.init_termios = tty_std_termios;
scc_driver.init_termios.c_cflag =
scc_driver = alloc_tty_driver(2);
if (!scc_driver)
return -ENOMEM;
scc_driver->owner = THIS_MODULE;
scc_driver->driver_name = "scc";
scc_driver->name = "ttyS";
scc_driver->devfs_name = "tts/";
scc_driver->major = TTY_MAJOR;
scc_driver->minor_start = SCC_MINOR_BASE;
scc_driver->type = TTY_DRIVER_TYPE_SERIAL;
scc_driver->subtype = SERIAL_TYPE_NORMAL;
scc_driver->init_termios = tty_std_termios;
scc_driver->init_termios.c_cflag =
B9600 | CS8 | CREAD | HUPCL | CLOCAL;
scc_driver.flags = TTY_DRIVER_REAL_RAW;
scc_driver.open = scc_open;
scc_driver.close = gs_close;
scc_driver.write = gs_write;
scc_driver.put_char = gs_put_char;
scc_driver.flush_chars = gs_flush_chars;
scc_driver.write_room = gs_write_room;
scc_driver.chars_in_buffer = gs_chars_in_buffer;
scc_driver.flush_buffer = gs_flush_buffer;
scc_driver.ioctl = scc_ioctl;
scc_driver.throttle = scc_throttle;
scc_driver.unthrottle = scc_unthrottle;
scc_driver.set_termios = gs_set_termios;
scc_driver.stop = gs_stop;
scc_driver.start = gs_start;
scc_driver.hangup = gs_hangup;
scc_driver.break_ctl = scc_break_ctl;
if ((error = tty_register_driver(&scc_driver))) {
scc_driver->flags = TTY_DRIVER_REAL_RAW;
tty_set_operations(scc_driver, &scc_ops);
if ((error = tty_register_driver(scc_driver))) {
printk(KERN_ERR "scc: Couldn't register scc driver, error = %d\n",
error);
put_tty_driver(scc_driver);
return 1;
}
......@@ -1026,7 +1030,7 @@ static void scc_console_write (struct console *co, const char *str, unsigned cou
static struct tty_driver *scc_console_device(struct console *c, int *index)
{
*index = c->index;
return &scc_driver;
return scc_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