tty: stop using alloc_tty_driver
[linux-2.6-microblaze.git] / drivers / tty / serial / serial_core.c
index 18ff85a..eb1401b 100644 (file)
@@ -184,8 +184,8 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state,
                int init_hw)
 {
        struct uart_port *uport = uart_port_check(state);
+       unsigned long flags;
        unsigned long page;
-       unsigned long flags = 0;
        int retval = 0;
 
        if (uport->type == PORT_UNKNOWN)
@@ -275,7 +275,7 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
 {
        struct uart_port *uport = uart_port_check(state);
        struct tty_port *port = &state->port;
-       unsigned long flags = 0;
+       unsigned long flags;
        char *xmit_buf = NULL;
 
        /*
@@ -334,39 +334,15 @@ void
 uart_update_timeout(struct uart_port *port, unsigned int cflag,
                    unsigned int baud)
 {
-       unsigned int bits;
-
-       /* byte size and parity */
-       switch (cflag & CSIZE) {
-       case CS5:
-               bits = 7;
-               break;
-       case CS6:
-               bits = 8;
-               break;
-       case CS7:
-               bits = 9;
-               break;
-       default:
-               bits = 10;
-               break; /* CS8 */
-       }
+       unsigned int size;
 
-       if (cflag & CSTOPB)
-               bits++;
-       if (cflag & PARENB)
-               bits++;
-
-       /*
-        * The total number of bits to be transmitted in the fifo.
-        */
-       bits = bits * port->fifosize;
+       size = tty_get_frame_size(cflag) * port->fifosize;
 
        /*
         * Figure the timeout to send the above number of bits.
         * Add .02 seconds of slop
         */
-       port->timeout = (HZ * bits) / baud + HZ/50;
+       port->timeout = (HZ * size) / baud + HZ/50;
 }
 
 EXPORT_SYMBOL(uart_update_timeout);
@@ -616,12 +592,12 @@ static int uart_write(struct tty_struct *tty,
        return ret;
 }
 
-static int uart_write_room(struct tty_struct *tty)
+static unsigned int uart_write_room(struct tty_struct *tty)
 {
        struct uart_state *state = tty->driver_data;
        struct uart_port *port;
        unsigned long flags;
-       int ret;
+       unsigned int ret;
 
        port = uart_port_lock(state, flags);
        ret = uart_circ_chars_free(&state->xmit);
@@ -629,12 +605,12 @@ static int uart_write_room(struct tty_struct *tty)
        return ret;
 }
 
-static int uart_chars_in_buffer(struct tty_struct *tty)
+static unsigned int uart_chars_in_buffer(struct tty_struct *tty)
 {
        struct uart_state *state = tty->driver_data;
        struct uart_port *port;
        unsigned long flags;
-       int ret;
+       unsigned int ret;
 
        port = uart_port_lock(state, flags);
        ret = uart_circ_chars_pending(&state->xmit);
@@ -2338,6 +2314,14 @@ uart_report_port(struct uart_driver *drv, struct uart_port *port)
               port->dev ? ": " : "",
               port->name,
               address, port->irq, port->uartclk / 16, uart_type(port));
+
+       /* The magic multiplier feature is a bit obscure, so report it too.  */
+       if (port->flags & UPF_MAGIC_MULTIPLIER)
+               pr_info("%s%s%s extra baud rates supported: %d, %d",
+                       port->dev ? dev_name(port->dev) : "",
+                       port->dev ? ": " : "",
+                       port->name,
+                       port->uartclk / 8, port->uartclk / 4);
 }
 
 static void
@@ -2546,9 +2530,12 @@ int uart_register_driver(struct uart_driver *drv)
        if (!drv->state)
                goto out;
 
-       normal = alloc_tty_driver(drv->nr);
-       if (!normal)
+       normal = tty_alloc_driver(drv->nr, TTY_DRIVER_REAL_RAW |
+                       TTY_DRIVER_DYNAMIC_DEV);
+       if (IS_ERR(normal)) {
+               retval = PTR_ERR(normal);
                goto out_kfree;
+       }
 
        drv->tty_driver = normal;
 
@@ -2561,7 +2548,6 @@ int uart_register_driver(struct uart_driver *drv)
        normal->init_termios    = tty_std_termios;
        normal->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
        normal->init_termios.c_ispeed = normal->init_termios.c_ospeed = 9600;
-       normal->flags           = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
        normal->driver_state    = drv;
        tty_set_operations(normal, &uart_ops);
 
@@ -3029,26 +3015,28 @@ out:
 /*
  *     Are the two ports equivalent?
  */
-int uart_match_port(struct uart_port *port1, struct uart_port *port2)
+bool uart_match_port(const struct uart_port *port1,
+               const struct uart_port *port2)
 {
        if (port1->iotype != port2->iotype)
-               return 0;
+               return false;
 
        switch (port1->iotype) {
        case UPIO_PORT:
-               return (port1->iobase == port2->iobase);
+               return port1->iobase == port2->iobase;
        case UPIO_HUB6:
-               return (port1->iobase == port2->iobase) &&
-                      (port1->hub6   == port2->hub6);
+               return port1->iobase == port2->iobase &&
+                      port1->hub6   == port2->hub6;
        case UPIO_MEM:
        case UPIO_MEM16:
        case UPIO_MEM32:
        case UPIO_MEM32BE:
        case UPIO_AU:
        case UPIO_TSI:
-               return (port1->mapbase == port2->mapbase);
+               return port1->mapbase == port2->mapbase;
        }
-       return 0;
+
+       return false;
 }
 EXPORT_SYMBOL(uart_match_port);