upgrade to fedora-2.6.12-1.1398.FC4 + vserver 2.0.rc7
[linux-2.6.git] / drivers / atm / he.c
index ccd54a8..df2c83f 100644 (file)
@@ -70,6 +70,7 @@
 #include <linux/sched.h>
 #include <linux/timer.h>
 #include <linux/interrupt.h>
+#include <linux/dma-mapping.h>
 #include <asm/io.h>
 #include <asm/byteorder.h>
 #include <asm/uaccess.h>
 #undef USE_RBPL_POOL                   /* if memory is tight try this */
 #define USE_TPD_POOL
 /* #undef CONFIG_ATM_HE_USE_SUNI */
-
-/* compatibility */
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,69)
-typedef void irqreturn_t;
-#define IRQ_NONE
-#define IRQ_HANDLED
-#define IRQ_RETVAL(x)
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,9)
-#define __devexit_p(func)              func
-#endif
-
-#ifndef MODULE_LICENSE
-#define MODULE_LICENSE(x)
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3)
-#define pci_set_drvdata(pci_dev, data) (pci_dev)->driver_data = (data)
-#define pci_get_drvdata(pci_dev)       (pci_dev)->driver_data
-#endif
+/* #undef HE_DEBUG */
 
 #include "he.h"
-
 #include "suni.h"
-
 #include <linux/atm_he.h>
 
 #define hprintk(fmt,args...)   printk(KERN_ERR DEV_LABEL "%d: " fmt, he_dev->number , ##args)
 
-#undef DEBUG
-#ifdef DEBUG
+#ifdef HE_DEBUG
 #define HPRINTK(fmt,args...)   printk(KERN_DEBUG DEV_LABEL "%d: " fmt, he_dev->number , ##args)
-#else
+#else /* !HE_DEBUG */
 #define HPRINTK(fmt,args...)   do { } while (0)
-#endif /* DEBUG */
-
+#endif /* HE_DEBUG */
 
 /* version definition */
 
@@ -147,14 +123,56 @@ static u8 read_prom_byte(struct he_dev *he_dev, int addr);
 
 /* globals */
 
-struct he_dev *he_devs = NULL;
-static int disable64 = 0;
+static struct he_dev *he_devs;
+static int disable64;
 static short nvpibits = -1;
 static short nvcibits = -1;
 static short rx_skb_reserve = 16;
 static int irq_coalesce = 1;
 static int sdh = 0;
 
+/* Read from EEPROM = 0000 0011b */
+static unsigned int readtab[] = {
+       CS_HIGH | CLK_HIGH,
+       CS_LOW | CLK_LOW,
+       CLK_HIGH,               /* 0 */
+       CLK_LOW,
+       CLK_HIGH,               /* 0 */
+       CLK_LOW,
+       CLK_HIGH,               /* 0 */
+       CLK_LOW,
+       CLK_HIGH,               /* 0 */
+       CLK_LOW,
+       CLK_HIGH,               /* 0 */
+       CLK_LOW,
+       CLK_HIGH,               /* 0 */
+       CLK_LOW | SI_HIGH,
+       CLK_HIGH | SI_HIGH,     /* 1 */
+       CLK_LOW | SI_HIGH,
+       CLK_HIGH | SI_HIGH      /* 1 */
+};     
+/* Clock to read from/write to the EEPROM */
+static unsigned int clocktab[] = {
+       CLK_LOW,
+       CLK_HIGH,
+       CLK_LOW,
+       CLK_HIGH,
+       CLK_LOW,
+       CLK_HIGH,
+       CLK_LOW,
+       CLK_HIGH,
+       CLK_LOW,
+       CLK_HIGH,
+       CLK_LOW,
+       CLK_HIGH,
+       CLK_LOW,
+       CLK_HIGH,
+       CLK_LOW,
+       CLK_HIGH,
+       CLK_LOW
+};     
+
 static struct atmdev_ops he_ops =
 {
        .open =         he_open,
@@ -354,7 +372,7 @@ he_init_one(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
 
        if (pci_enable_device(pci_dev))
                return -EIO;
-       if (pci_set_dma_mask(pci_dev, HE_DMA_MASK) != 0) {
+       if (pci_set_dma_mask(pci_dev, DMA_32BIT_MASK) != 0) {
                printk(KERN_WARNING "he: no suitable dma available\n");
                err = -EIO;
                goto init_one_failure;
@@ -394,8 +412,7 @@ he_init_one(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
 init_one_failure:
        if (atm_dev)
                atm_dev_deregister(atm_dev);
-       if (he_dev)
-               kfree(he_dev);
+       kfree(he_dev);
        pci_disable_device(pci_dev);
        return err;
 }
@@ -2516,8 +2533,7 @@ he_open(struct atm_vcc *vcc)
 open_failed:
 
        if (err) {
-               if (he_vcc)
-                       kfree(he_vcc);
+               kfree(he_vcc);
                clear_bit(ATM_VF_ADDR, &vcc->flags);
        }
        else
@@ -2558,8 +2574,8 @@ he_close(struct atm_vcc *vcc)
                        udelay(250);
                }
 
-               add_wait_queue(&he_vcc->rx_waitq, &wait);
                set_current_state(TASK_UNINTERRUPTIBLE);
+               add_wait_queue(&he_vcc->rx_waitq, &wait);
 
                he_writel_rsr0(he_dev, RSR0_CLOSE_CONN, cid);
                (void) he_readl_rsr0(he_dev, cid);              /* flush posted writes */
@@ -2593,7 +2609,7 @@ he_close(struct atm_vcc *vcc)
                 * TBRQ, the host issues the close command to the adapter.
                 */
 
-               while (((tx_inuse = atomic_read(&vcc->sk->sk_wmem_alloc)) > 0) &&
+               while (((tx_inuse = atomic_read(&sk_atm(vcc)->sk_wmem_alloc)) > 0) &&
                       (retry < MAX_RETRY)) {
                        msleep(sleep);
                        if (sleep < 250)
@@ -2633,8 +2649,8 @@ he_close(struct atm_vcc *vcc)
                tpd->vcc = vcc;
                wmb();
 
-               add_wait_queue(&he_vcc->tx_waitq, &wait);
                set_current_state(TASK_UNINTERRUPTIBLE);
+               add_wait_queue(&he_vcc->tx_waitq, &wait);
                __enqueue_tpd(he_dev, tpd, cid);
                spin_unlock_irqrestore(&he_dev->global_lock, flags);
 
@@ -3062,7 +3078,7 @@ static struct pci_driver he_driver = {
 
 static int __init he_init(void)
 {
-       return pci_module_init(&he_driver);
+       return pci_register_driver(&he_driver);
 }
 
 static void __exit he_cleanup(void)