Merge branch 'upstream-fixes' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik...
[powerpc.git] / drivers / char / synclink_gt.c
index 2b9cde9..a85a60a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: synclink_gt.c,v 4.20 2005/11/08 19:51:55 paulkf Exp $
+ * $Id: synclink_gt.c,v 4.22 2006/01/09 20:16:06 paulkf Exp $
  *
  * Device driver for Microgate SyncLink GT serial adapters.
  *
@@ -75,7 +75,6 @@
 #include <linux/workqueue.h>
 #include <linux/hdlc.h>
 
-#include <asm/serial.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/irq.h>
@@ -93,7 +92,7 @@
  * module identification
  */
 static char *driver_name     = "SyncLink GT";
-static char *driver_version  = "$Revision: 4.20 $";
+static char *driver_version  = "$Revision: 4.22 $";
 static char *tty_driver_name = "synclink_gt";
 static char *tty_dev_prefix  = "ttySLG";
 MODULE_LICENSE("GPL");
@@ -289,7 +288,6 @@ struct slgt_info {
 
        unsigned char __iomem * reg_addr;  /* memory mapped registers address */
        u32 phys_reg_addr;
-       u32 reg_offset;
        int reg_addr_requested;
 
        MGSL_PARAMS params;       /* communications parameters */
@@ -1750,6 +1748,9 @@ static void rx_async(struct slgt_info *info)
        unsigned char status;
        struct slgt_desc *bufs = info->rbufs;
        int i, count;
+       int chars = 0;
+       int stat;
+       unsigned char ch;
 
        start = end = info->rbuf_current;
 
@@ -1761,16 +1762,15 @@ static void rx_async(struct slgt_info *info)
                DBGDATA(info, p, count, "rx");
 
                for(i=0 ; i < count; i+=2, p+=2) {
-                       if (tty) {
-                               if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-                                       tty_flip_buffer_push(tty);
-                               if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-                                       break;
-                               *tty->flip.char_buf_ptr = *p;
-                               *tty->flip.flag_buf_ptr = 0;
+                       if (tty && chars) {
+                               tty_flip_buffer_push(tty);
+                               chars = 0;
                        }
+                       ch = *p;
                        icount->rx++;
 
+                       stat = 0;
+
                        if ((status = *(p+1) & (BIT9 + BIT8))) {
                                if (status & BIT9)
                                        icount->parity++;
@@ -1779,17 +1779,14 @@ static void rx_async(struct slgt_info *info)
                                /* discard char if tty control flags say so */
                                if (status & info->ignore_status_mask)
                                        continue;
-                               if (tty) {
-                                       if (status & BIT9)
-                                               *tty->flip.flag_buf_ptr = TTY_PARITY;
-                                       else if (status & BIT8)
-                                               *tty->flip.flag_buf_ptr = TTY_FRAME;
-                               }
+                               if (status & BIT9)
+                                       stat = TTY_PARITY;
+                               else if (status & BIT8)
+                                       stat = TTY_FRAME;
                        }
                        if (tty) {
-                               tty->flip.flag_buf_ptr++;
-                               tty->flip.char_buf_ptr++;
-                               tty->flip.count++;
+                               tty_insert_flip_char(tty, ch, stat);
+                               chars++;
                        }
                }
 
@@ -1812,7 +1809,7 @@ static void rx_async(struct slgt_info *info)
                        break;
        }
 
-       if (tty && tty->flip.count)
+       if (tty && chars)
                tty_flip_buffer_push(tty);
 }
 
@@ -2030,7 +2027,7 @@ static void isr_serial(struct slgt_info *info)
                        if (info->tty) {
                                if (!(status & info->ignore_status_mask)) {
                                        if (info->read_status_mask & MASK_BREAK) {
-                                               *info->tty->flip.flag_buf_ptr = TTY_BREAK;
+                                               tty_insert_flip_char(info->tty, 0, TTY_BREAK);
                                                if (info->flags & ASYNC_SAK)
                                                        do_SAK(info->tty);
                                        }
@@ -2633,7 +2630,7 @@ static int get_interface(struct slgt_info *info, int __user *if_mode)
 static int set_interface(struct slgt_info *info, int if_mode)
 {
        unsigned long flags;
-       unsigned char val;
+       unsigned short val;
 
        DBGINFO(("%s set_interface=%x)\n", info->device_name, if_mode));
        spin_lock_irqsave(&info->lock,flags);
@@ -2978,14 +2975,13 @@ static int claim_resources(struct slgt_info *info)
        else
                info->reg_addr_requested = 1;
 
-       info->reg_addr = ioremap(info->phys_reg_addr, PAGE_SIZE);
+       info->reg_addr = ioremap(info->phys_reg_addr, SLGT_REG_SIZE);
        if (!info->reg_addr) {
                DBGERR(("%s cant map device registers, addr=%08X\n",
                        info->device_name, info->phys_reg_addr));
                info->init_error = DiagStatus_CantAssignPciResources;
                goto errout;
        }
-       info->reg_addr += info->reg_offset;
        return 0;
 
 errout:
@@ -3006,7 +3002,7 @@ static void release_resources(struct slgt_info *info)
        }
 
        if (info->reg_addr) {
-               iounmap(info->reg_addr - info->reg_offset);
+               iounmap(info->reg_addr);
                info->reg_addr = NULL;
        }
 }
@@ -3110,12 +3106,6 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev
                info->irq_level = pdev->irq;
                info->phys_reg_addr = pci_resource_start(pdev,0);
 
-               /* veremap works on page boundaries
-                * map full page starting at the page boundary
-                */
-               info->reg_offset    = info->phys_reg_addr & (PAGE_SIZE-1);
-               info->phys_reg_addr &= ~(PAGE_SIZE-1);
-
                info->bus_type = MGSL_BUS_TYPE_PCI;
                info->irq_flags = SA_SHIRQ;