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

Next file: linux/drivers/net/skeleton.c
Previous file: linux/drivers/net/sk98lin/skge.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.42/linux/drivers/net/sk_g16.c linux/drivers/net/sk_g16.c
@@ -69,6 +69,7 @@
 #include <asm/bitops.h> 
 #include <linux/errno.h>
 #include <linux/init.h>
+#include <linux/spinlock.h>
 
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
@@ -455,6 +456,8 @@
 
 static SK_RAM *board;  /* pointer to our memory mapped board components */
 
+static spinlock_t SK_lock = SPIN_LOCK_UNLOCKED;
+
 /* Macros */
 
 
@@ -939,11 +942,7 @@
 
     if (!(i = SK_lance_init(dev, 0)))  /* LANCE init OK? */
     {
-
-
-	dev->tbusy = 0;
-	dev->interrupt = 0;
-	dev->start = 1;
+	netif_start_queue(dev);
 
 #ifdef SK_DEBUG
 
@@ -979,7 +978,6 @@
 	PRINTK(("## %s: LANCE init failed: CSR0: %#06x\n", 
                SK_NAME, SK_read_reg(CSR0)));
 
-	dev->start = 0;        /* Device not ready */
 	return -EAGAIN;
     }
 
@@ -1176,7 +1174,7 @@
     struct priv *p = (struct priv *) dev->priv;
     struct tmd *tmdp;
 
-    if (dev->tbusy)
+    if (test_bit(LINK_STATE_XOFF, &dev->flags))
     {
 	/* if Transmitter more than 150ms busy -> time_out */
 
@@ -1190,7 +1188,7 @@
 
 	SK_lance_init(dev, MODE_NORMAL); /* Reinit LANCE */
 
-	dev->tbusy = 0;                  /* Clear Transmitter flag */
+	netif_start_queue(dev);		 /* Clear Transmitter flag */
 
 	dev->trans_start = jiffies;      /* Mark Start of transmission */
 
@@ -1205,12 +1203,10 @@
      * This means check if we are already in. 
      */
 
-    if (test_and_set_bit(0, (void *) &dev->tbusy) != 0) /* dev->tbusy already set ? */ 
-    {
-	printk("%s: Transmitter access conflict.\n", dev->name);
-    }
-    else
+    netif_stop_queue (dev);
+
     {
+
 	/* Evaluate Packet length */
 	short len = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN; 
        
@@ -1248,11 +1244,13 @@
 	    * We own next buffer and are ready to transmit, so
 	    * clear busy flag
 	    */
-	   dev->tbusy = 0;
+	   netif_start_queue(dev);
 	}
 
 	p->stats.tx_bytes += skb->len;
+
     }
+
     dev_kfree_skb(skb);
     return 0;  
 } /* End of SK_send_packet */
@@ -1290,16 +1288,10 @@
 	printk("SK_interrupt(): IRQ %d for unknown device.\n", irq);
     }
     
-
-    if (dev->interrupt)
-    {
-	printk("%s: Re-entering the interrupt handler.\n", dev->name);
-    }
+    spin_lock (&SK_lock);
 
     csr0 = SK_read_reg(CSR0);      /* store register for checking */
 
-    dev->interrupt = 1;            /* We are handling an interrupt */
-
     /* 
      * Acknowledge all of the current interrupt sources, disable      
      * Interrupts (INEA = 0) 
@@ -1329,7 +1321,7 @@
 
     SK_write_reg(CSR0, CSR0_INEA); /* Enable Interrupts */
 
-    dev->interrupt = 0;            /* We are out */
+    spin_unlock (&SK_lock);
 } /* End of SK_interrupt() */ 
 
 
@@ -1430,14 +1422,7 @@
      * We mark transmitter not busy anymore, because now we have a free
      * transmit descriptor which can be filled by SK_send_packet and
      * afterwards sent by the LANCE
-     */
-
-    dev->tbusy = 0; 
-
-    /* 
-     * mark_bh(NET_BH);
-     * This will cause net_bh() to run after this interrupt handler.
-     *
+     * 
      * The function which do handle slow IRQ parts is do_bottom_half()
      * which runs at normal kernel priority, that means all interrupt are
      * enabled. (see kernel/irq.c)
@@ -1450,7 +1435,7 @@
      *  - try to transmit something from the send queue
      */
 
-    mark_bh(NET_BH); 
+    netif_wake_queue(dev);
 
 } /* End of SK_txintr() */
 
@@ -1625,8 +1610,7 @@
     PRINTK(("## %s: SK_close(). CSR0: %#06x\n", 
            SK_NAME, SK_read_reg(CSR0)));
 
-    dev->tbusy = 1;                /* Transmitter busy */
-    dev->start = 0;                /* Card down */
+    netif_stop_queue(dev);	   /* Transmitter busy */
 
     printk("%s: Shutting %s down CSR0 %#06x\n", dev->name, SK_NAME, 
            (int) SK_read_reg(CSR0));
@@ -2005,9 +1989,6 @@
 	printk("## Device Name: %s Base Address: %#06lx IRQ: %d\n", 
                dev->name, dev->base_addr, dev->irq);
 	       
-	printk("##   FLAGS: start: %d tbusy: %ld int: %ld\n", 
-               dev->start, dev->tbusy, dev->interrupt);
-
 	printk("## next device: %#08x init function: %#08x\n", 
               (int) dev->next, (int) dev->init);
     }

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