linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: pwaechtler@mac.com
To: linux-kernel@vger.kernel.org
Cc: torvalds@transmeta.com
Subject: [PATCH] 13/41 sound/oss/pas2_midi.c - convert cli to spinlocks
Date: Thu, 29 Aug 2002 21:56:27 +0200	[thread overview]
Message-ID: <200208292155.g7TLtXVw009183@smtp-relay01.mac.com> (raw)

--- vanilla-2.5.32/sound/oss/pas2_midi.c	Sat Apr 20 18:25:21 2002
+++ linux-2.5-cli-oss/sound/oss/pas2_midi.c	Wed Aug 14 19:44:58 2002
@@ -14,10 +14,13 @@
  */
 
 #include <linux/init.h>
+#include <linux/spinlock.h>
 #include "sound_config.h"
 
 #include "pas2.h"
 
+extern spinlock_t lock;
+
 static int      midi_busy = 0, input_opened = 0;
 static int      my_dev;
 
@@ -48,12 +51,11 @@
 	pas_write(0x20 | 0x40,
 		  0x178b);
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&lock, flags);
 
 	if ((err = pas_set_intr(0x10)) < 0)
 	{
-		restore_flags(flags);
+		spin_unlock_irqrestore(&lock, flags);
 		return err;
 	}
 	/*
@@ -81,7 +83,7 @@
 
 	pas_write(0xff, 0x1B88);
 
-	restore_flags(flags);
+	spin_unlock_irqrestore(&lock, flags);
 
 	midi_busy = 1;
 	qlen = qhead = qtail = 0;
@@ -131,8 +133,7 @@
 	 * Drain the local queue first
 	 */
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&lock, flags);
 
 	while (qlen && dump_to_midi(tmp_queue[qhead]))
 	{
@@ -140,7 +141,7 @@
 		qhead++;
 	}
 
-	restore_flags(flags);
+	spin_unlock_irqrestore(&lock, flags);
 
 	/*
 	 *	Output the byte if the local queue is empty.
@@ -157,14 +158,13 @@
 	if (qlen >= 256)
 		return 0;	/* Local queue full */
 
-	save_flags(flags);
-	cli();
+	spin_lock_irqsave(&lock, flags);
 
 	tmp_queue[qtail] = midi_byte;
 	qlen++;
 	qtail++;
 
-	restore_flags(flags);
+	spin_unlock_irqrestore(&lock, flags);
 
 	return 1;
 }
@@ -226,7 +226,6 @@
 {
 	unsigned char   stat;
 	int             i, incount;
-	unsigned long   flags;
 
 	stat = pas_read(0x1B88);
 
@@ -245,8 +244,7 @@
 	}
 	if (stat & (0x08 | 0x10))
 	{
-		save_flags(flags);
-		cli();
+		spin_lock(&lock);/* called in irq context */
 
 		while (qlen && dump_to_midi(tmp_queue[qhead]))
 		{
@@ -254,7 +252,7 @@
 			qhead++;
 		}
 
-		restore_flags(flags);
+		spin_unlock(&lock);
 	}
 	if (stat & 0x40)
 	{


                 reply	other threads:[~2002-08-29 22:46 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=200208292155.g7TLtXVw009183@smtp-relay01.mac.com \
    --to=pwaechtler@mac.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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;
as well as URLs for NNTP newsgroup(s).