fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / atm / firestream.c
index 025c692..9c67df5 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/pci.h>
+#include <linux/poison.h>
 #include <linux/errno.h>
 #include <linux/atm.h>
 #include <linux/atmdev.h>
@@ -82,14 +83,14 @@ static int num=0x5a;
  * would be interpreted. -- REW */
 
 #define NP FS_NR_FREE_POOLS
-int rx_buf_sizes[NP]  = {128,  256,  512, 1024, 2048, 4096, 16384, 65520};
+static int rx_buf_sizes[NP]  = {128,  256,  512, 1024, 2048, 4096, 16384, 65520};
 /* log2:                 7     8     9    10    11    12    14     16 */
 
 #if 0
-int rx_pool_sizes[NP] = {1024, 1024, 512, 256,  128,  64,   32,    32};
+static int rx_pool_sizes[NP] = {1024, 1024, 512, 256,  128,  64,   32,    32};
 #else
 /* debug */
-int rx_pool_sizes[NP] = {128,  128,  128, 64,   64,   64,   32,    32};
+static int rx_pool_sizes[NP] = {128,  128,  128, 64,   64,   64,   32,    32};
 #endif
 /* log2:                 10    10    9    8     7     6     5      5  */
 /* sumlog2:              17    18    18   18    18    18    19     21 */
@@ -250,7 +251,7 @@ struct reginit_item {
 };
 
 
-struct reginit_item PHY_NTC_INIT[] __devinitdata = {
+static struct reginit_item PHY_NTC_INIT[] __devinitdata = {
        { PHY_CLEARALL, 0x40 }, 
        { 0x12,  0x0001 },
        { 0x13,  0x7605 },
@@ -306,11 +307,11 @@ static int fs_debug = 0;
 
 #ifdef MODULE
 #ifdef DEBUG 
-MODULE_PARM(fs_debug, "i");
+module_param(fs_debug, int, 0644);
 #endif
-MODULE_PARM(loopback, "i");
-MODULE_PARM(num, "i");
-MODULE_PARM(fs_keystream, "i");
+module_param(loopback, int, 0);
+module_param(num, int, 0);
+module_param(fs_keystream, int, 0);
 /* XXX Add rx_buf_sizes, and rx_pool_sizes As per request Amar. -- REW */
 #endif
 
@@ -334,7 +335,7 @@ MODULE_PARM(fs_keystream, "i");
 #define func_exit()  fs_dprintk (FS_DEBUG_FLOW, "fs: exit  %s\n", __FUNCTION__)
 
 
-struct fs_dev *fs_boards = NULL;
+static struct fs_dev *fs_boards = NULL;
 
 #ifdef DEBUG
 
@@ -511,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 */
@@ -754,7 +755,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
                        fs_kfree_skb (skb);
 
                        fs_dprintk (FS_DEBUG_ALLOC, "Free trans-d: %p\n", td); 
-                       memset (td, 0x12, sizeof (struct FS_BPENTRY));
+                       memset (td, ATM_POISON_FREE, sizeof(struct FS_BPENTRY));
                        kfree (td);
                        break;
                default:
@@ -815,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
                                skb_put (skb, qe->p1 & 0xffff); 
                                ATM_SKB(skb)->vcc = atm_vcc;
                                atomic_inc(&atm_vcc->stats->rx);
-                               do_gettimeofday(&skb->stamp);
+                               __net_timestamp(skb);
                                fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
                                atm_vcc->push (atm_vcc, skb);
                                fs_dprintk (FS_DEBUG_ALLOC, "Free rec-d: %p\n", pe);
@@ -951,7 +952,7 @@ static int fs_open(struct atm_vcc *atm_vcc)
                   it most likely that the chip will notice it. It also prevents us
                   from having to wait for completion. On the other hand, we may
                   need to wait for completion anyway, to see if it completed
-                  succesfully. */
+                  successfully. */
 
                switch (atm_vcc->qos.aal) {
                case ATM_AAL2:
@@ -1000,7 +1001,11 @@ static int fs_open(struct atm_vcc *atm_vcc)
                                } else {
                                        r = ROUND_UP;
                                }
-                               error = make_rate (pcr, r, &tmc0, 0);
+                               error = make_rate (pcr, r, &tmc0, NULL);
+                               if (error) {
+                                       kfree(tc);
+                                       return error;
+                               }
                        }
                        fs_dprintk (FS_DEBUG_OPEN, "pcr = %d.\n", pcr);
                }
@@ -1374,13 +1379,13 @@ static void reset_chip (struct fs_dev *dev)
        }
 }
 
