[PATCH] 3c527.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Just a compile test since I do not have the board handy. 


--- 3c527.c	2003-06-17 06:20:03.000000000 +0200
+++ 3c527.c.new	2003-06-27 22:41:14.000000000 +0200
@@ -100,6 +100,8 @@
 #include <linux/string.h>
 #include <linux/wait.h>
 #include <linux/ethtool.h>
+#include <linux/sched.h>
+#include <linux/spinlock.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -178,7 +180,8 @@
 	u16 tx_ring_tail;       /* index to tx de-queue end */
 	u16 tx_ring_head;       /* index to tx en-queue end */
 
-	u16 rx_ring_tail;       /* index to rx de-queue end */ 
+	u16 rx_ring_tail;       /* index to rx de-queue end */
+	spinlock_t lock; 
 };
 
 /* The station (ethernet) address prefix, used for a sanity check. */
@@ -497,6 +500,7 @@
 	lp->rx_len 		= lp->exec_box->data[11];  /* Receive list count */
 
 	init_waitqueue_head(&lp->event);
+	spin_lock_init(&lp->lock);
 	
 	printk("%s: Firmware Rev %d. %d RX buffers, %d TX buffers. Base of 0x%08X.\n",
 		dev->name, lp->exec_box->data[12], lp->rx_len, lp->tx_len, lp->base);
@@ -622,19 +626,17 @@
 	 *	Wait for a command
 	 */
 	 
-	save_flags(flags);
-	cli();
-	 
-	while(lp->exec_pending)
-		sleep_on(&lp->event);
-		
+	spin_lock_irqsave(&lp->lock, flags);
+
+	wait_event(lp->event, (lp->exec_pending == 0));
+
 	/*
 	 *	Issue mine
 	 */
 
 	lp->exec_pending=1;
 	
-	restore_flags(flags);
+	spin_unlock_irqrestore(&lp->lock, flags);
 	
 	lp->exec_box->mbox=0;
 	lp->exec_box->mbox=cmd;
@@ -645,13 +647,12 @@
 	while(!(inb(ioaddr+HOST_STATUS)&HOST_STATUS_CRR));
 	outb(1<<6, ioaddr+HOST_CMD);	
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&lp->lock, flags);
 
-	while(lp->exec_pending!=2)
-		sleep_on(&lp->event);
+	wait_event(lp->event, (lp->exec_pending == 2));
 	lp->exec_pending=0;
-	restore_flags(flags);
+
+	spin_unlock_irqrestore(&lp->lock, flags);
 	
 	if(lp->exec_box->mbox&(1<<13))
 		ret = -1;
@@ -735,14 +736,12 @@
 	outb(HOST_CMD_SUSPND_RX, ioaddr+HOST_CMD);			
 	mc32_ready_poll(dev); 
 	outb(HOST_CMD_SUSPND_TX, ioaddr+HOST_CMD);	
-		
-	save_flags(flags);
-	cli();
-		
-	while(lp->xceiver_state!=HALTED) 
-		sleep_on(&lp->event); 
-		
-	restore_flags(flags);	
+	
+	spin_lock_irqsave(&lp->lock, flags);	
+
+	wait_event(lp->event, (lp->xceiver_state == HALTED));
+			
+	spin_unlock_irqrestore(&lp->lock, flags);	
 } 
 
 
@@ -1062,12 +1061,11 @@
 
 	netif_stop_queue(dev);
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&lp->lock, flags);
 		
 	if(atomic_read(&lp->tx_count)==0)
 	{
-		restore_flags(flags);
+		spin_unlock_irqrestore(&lp->lock, flags);
 		return 1;
 	}
 
@@ -1098,7 +1096,7 @@
 		
 	p->control     &= ~CONTROL_EOL;     /* Clear EOL on p */ 
 out:	
-	restore_flags(flags);
+	spin_unlock_irqrestore(&lp->lock, flags);
 
 	netif_wake_queue(dev);
 	return 0;




--

Angelo Dell'Aera 'buffer' 
Antifork Research, Inc.	  	http://buffer.antifork.org

PGP information in e-mail header


-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux