Merge branch 'upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/linville...
[linux-2.6.git] / drivers / net / sk98lin / skge.c
index 9a87953..49e76c7 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;
                }
@@ -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? 
@@ -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,21 +4793,22 @@ 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;
        }
 
        pNet = netdev_priv(dev);
-       pNet->pAC = kmalloc(sizeof(SK_AC), GFP_KERNEL);
+       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;
        }
 
-       memset(pNet->pAC, 0, sizeof(SK_AC));
        pAC = pNet->pAC;
        pAC->PciDev = pdev;
 
@@ -4823,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);
@@ -4862,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;
        }
@@ -4899,15 +4897,17 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
 
        boards_found++;
 
+       pci_set_drvdata(pdev, dev);
+
        /* More then one port found */
        if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
-               if ((dev = alloc_etherdev(sizeof(DEV_NET))) == 0) {
-                       printk(KERN_ERR "Unable to allocate etherdev "
+               dev = alloc_etherdev(sizeof(DEV_NET));
+               if (!dev) {
+                       printk(KERN_ERR "sk98lin: unable to allocate etherdev "
                                "structure!\n");
-                       goto out;
+                       goto single_port;
                }
 
-               pAC->dev[1]   = dev;
                pNet          = netdev_priv(dev);
                pNet->PortNr  = 1;
                pNet->NetNr   = 1;
@@ -4939,20 +4939,25 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
                if (using_dac)
                        dev->features |= NETIF_F_HIGHDMA;
 
-               if (register_netdev(dev)) {
-                       printk(KERN_ERR "sk98lin: Could not register device for seconf port.\n");
+               error = register_netdev(dev);
+               if (error) {
+                       printk(KERN_ERR "sk98lin: Could not register device"
+                              " for second port. (%d)\n", error);
                        free_netdev(dev);
-                       pAC->dev[1] = pAC->dev[0];
-               } else {
-                       memcpy(&dev->dev_addr,
-                                       &pAC->Addr.Net[1].CurrentMacAddress, 6);
-                       memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
-       
-                       printk("%s: %s\n", dev->name, DeviceStr);
-                       printk("      PrefPort:B  RlmtMode:Dual Check Link State\n");
+                       goto single_port;
                }
+
+               pAC->dev[1]   = dev;
+               memcpy(&dev->dev_addr,
+                      &pAC->Addr.Net[1].CurrentMacAddress, 6);
+               memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
+
+               printk("%s: %s\n", dev->name, DeviceStr);
+               printk("      PrefPort:B  RlmtMode:Dual Check Link State\n");
        }
 
+single_port:
+
        /* Save the hardware revision */
        pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) +
                (pAC->GIni.GIPciHwRev & 0x0F);
@@ -4964,7 +4969,6 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
        memset(&pAC->PnmiBackup, 0, sizeof(SK_PNMI_STRUCT_DATA));
        memcpy(&pAC->PnmiBackup, &pAC->PnmiStruct, sizeof(SK_PNMI_STRUCT_DATA));
 
-       pci_set_drvdata(pdev, dev);
        return 0;
 
  out_free_resources:
@@ -5069,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;
@@ -5129,7 +5133,7 @@ static struct pci_driver skge_driver = {
 
 static int __init skge_init(void)
 {
-       return pci_module_init(&skge_driver);
+       return pci_register_driver(&skge_driver);
 }
 
 static void __exit skge_exit(void)