Commit 6681f46b authored by Peter Wächtler's avatar Peter Wächtler Committed by Linus Torvalds

[PATCH] oss/sscape.c - convert cli to spinlocks

parent d0dd4250
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/wrapper.h> #include <linux/wrapper.h>
#include <linux/spinlock.h>
#include "coproc.h" #include "coproc.h"
...@@ -115,7 +116,7 @@ typedef struct sscape_info ...@@ -115,7 +116,7 @@ typedef struct sscape_info
char* raw_buf; char* raw_buf;
unsigned long raw_buf_phys; unsigned long raw_buf_phys;
int buffsize; /* -------------------------- */ int buffsize; /* -------------------------- */
spinlock_t lock;
int ok; /* Properly detected */ int ok; /* Properly detected */
int failed; int failed;
int dma_allocated; int dma_allocated;
...@@ -164,11 +165,10 @@ static unsigned char sscape_read(struct sscape_info *devc, int reg) ...@@ -164,11 +165,10 @@ static unsigned char sscape_read(struct sscape_info *devc, int reg)
unsigned long flags; unsigned long flags;
unsigned char val; unsigned char val;
save_flags(flags); spin_lock_irqsave(&devc->lock,flags);
cli();
outb(reg, PORT(ODIE_ADDR)); outb(reg, PORT(ODIE_ADDR));
val = inb(PORT(ODIE_DATA)); val = inb(PORT(ODIE_DATA));
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
return val; return val;
} }
...@@ -176,11 +176,10 @@ static void sscape_write(struct sscape_info *devc, int reg, int data) ...@@ -176,11 +176,10 @@ static void sscape_write(struct sscape_info *devc, int reg, int data)
{ {
unsigned long flags; unsigned long flags;
save_flags(flags); spin_lock_irqsave(&devc->lock,flags);
cli();
outb(reg, PORT(ODIE_ADDR)); outb(reg, PORT(ODIE_ADDR));
outb(data, PORT(ODIE_DATA)); outb(data, PORT(ODIE_DATA));
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
} }
static unsigned char sscape_pnp_read_codec(sscape_info* devc, unsigned char reg) static unsigned char sscape_pnp_read_codec(sscape_info* devc, unsigned char reg)
...@@ -188,11 +187,10 @@ static unsigned char sscape_pnp_read_codec(sscape_info* devc, unsigned char reg) ...@@ -188,11 +187,10 @@ static unsigned char sscape_pnp_read_codec(sscape_info* devc, unsigned char reg)
unsigned char res; unsigned char res;
unsigned long flags; unsigned long flags;
save_flags(flags); spin_lock_irqsave(&devc->lock,flags);
cli();
outb( reg, devc -> codec); outb( reg, devc -> codec);
res = inb (devc -> codec + 1); res = inb (devc -> codec + 1);
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
return res; return res;
} }
...@@ -201,11 +199,10 @@ static void sscape_pnp_write_codec(sscape_info* devc, unsigned char reg, unsigne ...@@ -201,11 +199,10 @@ static void sscape_pnp_write_codec(sscape_info* devc, unsigned char reg, unsigne
{ {
unsigned long flags; unsigned long flags;
save_flags(flags); spin_lock_irqsave(&devc->lock,flags);
cli();
outb( reg, devc -> codec); outb( reg, devc -> codec);
outb( data, devc -> codec + 1); outb( data, devc -> codec + 1);
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
} }
static void host_open(struct sscape_info *devc) static void host_open(struct sscape_info *devc)
...@@ -223,9 +220,7 @@ static int host_write(struct sscape_info *devc, unsigned char *data, int count) ...@@ -223,9 +220,7 @@ static int host_write(struct sscape_info *devc, unsigned char *data, int count)
unsigned long flags; unsigned long flags;
int i, timeout_val; int i, timeout_val;
save_flags(flags); spin_lock_irqsave(&devc->lock,flags);
cli();
/* /*
* Send the command and data bytes * Send the command and data bytes
*/ */
...@@ -238,12 +233,12 @@ static int host_write(struct sscape_info *devc, unsigned char *data, int count) ...@@ -238,12 +233,12 @@ static int host_write(struct sscape_info *devc, unsigned char *data, int count)
if (timeout_val <= 0) if (timeout_val <= 0)
{ {
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
return 0; return 0;
} }
outb(data[i], PORT(HOST_DATA)); outb(data[i], PORT(HOST_DATA));
} }
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
return 1; return 1;
} }
...@@ -253,9 +248,7 @@ static int host_read(struct sscape_info *devc) ...@@ -253,9 +248,7 @@ static int host_read(struct sscape_info *devc)
int timeout_val; int timeout_val;
unsigned char data; unsigned char data;
save_flags(flags); spin_lock_irqsave(&devc->lock,flags);
cli();
/* /*
* Read a byte * Read a byte
*/ */
...@@ -266,11 +259,11 @@ static int host_read(struct sscape_info *devc) ...@@ -266,11 +259,11 @@ static int host_read(struct sscape_info *devc)
if (timeout_val <= 0) if (timeout_val <= 0)
{ {
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
return -1; return -1;
} }
data = inb(PORT(HOST_DATA)); data = inb(PORT(HOST_DATA));
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
return data; return data;
} }
...@@ -391,14 +384,13 @@ static void sscape_coproc_close(void *dev_info, int sub_device) ...@@ -391,14 +384,13 @@ static void sscape_coproc_close(void *dev_info, int sub_device)
struct sscape_info *devc = dev_info; struct sscape_info *devc = dev_info;
unsigned long flags; unsigned long flags;
save_flags(flags); spin_lock_irqsave(&devc->lock,flags);
cli();
if (devc->dma_allocated) if (devc->dma_allocated)
{ {
sscape_write(devc, GA_DMAA_REG, 0x20); /* DMA channel disabled */ sscape_write(devc, GA_DMAA_REG, 0x20); /* DMA channel disabled */
devc->dma_allocated = 0; devc->dma_allocated = 0;
} }
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
return; return;
} }
...@@ -420,14 +412,13 @@ static int sscape_download_boot(struct sscape_info *devc, unsigned char *block, ...@@ -420,14 +412,13 @@ static int sscape_download_boot(struct sscape_info *devc, unsigned char *block,
* before continuing. * before continuing.
*/ */
save_flags(flags); spin_lock_irqsave(&devc->lock,flags);
cli();
codec_dma_bits = sscape_read(devc, GA_CDCFG_REG); codec_dma_bits = sscape_read(devc, GA_CDCFG_REG);
if (devc->dma_allocated == 0) if (devc->dma_allocated == 0)
devc->dma_allocated = 1; devc->dma_allocated = 1;
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
sscape_write(devc, GA_HMCTL_REG, sscape_write(devc, GA_HMCTL_REG,
(temp = sscape_read(devc, GA_HMCTL_REG)) & 0x3f); /*Reset */ (temp = sscape_read(devc, GA_HMCTL_REG)) & 0x3f); /*Reset */
...@@ -449,8 +440,7 @@ static int sscape_download_boot(struct sscape_info *devc, unsigned char *block, ...@@ -449,8 +440,7 @@ static int sscape_download_boot(struct sscape_info *devc, unsigned char *block,
} }
memcpy(audio_devs[devc->codec_audiodev]->dmap_out->raw_buf, block, size); memcpy(audio_devs[devc->codec_audiodev]->dmap_out->raw_buf, block, size);
save_flags(flags); spin_lock_irqsave(&devc->lock,flags);
cli();
/******** INTERRUPTS DISABLED NOW ********/ /******** INTERRUPTS DISABLED NOW ********/
...@@ -475,7 +465,7 @@ static int sscape_download_boot(struct sscape_info *devc, unsigned char *block, ...@@ -475,7 +465,7 @@ static int sscape_download_boot(struct sscape_info *devc, unsigned char *block,
done = 1; done = 1;
} }
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
if (!done) if (!done)
return 0; return 0;
...@@ -494,9 +484,7 @@ static int sscape_download_boot(struct sscape_info *devc, unsigned char *block, ...@@ -494,9 +484,7 @@ static int sscape_download_boot(struct sscape_info *devc, unsigned char *block,
/* /*
* Wait until the ODB wakes up * Wait until the ODB wakes up
*/ */
spin_lock_irqsave(&devc->lock,flags);
save_flags(flags);
cli();
done = 0; done = 0;
timeout_val = 5 * HZ; timeout_val = 5 * HZ;
while (!done && timeout_val-- > 0) while (!done && timeout_val-- > 0)
...@@ -513,14 +501,13 @@ static int sscape_download_boot(struct sscape_info *devc, unsigned char *block, ...@@ -513,14 +501,13 @@ static int sscape_download_boot(struct sscape_info *devc, unsigned char *block,
} }
sscape_write(devc, GA_CDCFG_REG, codec_dma_bits); sscape_write(devc, GA_CDCFG_REG, codec_dma_bits);
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
if (!done) if (!done)
{ {
printk(KERN_ERR "soundscape: The OBP didn't respond after code download\n"); printk(KERN_ERR "soundscape: The OBP didn't respond after code download\n");
return 0; return 0;
} }
save_flags(flags); spin_lock_irqsave(&devc->lock,flags);
cli();
done = 0; done = 0;
timeout_val = 5 * HZ; timeout_val = 5 * HZ;
while (!done && timeout_val-- > 0) while (!done && timeout_val-- > 0)
...@@ -529,7 +516,7 @@ static int sscape_download_boot(struct sscape_info *devc, unsigned char *block, ...@@ -529,7 +516,7 @@ static int sscape_download_boot(struct sscape_info *devc, unsigned char *block,
if (inb(PORT(HOST_DATA)) == 0xfe) /* Host startup acknowledge */ if (inb(PORT(HOST_DATA)) == 0xfe) /* Host startup acknowledge */
done = 1; done = 1;
} }
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
if (!done) if (!done)
{ {
printk(KERN_ERR "soundscape: OBP Initialization failed.\n"); printk(KERN_ERR "soundscape: OBP Initialization failed.\n");
...@@ -675,8 +662,7 @@ void __init attach_sscape(struct address_info *hw_config) ...@@ -675,8 +662,7 @@ void __init attach_sscape(struct address_info *hw_config)
if (!sscape_is_pnp) { if (!sscape_is_pnp) {
save_flags(flags); spin_lock_irqsave(&devc->lock,flags);
cli();
for (i = 1; i < 10; i++) for (i = 1; i < 10; i++)
{ {
switch (i) switch (i)
...@@ -710,7 +696,7 @@ void __init attach_sscape(struct address_info *hw_config) ...@@ -710,7 +696,7 @@ void __init attach_sscape(struct address_info *hw_config)
sscape_write(devc, i, regs[i]); sscape_write(devc, i, regs[i]);
} }
} }
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
} }
#ifdef SSCAPE_DEBUG2 #ifdef SSCAPE_DEBUG2
/* /*
...@@ -960,8 +946,7 @@ static int sscape_pnp_upload_file(sscape_info* devc, char* fn) ...@@ -960,8 +946,7 @@ static int sscape_pnp_upload_file(sscape_info* devc, char* fn)
return 0; return 0;
} }
dt = data; dt = data;
save_flags(flags); spin_lock_irqsave(&devc->lock,flags);
cli();
while ( len > 0 ) { while ( len > 0 ) {
if (len > devc -> buffsize) l = devc->buffsize; if (len > devc -> buffsize) l = devc->buffsize;
else l = len; else l = len;
...@@ -970,12 +955,12 @@ static int sscape_pnp_upload_file(sscape_info* devc, char* fn) ...@@ -970,12 +955,12 @@ static int sscape_pnp_upload_file(sscape_info* devc, char* fn)
sscape_start_dma(devc->dma, devc->raw_buf_phys, l, 0x48); sscape_start_dma(devc->dma, devc->raw_buf_phys, l, 0x48);
sscape_pnp_start_dma ( devc, 0 ); sscape_pnp_start_dma ( devc, 0 );
if (sscape_pnp_wait_dma ( devc, 0 ) == 0) { if (sscape_pnp_wait_dma ( devc, 0 ) == 0) {
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
return 0; return 0;
} }
} }
restore_flags(flags); spin_unlock_irqrestore(&devc->lock,flags);
vfree(data); vfree(data);
outb(0, devc -> base + 2); outb(0, devc -> base + 2);
...@@ -1469,6 +1454,7 @@ static int __init init_sscape(void) ...@@ -1469,6 +1454,7 @@ static int __init init_sscape(void)
devc->codec_type = 0; devc->codec_type = 0;
devc->ic_type = 0; devc->ic_type = 0;
devc->raw_buf = NULL; devc->raw_buf = NULL;
spin_lock_init(&devc->lock);
if (cfg.dma == -1 || cfg.irq == -1 || cfg.io_base == -1) { if (cfg.dma == -1 || cfg.irq == -1 || cfg.io_base == -1) {
printk(KERN_ERR "DMA, IRQ, and IO port must be specified.\n"); printk(KERN_ERR "DMA, IRQ, and IO port must be specified.\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment