aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sk98lin
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@osdl.org>2006-01-06 19:57:41 -0500
committerJeff Garzik <jgarzik@pobox.com>2006-01-09 10:32:40 -0500
commitdecf67aa2f4d498c02c2ad24a187a66c217f330c (patch)
tree96ead26cfcaa2915d4c1300fb533a0b62172f7f7 /drivers/net/sk98lin
parentbce7c95e4dd4d5e924deb2929b639b4caca09c93 (diff)
[PATCH] sk98lin: error handling on dual port board
Sk98lin driver error recovery on two port boards is bad. If it fails the second allocation, it will not release resources properly. Also it registers the second port in the pci driver data If second port fails, might as well go with one port. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/net/sk98lin')
-rw-r--r--drivers/net/sk98lin/skge.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index 9a879530ef6d..87bfe4c24a77 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -4899,15 +4899,17 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4899 4899
4900 boards_found++; 4900 boards_found++;
4901 4901
4902 pci_set_drvdata(pdev, dev);
4903
4902 /* More then one port found */ 4904 /* More then one port found */
4903 if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) { 4905 if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
4904 if ((dev = alloc_etherdev(sizeof(DEV_NET))) == 0) { 4906 dev = alloc_etherdev(sizeof(DEV_NET));
4905 printk(KERN_ERR "Unable to allocate etherdev " 4907 if (!dev) {
4908 printk(KERN_ERR "sk98lin: unable to allocate etherdev "
4906 "structure!\n"); 4909 "structure!\n");
4907 goto out; 4910 goto single_port;
4908 } 4911 }
4909 4912
4910 pAC->dev[1] = dev;
4911 pNet = netdev_priv(dev); 4913 pNet = netdev_priv(dev);
4912 pNet->PortNr = 1; 4914 pNet->PortNr = 1;
4913 pNet->NetNr = 1; 4915 pNet->NetNr = 1;
@@ -4939,20 +4941,25 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4939 if (using_dac) 4941 if (using_dac)
4940 dev->features |= NETIF_F_HIGHDMA; 4942 dev->features |= NETIF_F_HIGHDMA;
4941 4943
4942 if (register_netdev(dev)) { 4944 error = register_netdev(dev);
4943 printk(KERN_ERR "sk98lin: Could not register device for seconf port.\n"); 4945 if (error) {
4946 printk(KERN_ERR "sk98lin: Could not register device"
4947 " for second port. (%d)\n", error);
4944 free_netdev(dev); 4948 free_netdev(dev);
4945 pAC->dev[1] = pAC->dev[0]; 4949 goto single_port;
4946 } else {
4947 memcpy(&dev->dev_addr,
4948 &pAC->Addr.Net[1].CurrentMacAddress, 6);
4949 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
4950
4951 printk("%s: %s\n", dev->name, DeviceStr);
4952 printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
4953 } 4950 }
4951
4952 pAC->dev[1] = dev;
4953 memcpy(&dev->dev_addr,
4954 &pAC->Addr.Net[1].CurrentMacAddress, 6);
4955 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
4956
4957 printk("%s: %s\n", dev->name, DeviceStr);
4958 printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
4954 } 4959 }
4955 4960
4961single_port:
4962
4956 /* Save the hardware revision */ 4963 /* Save the hardware revision */
4957 pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) + 4964 pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) +
4958 (pAC->GIni.GIPciHwRev & 0x0F); 4965 (pAC->GIni.GIPciHwRev & 0x0F);
@@ -4964,7 +4971,6 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4964 memset(&pAC->PnmiBackup, 0, sizeof(SK_PNMI_STRUCT_DATA)); 4971 memset(&pAC->PnmiBackup, 0, sizeof(SK_PNMI_STRUCT_DATA));
4965 memcpy(&pAC->PnmiBackup, &pAC->PnmiStruct, sizeof(SK_PNMI_STRUCT_DATA)); 4972 memcpy(&pAC->PnmiBackup, &pAC->PnmiStruct, sizeof(SK_PNMI_STRUCT_DATA));
4966 4973
4967 pci_set_drvdata(pdev, dev);
4968 return 0; 4974 return 0;
4969 4975
4970 out_free_resources: 4976 out_free_resources: