libata-sff: separate out BMDMA qc_issue
[safe/jmp/linux-2.6] / drivers / atm / eni.c
index 5aab7bd..719ec5a 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/init.h>
 #include <linux/atm_eni.h>
 #include <linux/bitops.h>
+#include <linux/slab.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/atomic.h>
@@ -536,7 +537,7 @@ static int rx_aal0(struct atm_vcc *vcc)
                return 0;
        }
        skb_put(skb,length);
-       skb_set_timestamp(skb, &eni_vcc->timestamp);
+       skb->tstamp = eni_vcc->timestamp;
        DPRINTK("got len %ld\n",length);
        if (do_rx_dma(vcc,skb,1,length >> 2,length >> 2)) return 1;
        eni_vcc->rxing++;
@@ -701,7 +702,7 @@ static void get_service(struct atm_dev *dev)
                        DPRINTK("Grr, servicing VCC %ld twice\n",vci);
                        continue;
                }
-               do_gettimeofday(&ENI_VCC(vcc)->timestamp);
+               ENI_VCC(vcc)->timestamp = ktime_get_real();
                ENI_VCC(vcc)->next = NULL;
                if (vcc->qos.rxtp.traffic_class == ATM_CBR) {
                        if (eni_dev->fast)
@@ -912,7 +913,6 @@ static int start_rx(struct atm_dev *dev)
                free_page((unsigned long) eni_dev->free_list);
                return -ENOMEM;
        }
-       memset(eni_dev->rx_map,0,PAGE_SIZE);
        eni_dev->rx_mult = DEFAULT_RX_MULT;
        eni_dev->fast = eni_dev->last_fast = NULL;
        eni_dev->slow = eni_dev->last_slow = NULL;
@@ -1271,7 +1271,7 @@ static int comp_tx(struct eni_dev *eni_dev,int *pcr,int reserved,int *pre,
                        if (*pre < 3) (*pre)++; /* else fail later */
                        div = pre_div[*pre]*-*pcr;
                        DPRINTK("max div %d\n",div);
-                       *res = (TS_CLOCK+div-1)/div-1;
+                       *res = DIV_ROUND_UP(TS_CLOCK, div)-1;
                }
                if (*res < 0) *res = 0;
                if (*res > MID_SEG_MAX_RATE) *res = MID_SEG_MAX_RATE;
@@ -1705,7 +1705,6 @@ static int __devinit eni_do_init(struct atm_dev *dev)
        struct pci_dev *pci_dev;
        unsigned long real_base;
        void __iomem *base;
-       unsigned char revision;
        int error,i,last;
 
        DPRINTK(">eni_init\n");
@@ -1716,12 +1715,6 @@ static int __devinit eni_do_init(struct atm_dev *dev)
        pci_dev = eni_dev->pci_dev;
        real_base = pci_resource_start(pci_dev, 0);
        eni_dev->irq = pci_dev->irq;
-       error = pci_read_config_byte(pci_dev,PCI_REVISION_ID,&revision);
-       if (error) {
-               printk(KERN_ERR DEV_LABEL "(itf %d): init error 0x%02x\n",
-                   dev->number,error);
-               return -EINVAL;
-       }
        if ((error = pci_write_config_word(pci_dev,PCI_COMMAND,
            PCI_COMMAND_MEMORY |
            (eni_dev->asic ? PCI_COMMAND_PARITY | PCI_COMMAND_SERR : 0)))) {
@@ -1730,7 +1723,7 @@ static int __devinit eni_do_init(struct atm_dev *dev)
                return -EIO;
        }
        printk(KERN_NOTICE DEV_LABEL "(itf %d): rev.%d,base=0x%lx,irq=%d,",
-           dev->number,revision,real_base,eni_dev->irq);
+           dev->number,pci_dev->revision,real_base,eni_dev->irq);
        if (!(base = ioremap_nocache(real_base,MAP_MAX_SIZE))) {
                printk("\n");
                printk(KERN_ERR DEV_LABEL "(itf %d): can't set up page "
@@ -1746,7 +1739,8 @@ static int __devinit eni_do_init(struct atm_dev *dev)
                        printk(KERN_ERR KERN_ERR DEV_LABEL "(itf %d): bad "
                            "magic - expected 0x%x, got 0x%x\n",dev->number,
                            ENI155_MAGIC,(unsigned) readl(&eprom->magic));
-                       return -EINVAL;
+                       error = -EINVAL;
+                       goto unmap;
                }
        }
        eni_dev->phy = base+PHY_BASE;
@@ -1773,17 +1767,27 @@ static int __devinit eni_do_init(struct atm_dev *dev)
                printk(")\n");
                printk(KERN_ERR DEV_LABEL "(itf %d): ERROR - wrong id 0x%x\n",
                    dev->number,(unsigned) eni_in(MID_RES_ID_MCON));
-               return -EINVAL;
+               error = -EINVAL;
+               goto unmap;
        }
        error = eni_dev->asic ? get_esi_asic(dev) : get_esi_fpga(dev,base);
-       if (error) return error;
+       if (error)
+               goto unmap;
        for (i = 0; i < ESI_LEN; i++)
                printk("%s%02X",i ? "-" : "",dev->esi[i]);
        printk(")\n");
        printk(KERN_NOTICE DEV_LABEL "(itf %d): %s,%s\n",dev->number,
            eni_in(MID_RES_ID_MCON) & 0x200 ? "ASIC" : "FPGA",
            media_name[eni_in(MID_RES_ID_MCON) & DAUGTHER_ID]);
-       return suni_init(dev);
+
+       error = suni_init(dev);
+       if (error)
+               goto unmap;
+out:
+       return error;
+unmap:
+       iounmap(base);
+       goto out;
 }
 
 
@@ -2028,7 +2032,7 @@ static int eni_getsockopt(struct atm_vcc *vcc,int level,int optname,
 
 
 static int eni_setsockopt(struct atm_vcc *vcc,int level,int optname,
-    void __user *optval,int optlen)
+    void __user *optval,unsigned int optlen)
 {
        return -EINVAL;
 }