OSDN Git Service

[NET]: Replace CHECKSUM_HW by CHECKSUM_PARTIAL/CHECKSUM_COMPLETE
[linux-kernel-docs/linux-2.6.git] / drivers / net / sk98lin / skge.c
index 9f89c23..eb3b351 100644 (file)
@@ -292,17 +292,12 @@ static __devinit int SkGeInitPCI(SK_AC *pAC)
        struct pci_dev *pdev = pAC->PciDev;
        int retval;
 
-       if (pci_enable_device(pdev) != 0) {
-               return 1;
-       }
-
        dev->mem_start = pci_resource_start (pdev, 0);
        pci_set_master(pdev);
 
-       if (pci_request_regions(pdev, "sk98lin") != 0) {
-               retval = 2;
-               goto out_disable;
-       }
+       retval = pci_request_regions(pdev, "sk98lin");
+       if (retval)
+               goto out;
 
 #ifdef SK_BIG_ENDIAN
        /*
@@ -321,9 +316,8 @@ static __devinit int SkGeInitPCI(SK_AC *pAC)
         * Remap the regs into kernel space.
         */
        pAC->IoBase = ioremap_nocache(dev->mem_start, 0x4000);
-
-       if (!pAC->IoBase){
-               retval = 3;
+       if (!pAC->IoBase) {
+               retval = -EIO;
                goto out_release;
        }
 
@@ -331,8 +325,7 @@ static __devinit int SkGeInitPCI(SK_AC *pAC)
 
  out_release:
        pci_release_regions(pdev);
- out_disable:
-       pci_disable_device(pdev);
+ out:
        return retval;
 }
 
@@ -530,7 +523,7 @@ SK_BOOL     DualNet;
        if (SkGeInit(pAC, pAC->IoBase, SK_INIT_DATA) != 0) {
                printk("HWInit (0) failed.\n");
                spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
-               return(-EAGAIN);
+               return -EIO;
        }
        SkI2cInit(  pAC, pAC->IoBase, SK_INIT_DATA);
        SkEventInit(pAC, pAC->IoBase, SK_INIT_DATA);
@@ -552,7 +545,7 @@ SK_BOOL     DualNet;
        if (SkGeInit(pAC, pAC->IoBase, SK_INIT_IO) != 0) {
                printk("sk98lin: HWInit (1) failed.\n");
                spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
-               return(-EAGAIN);
+               return -EIO;
        }
        SkI2cInit(  pAC, pAC->IoBase, SK_INIT_IO);
        SkEventInit(pAC, pAC->IoBase, SK_INIT_IO);
@@ -577,27 +570,27 @@ SK_BOOL   DualNet;
        spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
 
        if (pAC->GIni.GIMacsFound == 2) {
-                Ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, "sk98lin", dev);
+                Ret = request_irq(dev->irq, SkGeIsr, IRQF_SHARED, "sk98lin", dev);
        } else if (pAC->GIni.GIMacsFound == 1) {
-               Ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ,
+               Ret = request_irq(dev->irq, SkGeIsrOnePort, IRQF_SHARED,
                        "sk98lin", dev);
        } else {
                printk(KERN_WARNING "sk98lin: Illegal number of ports: %d\n",
                       pAC->GIni.GIMacsFound);
-               return -EAGAIN;
+               return -EIO;
        }
 
        if (Ret) {
                printk(KERN_WARNING "sk98lin: Requested IRQ %d is busy.\n",
                       dev->irq);
-               return -EAGAIN;
+               return Ret;
        }
        pAC->AllocFlag |= SK_ALLOC_IRQ;
 
        /* Alloc memory for this board (Mem for RxD/TxD) : */
        if(!BoardAllocMem(pAC)) {
                printk("No memory for descriptor rings.\n");
-                       return(-EAGAIN);
+               return -ENOMEM;
        }
 
        BoardInitMem(pAC);
@@ -613,7 +606,7 @@ SK_BOOL     DualNet;
                DualNet)) {
                BoardFreeMem(pAC);
                printk("sk98lin: SkGeInitAssignRamToQueues failed.\n");
-               return(-EAGAIN);
+               return -EIO;
        }
 
        return (0);
@@ -1532,7 +1525,7 @@ struct sk_buff    *pMessage)      /* pointer to send-message              */
        ** This is to resolve faulty padding by the HW with 0xaa bytes.
        */
        if (BytesSend < C_LEN_ETHERNET_MINSIZE) {
-               if ((pMessage = skb_padto(pMessage, C_LEN_ETHERNET_MINSIZE)) == NULL) {
+               if (skb_padto(pMessage, C_LEN_ETHERNET_MINSIZE)) {
                        spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags);
                        return 0;
                }
@@ -1566,7 +1559,7 @@ struct sk_buff    *pMessage)      /* pointer to send-message              */
        pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32);
        pTxd->pMBuf     = pMessage;
 