-static void __devinit *aligned_kmalloc (int size, int flags, int alignment)
+static void __devinit *aligned_kmalloc (int size, gfp_t flags, int alignment)
 {
        void  *t;
 
        if (alignment <= 0x10) {
                t = kmalloc (size, flags);
-               if ((unsigned int)t & (alignment-1)) {
+               if ((unsigned long)t & (alignment-1)) {
                        printk ("Kmalloc doesn't align things correctly! %p\n", t);
                        kfree (t);
                        return aligned_kmalloc (size, flags, alignment * 4);
@@ -1464,7 +1469,8 @@ static inline int nr_buffers_in_freepool (struct fs_dev *dev, struct freepool *f
    does. I've seen "receive abort: no buffers" and things started
    working again after that...  -- REW */
 
-static void top_off_fp (struct fs_dev *dev, struct freepool *fp, int gfp_flags)
+static void top_off_fp (struct fs_dev *dev, struct freepool *fp,
+                       gfp_t gfp_flags)
 {
        struct FS_BPENTRY *qe, *ne;
        struct sk_buff *skb;
@@ -1544,7 +1550,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;
@@ -1656,9 +1662,10 @@ static int __devinit fs_init (struct fs_dev *dev)
        func_enter ();
        pci_dev = dev->pci_dev;
 
-       printk (KERN_INFO "found a FireStream %d card, base %08lx, irq%d.\n", 
+       printk (KERN_INFO "found a FireStream %d card, base %16llx, irq%d.\n",
                IS_FS50(dev)?50:155,
-               pci_resource_start(pci_dev, 0), dev->pci_dev->irq);
+               (unsigned long long)pci_resource_start(pci_dev, 0),
+               dev->pci_dev->irq);
 
        if (fs_debug & FS_DEBUG_INIT)
                my_hd ((unsigned char *) dev, sizeof (*dev));
@@ -1667,7 +1674,7 @@ static int __devinit fs_init (struct fs_dev *dev)
 
        dev->hw_base = pci_resource_start(pci_dev, 0);
 
-       dev->base = (ulong) ioremap(dev->hw_base, 0x1000);
+       dev->base = ioremap(dev->hw_base, 0x1000);
 
        reset_chip (dev);
   
@@ -1704,8 +1711,7 @@ static int __devinit fs_init (struct fs_dev *dev)
                }
 
                /* Try again after 10ms. */
-               set_current_state(TASK_UNINTERRUPTIBLE);
-               schedule_timeout ((HZ+99)/100);
+               msleep(10);
        }
 
        if (!to) {
@@ -1782,7 +1788,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 *));
@@ -1792,9 +1798,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);
 
@@ -1803,8 +1808,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. */
 
@@ -1827,7 +1830,7 @@ static int __devinit fs_init (struct fs_dev *dev)
                init_q (dev, &dev->rx_rq[i], RXB_RQ(i), RXRQ_NENTRIES, 1);
 
        dev->irq = pci_dev->irq;
-       if (request_irq (dev->irq, fs_irq, SA_SHIRQ, "firestream", dev)) {
+       if (request_irq (dev->irq, fs_irq, IRQF_SHARED, "firestream", dev)) {
                printk (KERN_WARNING "couldn't get irq %d for firestream.\n", pci_dev->irq);
                /* XXX undo all previous stuff... */
                return 1;
@@ -1891,14 +1894,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;
@@ -1922,7 +1922,7 @@ static int __devinit firestream_init_one (struct pci_dev *pci_dev,
        return -ENODEV;
 }
 
-void __devexit firestream_remove_one (struct pci_dev *pdev)
+static void __devexit firestream_remove_one (struct pci_dev *pdev)
 {
        int i;
        struct fs_dev *dev, *nxtdev;
@@ -2013,66 +2013,6 @@ void __devexit firestream_remove_one (struct pci_dev *pdev)
        func_exit ();
 }
 
-
-#if 0
-int __init fs_detect(void)
-{
-       struct pci_dev  *pci_dev;
-       int devs = 0;
-
-       func_enter ();
-       pci_dev = NULL;
-       while ((pci_dev = pci_find_device(PCI_VENDOR_ID_FUJITSU_ME,
-                                         PCI_DEVICE_ID_FUJITSU_FS50, 
-                                         pci_dev))) {
-               if (fs_register_and_init (pci_dev, &fs_pci_tbl[0]))
-                       break;
-               devs++;
-       }
-
-       while ((pci_dev = pci_find_device(PCI_VENDOR_ID_FUJITSU_ME,
-                                         PCI_DEVICE_ID_FUJITSU_FS155, 
-                                         pci_dev))) {
-               if (fs_register_and_init (pci_dev, FS_IS155)) 
-                       break;
-               devs++;
-       }
-       func_exit ();
-       return devs;
-}
-#else
-
-#if 0
-int __init init_PCI (void)
-{ /* Begin init_PCI */
-       
-       int pci_count;
-       printk ("init_PCI\n");
-       /*
-         memset (&firestream_driver, 0, sizeof (firestream_driver));
-         firestream_driver.name = "firestream";
-         firestream_driver.id_table = firestream_pci_tbl;
-         firestream_driver.probe = fs_register_and_init;
-       */
-       pci_count = pci_register_driver (&firestream_driver);
-       
-       if (pci_count <= 0) {
-               pci_unregister_driver (&firestream_driver);
-               pci_count = 0;
-       }
-
-       return(pci_count);
-
-} /* End init_PCI */
-#endif
-#endif
-
-/*
-#ifdef MODULE
-#define firestream_init init_module
-#endif 
-*/
-
 static struct pci_device_id firestream_pci_tbl[] = {
        { PCI_VENDOR_ID_FUJITSU_ME, PCI_DEVICE_ID_FUJITSU_FS50, 
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, FS_IS50},
@@ -2095,7 +2035,7 @@ static int __init firestream_init_module (void)
        int error;
 
        func_enter ();
-       error = pci_module_init(&firestream_driver);
+       error = pci_register_driver(&firestream_driver);
        func_exit ();
        return error;
 }
@@ -2111,3 +2051,4 @@ module_exit(firestream_cleanup_module);
 MODULE_LICENSE("GPL");
 
 
+