Commit 0b9b531b authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] tty_driver refcounting

drivers/serial/mcfserial.c converted to dynamic allocation
parent d4b965ce
...@@ -76,10 +76,7 @@ int mcfrs_console_cbaud = DEFAULT_CBAUD; ...@@ -76,10 +76,7 @@ int mcfrs_console_cbaud = DEFAULT_CBAUD;
/* /*
* Driver data structures. * Driver data structures.
*/ */
struct tty_driver mcfrs_serial_driver; static struct tty_driver *mcfrs_serial_driver;
/* serial subtype definitions */
#define SERIAL_TYPE_NORMAL 1
/* number of characters left in xmit buffer before we ask for more */ /* number of characters left in xmit buffer before we ask for more */
#define WAKEUP_CHARS 256 #define WAKEUP_CHARS 256
...@@ -1545,6 +1542,24 @@ static void show_serial_version(void) ...@@ -1545,6 +1542,24 @@ static void show_serial_version(void)
printk(mcfrs_drivername); printk(mcfrs_drivername);
} }
static struct tty_operations mcfrs_ops = {
.open = mcfrs_open,
.close = mcfrs_close,
.write = mcfrs_write,
.flush_chars = mcfrs_flush_chars,
.write_room = mcfrs_write_room,
.chars_in_buffer = mcfrs_chars_in_buffer,
.flush_buffer = mcfrs_flush_buffer,
.ioctl = mcfrs_ioctl,
.throttle = mcfrs_throttle,
.unthrottle = mcfrs_unthrottle,
.set_termios = mcfrs_set_termios,
.stop = mcfrs_stop,
.start = mcfrs_start,
.hangup = mcfrs_hangup,
.read_proc = mcfrs_readproc,
}
/* mcfrs_init inits the driver */ /* mcfrs_init inits the driver */
static int __init static int __init
mcfrs_init(void) mcfrs_init(void)
...@@ -1562,43 +1577,30 @@ mcfrs_init(void) ...@@ -1562,43 +1577,30 @@ mcfrs_init(void)
add_timer(&mcfrs_timer_struct); add_timer(&mcfrs_timer_struct);
mcfrs_ppstatus = mcf_getppdata() & (MCFPP_DCD0 | MCFPP_DCD1); mcfrs_ppstatus = mcf_getppdata() & (MCFPP_DCD0 | MCFPP_DCD1);
#endif #endif
mcfrs_serial_driver = alloc_tty_driver(NR_PORTS);
if (!mcfrs_serial_driver)
return -ENOMEM;
show_serial_version(); show_serial_version();
/* Initialize the tty_driver structure */ /* Initialize the tty_driver structure */
memset(&mcfrs_serial_driver, 0, sizeof(struct tty_driver)); mcfrs_serial_driver->name = "ttyS";
mcfrs_serial_driver.magic = TTY_DRIVER_MAGIC; mcfrs_serial_driver->driver_name = "serial";
mcfrs_serial_driver.name = "ttyS"; mcfrs_serial_driver->major = TTY_MAJOR;
mcfrs_serial_driver.major = TTY_MAJOR; mcfrs_serial_driver->minor_start = 64;
mcfrs_serial_driver.minor_start = 64; mcfrs_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
mcfrs_serial_driver.num = NR_PORTS; mcfrs_serial_driver->subtype = SERIAL_TYPE_NORMAL;
mcfrs_serial_driver.type = TTY_DRIVER_TYPE_SERIAL; mcfrs_serial_driver->init_termios = tty_std_termios;
mcfrs_serial_driver.subtype = SERIAL_TYPE_NORMAL;
mcfrs_serial_driver.init_termios = tty_std_termios; mcfrs_serial_driver->init_termios.c_cflag =
mcfrs_serial_driver.init_termios.c_cflag =
mcfrs_console_cbaud | CS8 | CREAD | HUPCL | CLOCAL; mcfrs_console_cbaud | CS8 | CREAD | HUPCL | CLOCAL;
mcfrs_serial_driver.flags = TTY_DRIVER_REAL_RAW; mcfrs_serial_driver->flags = TTY_DRIVER_REAL_RAW;
mcfrs_serial_driver.open = mcfrs_open; tty_set_operations(mcfrs_serial_driver, &mcfrs_ops);
mcfrs_serial_driver.close = mcfrs_close;
mcfrs_serial_driver.write = mcfrs_write; if (tty_register_driver(mcfrs_serial_driver)) {
mcfrs_serial_driver.flush_chars = mcfrs_flush_chars;
mcfrs_serial_driver.write_room = mcfrs_write_room;
mcfrs_serial_driver.chars_in_buffer = mcfrs_chars_in_buffer;
mcfrs_serial_driver.flush_buffer = mcfrs_flush_buffer;
mcfrs_serial_driver.ioctl = mcfrs_ioctl;
mcfrs_serial_driver.throttle = mcfrs_throttle;
mcfrs_serial_driver.unthrottle = mcfrs_unthrottle;
mcfrs_serial_driver.set_termios = mcfrs_set_termios;
mcfrs_serial_driver.stop = mcfrs_stop;
mcfrs_serial_driver.start = mcfrs_start;
mcfrs_serial_driver.hangup = mcfrs_hangup;
mcfrs_serial_driver.read_proc = mcfrs_readproc;
mcfrs_serial_driver.driver_name = "serial";
if (tty_register_driver(&mcfrs_serial_driver)) {
printk("MCFRS: Couldn't register serial driver\n"); printk("MCFRS: Couldn't register serial driver\n");
put_tty_driver(mcfrs_serial_driver);
return(-EBUSY); return(-EBUSY);
} }
...@@ -1627,8 +1629,7 @@ mcfrs_init(void) ...@@ -1627,8 +1629,7 @@ mcfrs_init(void)
mcfrs_setsignals(info, 0, 0); mcfrs_setsignals(info, 0, 0);
mcfrs_irqinit(info); mcfrs_irqinit(info);
printk("%s%d at 0x%04x (irq = %d)", mcfrs_serial_driver.name, printk("ttyS%d at 0x%04x (irq = %d)", info->line, info->addr, info->irq);
info->line, info->addr, info->irq);
printk(" is a builtin ColdFire UART\n"); printk(" is a builtin ColdFire UART\n");
} }
...@@ -1720,7 +1721,7 @@ int mcfrs_console_setup(struct console *cp, char *arg) ...@@ -1720,7 +1721,7 @@ int mcfrs_console_setup(struct console *cp, char *arg)
static struct tty_driver *mcfrs_console_device(struct console *c, int *index) static struct tty_driver *mcfrs_console_device(struct console *c, int *index)
{ {
*index = c->index; *index = c->index;
return &mcfrs_serial_driver; return mcfrs_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