patch-2.4.3 linux/drivers/net/tokenring/olympic.c

Next file: linux/drivers/net/tokenring/olympic.h
Previous file: linux/drivers/net/tokenring/lanstreamer.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.2/linux/drivers/net/tokenring/olympic.c linux/drivers/net/tokenring/olympic.c
@@ -1,6 +1,6 @@
 /*
  *   olympic.c (c) 1999 Peter De Schrijver All Rights Reserved
- *		   1999 Mike Phillips (phillim@amtrak.com)
+ *		   1999 Mike Phillips (mikep@linuxtr.net)
  *
  *  Linux driver for IBM PCI tokenring cards based on the Pit/Pit-Phy/Olympic
  *  chipset. 
@@ -38,10 +38,11 @@
  *            Fixing the hardware descriptors was another matter,
  *            because they weren't going through read[wl](), there all
  *            the results had to be in memory in le32 values. kdaaker
- *
+ * 12/23/00 - Added minimal Cardbus support (Thanks Donald).
  *
  *  To Do:
- *
+ *           Complete full Cardbus / hot-swap support.
+ * 
  *  If Problems do Occur
  *  Most problems can be rectified by either closing and opening the interface
  *  (ifconfig down and up) or rmmod and insmod'ing the driver (a bit difficult
@@ -99,7 +100,7 @@
  */
 
 static char *version = 
-"Olympic.c v0.5.0 3/10/00 - Peter De Schrijver & Mike Phillips" ; 
+"Olympic.c v0.5.C 12/23/00 - Peter De Schrijver & Mike Phillips" ; 
 
 static struct pci_device_id olympic_pci_tbl[] __initdata = {
 	{ PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_TR_WAKE, PCI_ANY_ID, PCI_ANY_ID, },
@@ -191,11 +192,9 @@
 			if (pci_enable_device(pci_device))
 				continue;
 
-			/* These lines are needed by the PowerPC, it appears
-that these flags
-			 * are not being set properly for the PPC, this may
-well be fixed with
-			 * the new PCI code */			
+			/* These lines are needed by the PowerPC, it appears that these flags
+			 * are not being set properly for the PPC, this may well be fixed with
+			 * the new PCI code */ 
 			pci_read_config_word(pci_device, PCI_COMMAND, &pci_command);
 			pci_command |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
 			pci_write_config_word(pci_device, PCI_COMMAND,pci_command);
@@ -216,7 +215,11 @@
 			init_waitqueue_head(&olympic_priv->srb_wait);
 			init_waitqueue_head(&olympic_priv->trb_wait);
 #ifndef MODULE
-			dev=init_trdev(dev, 0);
+			dev = init_trdev(NULL, 0);
+			if (!dev) {
+				kfree(olympic_priv);
+				return 0;
+			}
 #endif
 			dev->priv=(void *)olympic_priv;
 #if OLYMPIC_DEBUG  
@@ -224,8 +227,9 @@
 #endif
 			dev->irq=pci_device->irq;
 			dev->base_addr=pci_resource_start(pci_device, 0);
-			dev->init=&olympic_init;
+			dev->init=&olympic_init;	/* AKPM: Not needed */
 			olympic_priv->olympic_card_name = (char *)pci_device->resource[0].name ; 
+			/* FIXME: check ioremap return val, handle cleanup */
 			olympic_priv->olympic_mmio = 
 				ioremap(pci_resource_start(pci_device,1),256);
 			olympic_priv->olympic_lap = 
@@ -240,8 +244,11 @@
 			olympic_priv->olympic_message_level = message_level[card_no] ; 
 	
 			if(olympic_init(dev)==-1) {
-				unregister_netdevice(dev);
 				kfree(dev->priv);
+#ifndef MODULE
+				unregister_netdev(dev);
+				kfree(dev);
+#endif
 				return 0;
 			}				
 
@@ -288,6 +295,10 @@
 
 	spin_lock_init(&olympic_priv->olympic_lock) ; 
 
+	/* Needed for cardbus */
+	if(!(readl(olympic_mmio+BCTL) & BCTL_MODE_INDICATOR))
+		writel(readl(olympic_priv->olympic_mmio+FERMASK)|FERMASK_INT_BIT, olympic_mmio+FERMASK);
+
 #if OLYMPIC_DEBUG
 	printk("BCTL: %x\n",readl(olympic_mmio+BCTL));
 	printk("GPR: %x\n",readw(olympic_mmio+GPR));
@@ -1259,6 +1270,11 @@
 }
 #endif 
 		mac_frame = dev_alloc_skb(frame_len) ; 
+		if (!mac_frame) {
+			printk(KERN_WARNING "%s: Memory squeeze, dropping "
+			       "frame.\n", dev->name);
+			goto drop_frame;
+		}
 
 		/* Walk the buffer chain, creating the frame */
 
@@ -1281,6 +1297,7 @@
 		netif_rx(mac_frame) ; 	
 		dev->last_rx = jiffies ;
 
+drop_frame:
 		/* Now tell the card we have dealt with the received frame */
 
 		/* Set LISR Bit 1 */
@@ -1633,8 +1650,11 @@
         for (i = 0; (i<OLYMPIC_MAX_ADAPTERS); i++) {
 		dev_olympic[i] = NULL;
                 dev_olympic[i] = init_trdev(dev_olympic[i], 0);
-                if (dev_olympic[i] == NULL)
-                        return -ENOMEM;
+                if (dev_olympic[i] == NULL) {
+			if (i == 0)
+                        	return -ENOMEM;
+			break;
+		}
 
 		dev_olympic[i]->init      = &olympic_probe;
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)