mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] 2.5.53 : drivers/net/pcmcia/3c574_cs.c
@ 2002-12-29  1:07 Frank Davis
  0 siblings, 0 replies; only message in thread
From: Frank Davis @ 2002-12-29  1:07 UTC (permalink / raw)
  To: linux-kernel; +Cc: fdavis

Hello all,
  The following patch swaps the save_flags/cli/restore_flags combo 
with a spinlock. Please review.
Regards,
Frank

--- linux/drivers/net/pcmcia/3c574_cs.c.old	Fri Nov 22 23:20:59 2002
+++ linux/drivers/net/pcmcia/3c574_cs.c	Sat Dec 28 19:53:10 2002
@@ -96,9 +96,12 @@
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/bitops.h>
+#include <linux/spinlock.h>
 
 /*====================================================================*/
 
+static spinlock_t 3c574_cs_lock = SPIN_LOCK_UNLOCKED;
+
 /* Module parameters */
 
 MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
@@ -1043,13 +1046,12 @@
 		return;
     }
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&3c574_cs_lock, flags);
 	EL3WINDOW(4);
 	media = mdio_read(ioaddr, lp->phys, 1);
 	partner = mdio_read(ioaddr, lp->phys, 5);
 	EL3WINDOW(1);
-	restore_flags(flags);
+	spin_unlock_irqrestore(&3c574_cs_lock, flags);
 
 	if (media != lp->media_status) {
 		if ((media ^ lp->media_status) & 0x0004)
@@ -1232,31 +1234,29 @@
 	case SIOCDEVPRIVATE+1:		/* Read the specified MII register. */
 		{
 			int saved_window;
-                       unsigned long flags;
+                        unsigned long flags;
 
-			save_flags(flags);
-			cli();
+			spin_lock_irqsave(&3c574_cs_lock, flags);
 			saved_window = inw(ioaddr + EL3_CMD) >> 13;
 			EL3WINDOW(4);
 			data[3] = mdio_read(ioaddr, data[0] & 0x1f, data[1] & 0x1f);
 			EL3WINDOW(saved_window);
-			restore_flags(flags);
+			spin_unlock_irqrestore(&3c574_cs_lock,flags);
 			return 0;
 		}
 	case SIOCDEVPRIVATE+2:		/* Write the specified MII register */
 		{
 			int saved_window;
-                       unsigned long flags;
+                        unsigned long flags;
 
 			if (!capable(CAP_NET_ADMIN))
 				return -EPERM;
-			save_flags(flags);
-			cli();
+			spin_lock_irqsave(&3c574_cs_lock, flags);
 			saved_window = inw(ioaddr + EL3_CMD) >> 13;
 			EL3WINDOW(4);
 			mdio_write(ioaddr, data[0] & 0x1f, data[1] & 0x1f, data[2]);
 			EL3WINDOW(saved_window);
-			restore_flags(flags);
+			spin_unlock_irqrestore(&3c574_cs_lock, flags);
 			return 0;
 		}
 	default:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-12-29  1:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-29  1:07 [PATCH] 2.5.53 : drivers/net/pcmcia/3c574_cs.c Frank Davis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®