]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/atm/firestream.c
smc91x: Add code to detect errors caused by bad memory timings
[linux-2.6-omap-h63xx.git] / drivers / atm / firestream.c
index 38fc054bd6715246f261f5a2e88e432026ef92eb..7f6d02ce1b5f53da024bddd9e1ef0976c593ad01 100644 (file)
@@ -512,7 +512,7 @@ static unsigned int make_rate (unsigned int rate, int r,
                }
                case ROUND_UP: {
                        /* check all bits that we are discarding */
-                       if (man & (-1>>9)) {
+                       if (man & (~0U>>9)) {
                                man = (man>>(32-9)) + 1;
                                if (man == (1<<9)) {
                                        /* no need to check for round up outside of range */
@@ -1002,6 +1002,10 @@ static int fs_open(struct atm_vcc *atm_vcc)
                                        r = ROUND_UP;
                                }
                                error = make_rate (pcr, r, &tmc0, NULL);
+                               if (error) {
+                                       kfree(tc);
+                                       return error;
+                               }
                        }
                        fs_dprintk (FS_DEBUG_OPEN, "pcr = %d.\n", pcr);
                }
@@ -1471,6 +1475,7 @@ static void top_off_fp (struct fs_dev *dev, struct freepool *fp,
        struct FS_BPENTRY *qe, *ne;
        struct sk_buff *skb;
        int n = 0;
+       u32 qe_tmp;
 
        fs_dprintk (FS_DEBUG_QUEUE, "Topping off queue at %x (%d-%d/%d)\n", 
                    fp->offset, read_fs (dev, FP_CNT (fp->offset)), fp->n, 
@@ -1498,10 +1503,16 @@ static void top_off_fp (struct fs_dev *dev, struct freepool *fp,
                ne->skb = skb;
                ne->fp = fp;
 
-               qe = (struct FS_BPENTRY *) (read_fs (dev, FP_EA(fp->offset)));
-               fs_dprintk (FS_DEBUG_QUEUE, "link at %p\n", qe);
-               if (qe) {
-                       qe = bus_to_virt ((long) qe);
+               /*
+                * FIXME: following code encodes and decodes
+                * machine pointers (could be 64-bit) into a
+                * 32-bit register.
+                */
+
+               qe_tmp = read_fs (dev, FP_EA(fp->offset));
+               fs_dprintk (FS_DEBUG_QUEUE, "link at %x\n", qe_tmp);
+               if (qe_tmp) {
+                       qe = bus_to_virt ((long) qe_tmp);
                        qe->next = virt_to_bus(ne);
                        qe->flags &= ~FP_FLAGS_EPI;
                } else
@@ -1546,7 +1557,7 @@ static void __devexit free_freepool (struct fs_dev *dev, struct freepool *fp)
 
 
 
-static irqreturn_t fs_irq (int irq, void *dev_id,  struct pt_regs * pt_regs
+static irqreturn_t fs_irq (int irq, void *dev_id) 
 {
        int i;
        u32 status;
@@ -1784,7 +1795,7 @@ static int __devinit fs_init (struct fs_dev *dev)
                write_fs (dev, RAM, (1 << (28 - FS155_VPI_BITS - FS155_VCI_BITS)) - 1);
                dev->nchannels = FS155_NR_CHANNELS;
        }
-       dev->atm_vccs = kmalloc (dev->nchannels * sizeof (struct atm_vcc *), 
+       dev->atm_vccs = kcalloc (dev->nchannels, sizeof (struct atm_vcc *),
                                 GFP_KERNEL);
        fs_dprintk (FS_DEBUG_ALLOC, "Alloc atmvccs: %p(%Zd)\n",
                    dev->atm_vccs, dev->nchannels * sizeof (struct atm_vcc *));
@@ -1794,9 +1805,8 @@ static int __devinit fs_init (struct fs_dev *dev)
                /* XXX Clean up..... */
                return 1;
        }
-       memset (dev->atm_vccs, 0, dev->nchannels * sizeof (struct atm_vcc *));
 
-       dev->tx_inuse = kmalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
+       dev->tx_inuse = kzalloc (dev->nchannels / 8 /* bits/byte */ , GFP_KERNEL);
        fs_dprintk (FS_DEBUG_ALLOC, "Alloc tx_inuse: %p(%d)\n", 
                    dev->atm_vccs, dev->nchannels / 8);
 
@@ -1805,8 +1815,6 @@ static int __devinit fs_init (struct fs_dev *dev)
                /* XXX Clean up..... */
                return 1;
        }
-       memset (dev->tx_inuse, 0, dev->nchannels / 8);
-
        /* -- RAS1 : FS155 and 50 differ. Default (0) should be OK for both */
        /* -- RAS2 : FS50 only: Default is OK. */
 
@@ -1893,14 +1901,11 @@ static int __devinit firestream_init_one (struct pci_dev *pci_dev,
        if (pci_enable_device(pci_dev)) 
                goto err_out;
 
-       fs_dev = kmalloc (sizeof (struct fs_dev), GFP_KERNEL);
+       fs_dev = kzalloc (sizeof (struct fs_dev), GFP_KERNEL);
        fs_dprintk (FS_DEBUG_ALLOC, "Alloc fs-dev: %p(%Zd)\n",
                    fs_dev, sizeof (struct fs_dev));
        if (!fs_dev)
                goto err_out;
-
-       memset (fs_dev, 0, sizeof (struct fs_dev));
-  
        atm_dev = atm_dev_register("fs", &ops, -1, NULL);
        if (!atm_dev)
                goto err_out_free_fs_dev;