]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/serial/sunzilog.c
ttydev: fix pamc_zilog for tty pointer move
[linux-2.6-omap-h63xx.git] / drivers / serial / sunzilog.c
index cb2e405063794f97922aaa6f5eaf9e0d77a15302..0f3d69b86d6795de97bc81239d20fb78cbb920e9 100644 (file)
@@ -329,8 +329,8 @@ sunzilog_receive_chars(struct uart_sunzilog_port *up,
 
        tty = NULL;
        if (up->port.info != NULL &&            /* Unopened serial console */
-           up->port.info->tty != NULL)         /* Keyboard || mouse */
-               tty = up->port.info->tty;
+           up->port.info->port.tty != NULL)    /* Keyboard || mouse */
+               tty = up->port.info->port.tty;
 
        for (;;) {
 
@@ -1015,6 +1015,7 @@ static struct uart_ops sunzilog_pops = {
        .verify_port    =       sunzilog_verify_port,
 };
 
+static int uart_chip_count;
 static struct uart_sunzilog_port *sunzilog_port_table;
 static struct zilog_layout __iomem **sunzilog_chip_regs;
 
@@ -1022,7 +1023,7 @@ static struct uart_sunzilog_port *sunzilog_irq_chain;
 
 static struct uart_driver sunzilog_reg = {
        .owner          =       THIS_MODULE,
-       .driver_name    =       "ttyS",
+       .driver_name    =       "sunzilog",
        .dev_name       =       "ttyS",
        .major          =       TTY_MAJOR,
 };
@@ -1230,7 +1231,7 @@ static inline struct console *SUNZILOG_CONSOLE(void)
 #define SUNZILOG_CONSOLE()     (NULL)
 #endif
 
-static void __devinit sunzilog_init_kbdms(struct uart_sunzilog_port *up, int channel)
+static void __devinit sunzilog_init_kbdms(struct uart_sunzilog_port *up)
 {
        int baud, brg;
 
@@ -1304,7 +1305,7 @@ static void __devinit sunzilog_init_hw(struct uart_sunzilog_port *up)
                up->curregs[R7] = 0x7E; /* SDLC Flag    */
                up->curregs[R9] = NV;
                up->curregs[R7p] = 0x00;
-               sunzilog_init_kbdms(up, up->port.line);
+               sunzilog_init_kbdms(up);
                /* Only enable interrupts if an ISR handler available */
                if (up->flags & SUNZILOG_FLAG_ISR_HANDLER)
                        up->curregs[R9] |= MIE;
@@ -1350,16 +1351,22 @@ static int zilog_irq = -1;
 
 static int __devinit zs_probe(struct of_device *op, const struct of_device_id *match)
 {
-       static int inst;
+       static int kbm_inst, uart_inst;
+       int inst;
        struct uart_sunzilog_port *up;
        struct zilog_layout __iomem *rp;
-       int keyboard_mouse;
+       int keyboard_mouse = 0;
        int err;
 
-       keyboard_mouse = 0;
        if (of_find_property(op->node, "keyboard", NULL))
                keyboard_mouse = 1;
 
+       /* uarts must come before keyboards/mice */
+       if (keyboard_mouse)
+               inst = uart_chip_count + kbm_inst;
+       else
+               inst = uart_inst;
+
        sunzilog_chip_regs[inst] = of_ioremap(&op->resource[0], 0,
                                              sizeof(struct zilog_layout),
                                              "zs");
@@ -1427,6 +1434,7 @@ static int __devinit zs_probe(struct of_device *op, const struct of_device_id *m
                                   rp, sizeof(struct zilog_layout));
                        return err;
                }
+               uart_inst++;
        } else {
                printk(KERN_INFO "%s: Keyboard at MMIO 0x%llx (irq = %d) "
                       "is a %s\n",
@@ -1438,12 +1446,11 @@ static int __devinit zs_probe(struct of_device *op, const struct of_device_id *m
                       op->dev.bus_id,
                       (unsigned long long) up[1].port.mapbase,
                       op->irqs[0], sunzilog_type(&up[1].port));
+               kbm_inst++;
        }
 
        dev_set_drvdata(&op->dev, &up[0]);
 
-       inst++;
-
        return 0;
 }
 
@@ -1491,28 +1498,25 @@ static struct of_platform_driver zs_driver = {
 static int __init sunzilog_init(void)
 {
        struct device_node *dp;
-       int err, uart_count;
-       int num_keybms;
+       int err;
+       int num_keybms = 0;
        int num_sunzilog = 0;
 
-       num_keybms = 0;
        for_each_node_by_name(dp, "zs") {
                num_sunzilog++;
                if (of_find_property(dp, "keyboard", NULL))
                        num_keybms++;
        }
 
-       uart_count = 0;
        if (num_sunzilog) {
-               int uart_count;
-
                err = sunzilog_alloc_tables(num_sunzilog);
                if (err)
                        goto out;
 
-               uart_count = (num_sunzilog * 2) - (2 * num_keybms);
+               uart_chip_count = num_sunzilog - num_keybms;
 
-               err = sunserial_register_minors(&sunzilog_reg, uart_count);
+               err = sunserial_register_minors(&sunzilog_reg,
+                                               uart_chip_count * 2);
                if (err)
                        goto out_free_tables;
        }