-       if (pMessage->ip_summed == CHECKSUM_HW) {
+       if (pMessage->ip_summed == CHECKSUM_PARTIAL) {
                u16 hdrlen = pMessage->h.raw - pMessage->data;
                u16 offset = hdrlen + pMessage->csum;
 
@@ -1685,7 +1678,7 @@ struct sk_buff    *pMessage)      /* pointer to send-message              */
        /* 
        ** Does the HW need to evaluate checksum for TCP or UDP packets? 
        */
-       if (pMessage->ip_summed == CHECKSUM_HW) {
+       if (pMessage->ip_summed == CHECKSUM_PARTIAL) {
                u16 hdrlen = pMessage->h.raw - pMessage->data;
                u16 offset = hdrlen + pMessage->csum;
 
@@ -1734,7 +1727,7 @@ struct sk_buff    *pMessage)      /* pointer to send-message              */
                pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32);
                pTxd->pMBuf     = pMessage;
                
-               pTxd->TBControl = Control | BMU_OWN | sk_frag->size;;
+               pTxd->TBControl = Control | BMU_OWN | sk_frag->size;
 
                /* 
                ** Do we have the last fragment? 
@@ -2165,7 +2158,7 @@ rx_start:
 
 #ifdef USE_SK_RX_CHECKSUM
                pMsg->csum = pRxd->TcpSums & 0xffff;
-               pMsg->ip_summed = CHECKSUM_HW;
+               pMsg->ip_summed = CHECKSUM_COMPLETE;
 #else
                pMsg->ip_summed = CHECKSUM_NONE;
 #endif
@@ -2858,7 +2851,7 @@ unsigned long     Flags;                  /* for spin lock */
  * Description:
  *     This function is called if an ioctl is issued on the device.
  *     There are three subfunction for reading, writing and test-writing
- *     the private MIB data structure (usefull for SysKonnect-internal tools).
+ *     the private MIB data structure (useful for SysKonnect-internal tools).
  *
  * Returns:
  *     0, if everything is ok
@@ -4800,8 +4793,10 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
                }
        }
 
-       if ((dev = alloc_etherdev(sizeof(DEV_NET))) == NULL) {
-               printk(KERN_ERR "Unable to allocate etherdev "
+       error = -ENOMEM;
+       dev = alloc_etherdev(sizeof(DEV_NET));
+       if (!dev) {
+               printk(KERN_ERR "sk98lin: unable to allocate etherdev "
                       "structure!\n");
                goto out_disable_device;
        }
@@ -4809,7 +4804,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
        pNet = netdev_priv(dev);
        pNet->pAC = kzalloc(sizeof(SK_AC), GFP_KERNEL);
        if (!pNet->pAC) {
-               printk(KERN_ERR "Unable to allocate adapter "
+               printk(KERN_ERR "sk98lin: unable to allocate adapter "
                       "structure!\n");
                goto out_free_netdev;
        }
@@ -4822,6 +4817,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
        pAC->CheckQueue = SK_FALSE;
 
        dev->irq = pdev->irq;
+
        error = SkGeInitPCI(pAC);
        if (error) {
                printk(KERN_ERR "sk98lin: PCI setup failed: %i\n", error);
@@ -4861,17 +4857,20 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
 
        pAC->Index = boards_found++;
 
-       if (SkGeBoardInit(dev, pAC))
+       error = SkGeBoardInit(dev, pAC);
+       if (error)
                goto out_free_netdev;
 
        /* Read Adapter name from VPD */
        if (ProductStr(pAC, DeviceStr, sizeof(DeviceStr)) != 0) {
+               error = -EIO;
                printk(KERN_ERR "sk98lin: Could not read VPD data.\n");
                goto out_free_resources;
        }
 
        /* Register net device */
-       if (register_netdev(dev)) {
+       error = register_netdev(dev);
+       if (error) {
                printk(KERN_ERR "sk98lin: Could not register device.\n");
                goto out_free_resources;
        }
@@ -5074,9 +5073,9 @@ static int skge_resume(struct pci_dev *pdev)
        pci_enable_device(pdev);
        pci_set_master(pdev);
        if (pAC->GIni.GIMacsFound == 2)
-               ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, "sk98lin", dev);
+               ret = request_irq(dev->irq, SkGeIsr, IRQF_SHARED, "sk98lin", dev);
        else
-               ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, "sk98lin", dev);
+               ret = request_irq(dev->irq, SkGeIsrOnePort, IRQF_SHARED, "sk98lin", dev);
        if (ret) {
                printk(KERN_WARNING "sk98lin: unable to acquire IRQ %d\n", dev->irq);
                pAC->AllocFlag &= ~SK_ALLOC_IRQ;