Skip to contentSkip to conversation

cli() cleanup in xircom_tulip_cp.c and fec.c

PATCH In review Brandon Niemczyk 1 participant 2 messages Jul 11, 2005 – Jul 12, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cli() cleanup in xircom_tulip_cp.c and fec.c

replaces calls to save_flags(); cli() with spinlocks, also fixes some unreadable spacing in outl_CSR6()

drivers/net/fec.c +3 -3
diff -pruNX anti-cli/Documentation/dontdiff linux-pristine/drivers/net/fec.c anti-cli/drivers/net/fec.c
@@ -707,6 +707,7 @@ mii_queue(struct net_device *dev, int re
 	unsigned long	flags;
 	mii_list_t	*mip;
 	int		retval;
+	static spinlock_t lock = SPIN_LOCK_UNLOCKED;
 
 	/* Add PHY address to register command.
 	*/
@@ -715,8 +716,7 @@ mii_queue(struct net_device *dev, int re
 
 	retval = 0;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&lock, flags);
 
 	if ((mip = mii_free) != NULL) {
 		mii_free = mip->mii_next;
@@ -736,7 +736,7 @@ mii_queue(struct net_device *dev, int re
 		retval = 1;
 	}
 
-	restore_flags(flags);
+	spin_unlock_irqrestore(&lock, flags);
 
 	return(retval);
 }
drivers/net/tulip/xircom_tulip_cb.c +37 -34

127 lines not on this page · raw message

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw

Please discard the previous patch. I'm going to take these one at a time. Here's a patch for the fec code, it also makes some global variables that aren't used anywhere or declared in a header static.

drivers/net/fec.c +12 -7
diff -pruNX anti-cli/Documentation/dontdiff linux-pristine/drivers/net/fec.c anti-cli/drivers/net/fec.c
@@ -237,10 +237,11 @@ typedef struct mii_list {
 } mii_list_t;
 
 #define		NMII	20
-mii_list_t	mii_cmds[NMII];
-mii_list_t	*mii_free;
-mii_list_t	*mii_head;
-mii_list_t	*mii_tail;
+static mii_list_t	mii_cmds[NMII];
+static mii_list_t	*mii_free;
+static mii_list_t	*mii_head;
+static mii_list_t	*mii_tail;
+static DECLARE_SPINLOCK(mii_lock);
 
 static int	mii_queue(struct net_device *dev, int request, 
 				void (*func)(uint, struct net_device *));
@@ -679,10 +680,13 @@ fec_enet_mii(struct net_device *dev)
 	volatile fec_t	*ep;
 	mii_list_t	*mip;
 	uint		mii_reg;
+	unsigned long	flags;
 
 	fep = netdev_priv(dev);
 	ep = fep->hwp;
 	mii_reg = ep->fec_mii_data;
+
+	spin_lock_irqsave(&mii_lock, flags);
 	
 	if ((mip = mii_head) == NULL) {
 		printk("MII and no head!\n");
@@ -698,6 +702,8 @@ fec_enet_mii(struct net_device *dev)
 
 	if ((mip = mii_head) != NULL)
 		ep->fec_mii_data = mip->mii_regval;
+
+	spin_unlock_irqrestore(&mii_lock, flags);
 }
 
 static int
@@ -715,8 +721,7 @@ mii_queue(struct net_device *dev, int re
 
 	retval = 0;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&mii_lock, flags);
 
 	if ((mip = mii_free) != NULL) {
 		mii_free = mip->mii_next;
@@ -736,7 +741,7 @@ mii_queue(struct net_device *dev, int re
 		retval = 1;
 	}
 
-	restore_flags(flags);
+	spin_unlock_irqrestore(&mii_lock, flags);
 
 	return(retval);
 }

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors