serial: imx: bit &/| confusion
[safe/jmp/linux-2.6] / drivers / serial / sunsab.c
index ff610c2..d514e28 100644 (file)
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/init.h>
+#include <linux/of_device.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/prom.h>
-#include <asm/of_device.h>
 
 #if defined(CONFIG_SERIAL_SUNSAB_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
 #define SUPPORT_SYSRQ
@@ -117,8 +117,8 @@ receive_chars(struct uart_sunsab_port *up,
        int count = 0;
        int i;
 
-       if (up->port.info != NULL)              /* Unopened serial console */
-               tty = up->port.info->tty;
+       if (up->port.state != NULL)             /* Unopened serial console */
+               tty = up->port.state->port.tty;
 
        /* Read number of BYTES (Character + Status) available. */
        if (stat->sreg.isr0 & SAB82532_ISR0_RPF) {
@@ -229,7 +229,7 @@ static void sunsab_tx_idle(struct uart_sunsab_port *);
 static void transmit_chars(struct uart_sunsab_port *up,
                           union sab82532_irq_status *stat)
 {
-       struct circ_buf *xmit = &up->port.info->xmit;
+       struct circ_buf *xmit = &up->port.state->xmit;
        int i;
 
        if (stat->sreg.isr1 & SAB82532_ISR1_ALLS) {
@@ -297,7 +297,7 @@ static void check_status(struct uart_sunsab_port *up,
                up->port.icount.dsr++;
        }
 
-       wake_up_interruptible(&up->port.info->delta_msr_wait);
+       wake_up_interruptible(&up->port.state->port.delta_msr_wait);
 }
 
 static irqreturn_t sunsab_interrupt(int irq, void *dev_id)
@@ -429,7 +429,7 @@ static void sunsab_tx_idle(struct uart_sunsab_port *up)
 static void sunsab_start_tx(struct uart_port *port)
 {
        struct uart_sunsab_port *up = (struct uart_sunsab_port *) port;
-       struct circ_buf *xmit = &up->port.info->xmit;
+       struct circ_buf *xmit = &up->port.state->xmit;
        int i;
 
        up->interrupt_mask1 &= ~(SAB82532_IMR1_ALLS|SAB82532_IMR1_XPR);
@@ -826,13 +826,12 @@ static struct uart_ops sunsab_pops = {
 
 static struct uart_driver sunsab_reg = {
        .owner                  = THIS_MODULE,
-       .driver_name            = "serial",
+       .driver_name            = "sunsab",
        .dev_name               = "ttyS",
        .major                  = TTY_MAJOR,
 };
 
 static struct uart_sunsab_port *sunsab_ports;
-static int num_channels;
 
 #ifdef CONFIG_SERIAL_SUNSAB_CONSOLE
 
@@ -884,7 +883,7 @@ static int sunsab_console_setup(struct console *con, char *options)
        printk("Console: ttyS%d (SAB82532)\n",
               (sunsab_reg.minor - 64) + con->index);
 
-       sunserial_console_termios(con);
+       sunserial_console_termios(con, to_of_device(up->port.dev)->node);
 
        switch (con->cflag & CBAUD) {
        case B150: baud = 150; break;
@@ -1028,10 +1027,12 @@ static int __devinit sab_probe(struct of_device *op, const struct of_device_id *
                goto out1;
 
        sunserial_console_match(SUNSAB_CONSOLE(), op->node,
-                               &sunsab_reg, up[0].port.line);
+                               &sunsab_reg, up[0].port.line,
+                               false);
 
        sunserial_console_match(SUNSAB_CONSOLE(), op->node,
-                               &sunsab_reg, up[1].port.line);
+                               &sunsab_reg, up[1].port.line,
+                               false);
 
        err = uart_add_one_port(&sunsab_reg, &up[0].port);
        if (err)
@@ -1079,7 +1080,7 @@ static int __devexit sab_remove(struct of_device *op)
        return 0;
 }
 
-static struct of_device_id sab_match[] = {
+static const struct of_device_id sab_match[] = {
        {
                .name = "se",
        },
@@ -1102,8 +1103,8 @@ static int __init sunsab_init(void)
 {
        struct device_node *dp;
        int err;
+       int num_channels = 0;
 
-       num_channels = 0;
        for_each_node_by_name(dp, "se")
                num_channels += 2;
        for_each_node_by_name(dp, "serial") {
@@ -1117,20 +1118,13 @@ static int __init sunsab_init(void)
                if (!sunsab_ports)
                        return -ENOMEM;
 
-               sunsab_reg.minor = sunserial_current_minor;
-               sunsab_reg.nr = num_channels;
-               sunsab_reg.cons = SUNSAB_CONSOLE();
-
-               err = uart_register_driver(&sunsab_reg);
+               err = sunserial_register_minors(&sunsab_reg, num_channels);
                if (err) {
                        kfree(sunsab_ports);
                        sunsab_ports = NULL;
 
                        return err;
                }
-
-               sunsab_reg.tty_driver->name_base = sunsab_reg.minor - 64;
-               sunserial_current_minor += num_channels;
        }
 
        return of_register_driver(&sab_driver, &of_bus_type);
@@ -1139,9 +1133,8 @@ static int __init sunsab_init(void)
 static void __exit sunsab_exit(void)
 {
        of_unregister_driver(&sab_driver);
-       if (num_channels) {
-               sunserial_current_minor -= num_channels;
-               uart_unregister_driver(&sunsab_reg);
+       if (sunsab_reg.nr) {
+               sunserial_unregister_minors(&sunsab_reg, sunsab_reg.nr);
        }
 
        kfree(sunsab_ports);