mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: pwaechtler@mac.com
To: linux-kernel@vger.kernel.org
Cc: torvalds@transmeta.com
Subject: [PATCH] 4/41 sound/oss/ad1816.c - convert cli to spinlocks
Date: Thu, 29 Aug 2002 21:56:27 +0200	[thread overview]
Message-ID: <200208292153.g7TLrnKN026074@smtp-relay03.mac.com> (raw)

--- vanilla-2.5.32/sound/oss/ad1816.c	Sat Apr 20 18:25:17 2002
+++ linux-2.5-cli-oss/sound/oss/ad1816.c	Tue Aug 13 16:08:27 2002
@@ -37,7 +37,7 @@
 #include <linux/init.h>
 #include <linux/isapnp.h>
 #include <linux/stddef.h>
-
+#include <linux/spinlock.h>
 #include "sound_config.h"
 
 #define DEBUGNOISE(x)
@@ -77,7 +77,7 @@
 				    in ad1816_info */
 	int            irq_ok;
 	int            *osp;
-  
+	spinlock_t	lock;  
 } ad1816_info;
 
 static int nr_ad1816_devs;
@@ -109,12 +109,11 @@
 	
 	CHECK_FOR_POWER;
 
-	save_flags (flags); /* make register access atomic */
-	cli ();
+	spin_lock_irqsave(&devc->lock,flags); /* make register access atomic */
 	outb ((unsigned char) (reg & 0x3f), devc->base+0);
 	result = inb(devc->base+2);
 	result+= inb(devc->base+3)<<8;
-	restore_flags (flags);
+	spin_unlock_irqrestore(&devc->lock,flags);
 	
 	return (result);
 }
@@ -126,12 +125,11 @@
 	
 	CHECK_FOR_POWER;
 	
-	save_flags (flags); /* make register access atomic */
-	cli ();
+	spin_lock_irqsave(&devc->lock,flags); /* make register access atomic */
 	outb ((unsigned char) (reg & 0xff), devc->base+0);
 	outb ((unsigned char) (data & 0xff),devc->base+2);
 	outb ((unsigned char) ((data>>8)&0xff),devc->base+3);
-	restore_flags (flags);
+	spin_unlock_irqrestore(&devc->lock,flags);
 
 }
 
@@ -147,8 +145,7 @@
 	
 	DEBUGINFO (printk("ad1816: halt_input called\n"));
 	
-	save_flags (flags); 
-	cli ();
+	spin_lock_irqsave(&devc->lock,flags); 
 	
 	if(!isa_dma_bridge_buggy) {
 	        disable_dma(audio_devs[dev]->dmap_in->dma);
@@ -168,7 +165,7 @@
 	outb (~0x40, devc->base+1);	
 	
 	devc->audio_mode &= ~PCM_ENABLE_INPUT;
-	restore_flags (flags);
+	spin_unlock_irqrestore(&devc->lock,flags);
 }
 
 static void ad1816_halt_output (int dev)
@@ -180,8 +177,7 @@
 
 	DEBUGINFO (printk("ad1816: halt_output called!\n"));
 
-	save_flags (flags); 
-	cli ();
+	spin_lock_irqsave(&devc->lock,flags); 
 	/* Mute pcm output */
 	ad_write(devc, 4, ad_read(devc,4)|0x8080);
 
@@ -203,7 +199,7 @@
 	outb ((unsigned char)~0x80, devc->base+1);	
 
 	devc->audio_mode &= ~PCM_ENABLE_OUTPUT;
-	restore_flags (flags);
+	spin_unlock_irqrestore(&devc->lock,flags);
 }
 
 static void ad1816_output_block (int dev, unsigned long buf, 
@@ -217,14 +213,13 @@
   
 	cnt = count/4 - 1;
   
-	save_flags (flags);
-	cli ();
+	spin_lock_irqsave(&devc->lock,flags);
 	
 	/* set transfer count */
 	ad_write (devc, 8, cnt & 0xffff); 
 	
 	devc->audio_mode |= PCM_ENABLE_OUTPUT; 
-	restore_flags (flags);
+	spin_unlock_irqrestore(&devc->lock,flags);
 }
 
 
@@ -239,14 +234,13 @@
 
 	cnt = count/4 - 1;
 
-	save_flags (flags); /* make register access atomic */
-	cli ();
+	spin_lock_irqsave(&devc->lock,flags);
 
 	/* set transfer count */
 	ad_write (devc, 10, cnt & 0xffff); 
 
 	devc->audio_mode |= PCM_ENABLE_INPUT;
-	restore_flags (flags);
+	spin_unlock_irqrestore(&devc->lock,flags);
 }
 
 static int ad1816_prepare_for_input (int dev, int bsize, int bcount)
