patch-2.3.43 linux/drivers/net/myri_sbus.c

Next file: linux/drivers/net/ncr885e.c
Previous file: linux/drivers/net/mace.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.42/linux/drivers/net/myri_sbus.c linux/drivers/net/myri_sbus.c
@@ -551,7 +551,6 @@
 
 		DIRQ(("IRQ_DISAB "));
 		myri_disable_irq(lregs, mp->cregs);
-		dev->interrupt = 1;
 		softstate = sbus_readl(&chan->state);
 		DIRQ(("state[%08x] ", softstate));
 		if (softstate != STATE_READY) {
@@ -562,7 +561,6 @@
 		myri_rx(mp, dev);
 		DIRQ(("\nistat=ISTAT_HOST "));
 		sbus_writel(ISTAT_HOST, lregs + LANAI_ISTAT);
-		dev->interrupt = 0;
 		DIRQ(("IRQ_ENAB "));
 		myri_enable_irq(lregs, mp->cregs);
 	}
@@ -584,6 +582,17 @@
 	return 0;
 }
 
+static void myri_tx_timeout(struct net_device *dev)
+{
+	struct myri_eth *mp = (struct myri_eth *) dev->priv;
+
+	printk(KERN_ERR "%s: transmit timed out, resetting\n", dev->name);
+
+	mp->enet_stats.tx_errors++;
+	myri_init(mp, 0);
+	netif_start_queue(dev);
+}
+
 static int myri_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
 	struct myri_eth *mp = (struct myri_eth *) dev->priv;
@@ -598,29 +607,7 @@
 
 	myri_tx(mp, dev);
 
-	if (dev->tbusy) {
-		int tickssofar = jiffies - dev->trans_start;
-
-		DTX(("tbusy tickssofar[%d] ", tickssofar));
-		if (tickssofar < 40) {
-			DTX(("returning 1\n"));
-			return 1;
-		} else {
-			DTX(("resetting, return 0\n"));
-			printk(KERN_ERR "%s: transmit timed out, resetting\n", dev->name);
-			mp->enet_stats.tx_errors++;
-			myri_init(mp, in_interrupt());
-			dev->tbusy = 0;
-			dev->trans_start = jiffies;
-			return 0;
-		}
-	}
-
-	if (test_and_set_bit(0, (void *) &dev->tbusy) != 0) {
-		DTX(("tbusy, maybe a race? returning 1\n"));
-		printk("%s: Transmitter access conflict.\n", dev->name);
-		return 1;
-	}
+	netif_stop_queue(dev);
 
 	/* This is just to prevent multiple PIO reads for TX_BUFFS_AVAIL. */
 	head = sbus_readl(&sq->head);
@@ -677,7 +664,7 @@
 	bang_the_chip(mp);
 
 	DTX(("tbusy=0, returning 0\n"));
-	dev->tbusy = 0;
+	netif_start_queue(dev);
 	restore_flags(flags);
 	return 0;
 }
@@ -1059,6 +1046,8 @@
 	dev->open = &myri_open;
 	dev->stop = &myri_close;
 	dev->hard_start_xmit = &myri_start_xmit;
+	dev->tx_timeout = &myri_tx_timeout;
+	dev->watchdog_timeo = 5*HZ;
 	dev->get_stats = &myri_get_stats;
 	dev->set_multicast_list = &myri_set_multicast;
 	dev->irq = sdev->irqs[0];
@@ -1105,7 +1094,7 @@
 	return 0;
 }
 
-int __init myri_sbus_probe(void)
+static int __init myri_sbus_probe(void)
 {
 	struct net_device *dev = NULL;
 	struct sbus_bus *bus;
@@ -1113,6 +1102,10 @@
 	static int called = 0;
 	int cards = 0, v;
 
+#ifdef MODULE
+	root_myri_dev = NULL;
+#endif
+
 	if (called)
 		return ENODEV;
 	called++;
@@ -1134,18 +1127,9 @@
 	return 0;
 }
 
-#ifdef MODULE
-
-int
-init_module(void)
-{
-	root_myri_dev = NULL;
-	return myri_sbus_probe();
-}
-
-void
-cleanup_module(void)
+static void __exit myri_sbus_cleanup(void)
 {
+#ifdef MODULE
 	/* No need to check MOD_IN_USE, as sys_delete_module() checks. */
 	while (root_myri_dev) {
 		struct myri_eth *next = root_myri_dev->next_module;
@@ -1154,6 +1138,8 @@
 		kfree(root_myri_dev->dev);
 		root_myri_dev = next;
 	}
+#endif /* MODULE */
 }
 
-#endif /* MODULE */
+module_init(myri_sbus_probe);
+module_exit(myri_sbus_cleanup);

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