mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank Davis <fdavis@si.rr.com>
To: linux-kernel@vger.kernel.org
Cc: fdavis@si.rr.com
Subject: [PATCH] 2.5.53 : drivers/net/pcmcia/3c574_cs.c
Date: Sat, 28 Dec 2002 20:07:18 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.44.0212282004240.952-100000@linux-dev> (raw)

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:


                 reply	other threads:[~2002-12-29  1:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0212282004240.952-100000@linux-dev \
    --to=fdavis@si.rr.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®