@@ -258,8 +252,7 @@
 	
 	DEBUGINFO (printk ("ad1816: prepare_for_input called: bsize=%d bcount=%d\n",bsize,bcount));
 
-	save_flags (flags); 
-	cli ();
+	spin_lock_irqsave(&devc->lock,flags);
 	
 	fmt_bits= (devc->format_bits&0x7)<<3;
 	
@@ -290,7 +283,7 @@
 	ad_write (devc, 2, freq & 0xffff);	
 	ad_write (devc, 3, freq & 0xffff);	
 
-	restore_flags (flags);
+	spin_unlock_irqrestore(&devc->lock,flags);
 
 	ad1816_halt_input(dev);
 	return 0;
@@ -305,8 +298,7 @@
 
 	DEBUGINFO (printk ("ad1816: prepare_for_output called: bsize=%d bcount=%d\n",bsize,bcount));
 
-	save_flags (flags); /* make register access atomic */
-	cli ();
+	spin_lock_irqsave(&devc->lock,flags);
 
 	fmt_bits= (devc->format_bits&0x7)<<3;
 	/* set mono/stereo mode */
@@ -335,7 +327,7 @@
 	ad_write (devc, 2, freq & 0xffff);
 	ad_write (devc, 3, freq & 0xffff);
 
-	restore_flags (flags);
+	spin_unlock_irqrestore(&devc->lock,flags);
 	
 	ad1816_halt_output(dev);
 	return 0;
@@ -351,8 +343,7 @@
 
 	/* mode may have changed */
 
-	save_flags (flags); /* make register access atomic */
-	cli ();
+	spin_lock_irqsave(&devc->lock,flags);
 
 	/* mask out modes not specified on open call */
 	state &= devc->audio_mode; 
@@ -377,7 +368,7 @@
 		/* disable capture */
 		outb(inb(devc->base+8)&~0x01, devc->base+8);
 	}
-	restore_flags (flags);
+	spin_unlock_irqrestore(&devc->lock,flags);
 }
 
 
@@ -480,11 +471,10 @@
 	devc = (ad1816_info *) audio_devs[dev]->devc; 
 
 	/* make check if device already open atomic */
-	save_flags (flags); 
-	cli ();
+	spin_lock_irqsave(&devc->lock,flags);
 
 	if (devc->opened) {
-		restore_flags (flags);
+		spin_unlock_irqrestore(&devc->lock,flags);
 		return -(EBUSY);
 	}
 
@@ -497,7 +487,7 @@
 	devc->channels=1;
 
 	ad1816_reset(devc->dev_no); /* halt all pending output */
-	restore_flags (flags);
+	spin_unlock_irqrestore(&devc->lock,flags);
 	return 0;
 }
 
@@ -506,8 +496,7 @@
 	unsigned long flags;
 	ad1816_info    *devc = (ad1816_info *) audio_devs[dev]->devc;
 
-	save_flags (flags); 
-	cli ();
+	spin_lock_irqsave(&devc->lock,flags);
 
 	/* halt all pending output */
 	ad1816_reset(devc->dev_no); 
@@ -518,8 +507,7 @@
 	devc->audio_format=AFMT_U8;
 	devc->format_bits = 0;
 
-
-	restore_flags (flags);
+	spin_unlock_irqrestore(&devc->lock,flags);
 }
 
 
@@ -556,7 +544,6 @@
 	unsigned char	status;
 	ad1816_info	*devc;
 	int		dev;
-	unsigned long	flags;
 
 	
 	if (irq < 0 || irq > 15) {
@@ -574,8 +561,7 @@
 
 	devc = (ad1816_info *) audio_devs[dev]->devc;
 	
-	save_flags(flags);
-	cli();
+	spin_lock(&devc->lock);
 
 	/* read interrupt register */
 	status = inb (devc->base+1); 
@@ -595,7 +581,7 @@
 	if (devc->opened && (devc->audio_mode & PCM_ENABLE_OUTPUT) && (status & 128))
 		DMAbuf_outputintr (dev, 1);
 
-	restore_flags(flags);
+	spin_unlock(&devc->lock);
 }
 
 /* ------------------------------------------------------------------- */
@@ -1033,6 +1019,7 @@
 	devc->irq = 0;
 	devc->opened = 0;
 	devc->osp = osp;
+	spin_lock_init(&devc->lock);
 
 	/* base+0: bit 1 must be set but not 255 */
 	tmp=inb(devc->base);


                 reply	other threads:[~2002-08-29 21:51 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=200208292153.g7TLrnKN026074@smtp-relay03.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

all inboxes | Powered by JetHome®