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/char/ftape/lowlevel/ftape-calibr.c
Date: Sat, 28 Dec 2002 21:04:52 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.44.0212282102110.999-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/char/ftape/lowlevel/ftape-calibr.c.old	Sat Oct 19 12:04:19 2002
+++ linux/drivers/char/ftape/lowlevel/ftape-calibr.c	Sat Dec 28 21:01:01 2002
@@ -35,9 +35,10 @@
 # include <linux/timex.h>
 #endif
 #include <linux/ftape.h>
-#include "../lowlevel/ftape-tracing.h"
-#include "../lowlevel/ftape-calibr.h"
-#include "../lowlevel/fdc-io.h"
+#include "ftape-tracing.h"
+#include "ftape-calibr.h"
+#include "fdc-io.h"
+#include <linux/spinlock.h>
 
 #undef DEBUG
 
@@ -62,6 +63,7 @@
  * it will overflow only once per 30 seconds (on a 200MHz machine),
  * which is plenty.
  */
+static spinlock_t ftape_calibar_lock = SPIN_LOCK_UNLOCKED;
 
 unsigned int ftape_timestamp(void)
 {
@@ -75,13 +77,12 @@
 	__u16 lo;
 	__u16 hi;
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&ftape_calibar_lock, flags);
 	outb_p(0x00, 0x43);	/* latch the count ASAP */
 	lo = inb_p(0x40);	/* read the latched count */
 	lo |= inb(0x40) << 8;
 	hi = jiffies;
-	restore_flags(flags);
+	spin_lock_irqrestore(&ftape_calibar_lock, flags);
 	return ((hi + 1) * (unsigned int) LATCH) - lo;  /* downcounter ! */
 #endif
 }
@@ -94,12 +95,11 @@
 	unsigned int count;
  	unsigned long flags;
  
- 	save_flags(flags);
- 	cli();
+ 	spin_lock_irqsave(&ftape_calibar_lock, flags);
  	outb_p(0x00, 0x43);	/* latch the count ASAP */
 	count = inb_p(0x40);	/* read the latched count */
 	count |= inb(0x40) << 8;
- 	restore_flags(flags);
+ 	spin_unlock_irqrestore(&ftape_calibar_lock, flags);
 	return (LATCH - count);	/* normal: downcounter */
 #endif
 }
@@ -150,14 +150,13 @@
 	int status;
 	TRACE_FUN(ft_t_any);
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&ftape_calibar_lock, flags);
 	t0 = short_ftape_timestamp();
 	for (i = 0; i < 1000; ++i) {
 		status = inb(fdc.msr);
 	}
 	t1 = short_ftape_timestamp();
-	restore_flags(flags);
+	spin_unlock_irqrestore(&ftape_calibar_lock, flags);
 	TRACE(ft_t_info, "inb() duration: %d nsec", ftape_timediff(t0, t1));
 	TRACE_EXIT;
 }
@@ -241,8 +240,7 @@
 
 		*calibr_count =
 		*calibr_time = count;	/* set TC to 1 */
-		save_flags(flags);
-		cli();
+		spin_lock_irqsave(&ftape_calibar_lock, flags);
 		fun(0);		/* dummy, get code into cache */
 		t0 = short_ftape_timestamp();
 		fun(0);		/* overhead + one test */
@@ -252,7 +250,7 @@
 		fun(count);		/* overhead + count tests */
 		t1 = short_ftape_timestamp();
 		multiple = diff(t0, t1);
-		restore_flags(flags);
+		spin_unlock_irqrestore(&ftape_calibar_lock, flags);
 		time = ftape_timediff(0, multiple - once);
 		tc = (1000 * time) / (count - 1);
 		TRACE(ft_t_any, "once:%3d us,%6d times:%6d us, TC:%5d ns",


                 reply	other threads:[~2002-12-29  2:04 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.0212282102110.999-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®