Commit 1e963aac authored by Peter Wächtler's avatar Peter Wächtler Committed by Linus Torvalds

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

parent 6681f46b
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/spinlock.h>
#include "sound_config.h" #include "sound_config.h"
#include "sound_firmware.h" #include "sound_firmware.h"
...@@ -142,6 +143,7 @@ typedef struct pss_confdata { ...@@ -142,6 +143,7 @@ typedef struct pss_confdata {
static pss_confdata pss_data; static pss_confdata pss_data;
static pss_confdata *devc = &pss_data; static pss_confdata *devc = &pss_data;
static spinlock_t lock=SPIN_LOCK_UNLOCKED;
static int pss_initialized = 0; static int pss_initialized = 0;
static int nonstandard_microcode = 0; static int nonstandard_microcode = 0;
...@@ -838,18 +840,17 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, caddr_t arg, int l ...@@ -838,18 +840,17 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, caddr_t arg, int l
return -EFAULT; return -EFAULT;
} }
data = (unsigned short *)(mbuf->data); data = (unsigned short *)(mbuf->data);
save_flags(flags); spin_lock_irqsave(&lock, flags);
cli();
for (i = 0; i < mbuf->len; i++) { for (i = 0; i < mbuf->len; i++) {
if (!pss_put_dspword(devc, *data++)) { if (!pss_put_dspword(devc, *data++)) {
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
mbuf->len = i; /* feed back number of WORDs sent */ mbuf->len = i; /* feed back number of WORDs sent */
err = copy_to_user(arg, mbuf, sizeof(copr_msg)); err = copy_to_user(arg, mbuf, sizeof(copr_msg));
vfree(mbuf); vfree(mbuf);
return err ? -EFAULT : -EIO; return err ? -EFAULT : -EIO;
} }
} }
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
vfree(mbuf); vfree(mbuf);
return 0; return 0;
...@@ -859,8 +860,7 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, caddr_t arg, int l ...@@ -859,8 +860,7 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, caddr_t arg, int l
if (mbuf == NULL) if (mbuf == NULL)
return -ENOSPC; return -ENOSPC;
data = (unsigned short *)mbuf->data; data = (unsigned short *)mbuf->data;
save_flags(flags); spin_lock_irqsave(&lock, flags);
cli();
for (i = 0; i < sizeof(mbuf->data)/sizeof(unsigned short); i++) { for (i = 0; i < sizeof(mbuf->data)/sizeof(unsigned short); i++) {
mbuf->len = i; /* feed back number of WORDs read */ mbuf->len = i; /* feed back number of WORDs read */
if (!pss_get_dspword(devc, data++)) { if (!pss_get_dspword(devc, data++)) {
...@@ -869,7 +869,7 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, caddr_t arg, int l ...@@ -869,7 +869,7 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, caddr_t arg, int l
break; break;
} }
} }
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
if (copy_to_user(arg, mbuf, sizeof(copr_msg))) if (copy_to_user(arg, mbuf, sizeof(copr_msg)))
err = -EFAULT; err = -EFAULT;
vfree(mbuf); vfree(mbuf);
...@@ -878,22 +878,21 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, caddr_t arg, int l ...@@ -878,22 +878,21 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, caddr_t arg, int l
case SNDCTL_COPR_RDATA: case SNDCTL_COPR_RDATA:
if (copy_from_user(&dbuf, arg, sizeof(dbuf))) if (copy_from_user(&dbuf, arg, sizeof(dbuf)))
return -EFAULT; return -EFAULT;
save_flags(flags); spin_lock_irqsave(&lock, flags);
cli();
if (!pss_put_dspword(devc, 0x00d0)) { if (!pss_put_dspword(devc, 0x00d0)) {
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return -EIO; return -EIO;
} }
if (!pss_put_dspword(devc, (unsigned short)(dbuf.parm1 & 0xffff))) { if (!pss_put_dspword(devc, (unsigned short)(dbuf.parm1 & 0xffff))) {
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return -EIO; return -EIO;
} }
if (!pss_get_dspword(devc, &tmp)) { if (!pss_get_dspword(devc, &tmp)) {
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return -EIO; return -EIO;
} }
dbuf.parm1 = tmp; dbuf.parm1 = tmp;
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
if (copy_to_user(arg, &dbuf, sizeof(dbuf))) if (copy_to_user(arg, &dbuf, sizeof(dbuf)))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -901,74 +900,71 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, caddr_t arg, int l ...@@ -901,74 +900,71 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, caddr_t arg, int l
case SNDCTL_COPR_WDATA: case SNDCTL_COPR_WDATA:
if (copy_from_user(&dbuf, arg, sizeof(dbuf))) if (copy_from_user(&dbuf, arg, sizeof(dbuf)))
return -EFAULT; return -EFAULT;
save_flags(flags); spin_lock_irqsave(&lock, flags);
cli();
if (!pss_put_dspword(devc, 0x00d1)) { if (!pss_put_dspword(devc, 0x00d1)) {
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return -EIO; return -EIO;
} }
if (!pss_put_dspword(devc, (unsigned short) (dbuf.parm1 & 0xffff))) { if (!pss_put_dspword(devc, (unsigned short) (dbuf.parm1 & 0xffff))) {
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return -EIO; return -EIO;
} }
tmp = (unsigned int)dbuf.parm2 & 0xffff; tmp = (unsigned int)dbuf.parm2 & 0xffff;
if (!pss_put_dspword(devc, tmp)) { if (!pss_put_dspword(devc, tmp)) {
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return -EIO; return -EIO;
} }
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return 0; return 0;
case SNDCTL_COPR_WCODE: case SNDCTL_COPR_WCODE:
if (copy_from_user(&dbuf, arg, sizeof(dbuf))) if (copy_from_user(&dbuf, arg, sizeof(dbuf)))
return -EFAULT; return -EFAULT;
save_flags(flags); spin_lock_irqsave(&lock, flags);
cli();
if (!pss_put_dspword(devc, 0x00d3)) { if (!pss_put_dspword(devc, 0x00d3)) {
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return -EIO; return -EIO;
} }
if (!pss_put_dspword(devc, (unsigned short)(dbuf.parm1 & 0xffff))) { if (!pss_put_dspword(devc, (unsigned short)(dbuf.parm1 & 0xffff))) {
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return -EIO; return -EIO;
} }
tmp = (unsigned int)dbuf.parm2 & 0x00ff; tmp = (unsigned int)dbuf.parm2 & 0x00ff;
if (!pss_put_dspword(devc, tmp)) { if (!pss_put_dspword(devc, tmp)) {
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return -EIO; return -EIO;
} }
tmp = ((unsigned int)dbuf.parm2 >> 8) & 0xffff; tmp = ((unsigned int)dbuf.parm2 >> 8) & 0xffff;
if (!pss_put_dspword(devc, tmp)) { if (!pss_put_dspword(devc, tmp)) {
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return -EIO; return -EIO;
} }
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return 0; return 0;
case SNDCTL_COPR_RCODE: case SNDCTL_COPR_RCODE:
if (copy_from_user(&dbuf, arg, sizeof(dbuf))) if (copy_from_user(&dbuf, arg, sizeof(dbuf)))
return -EFAULT; return -EFAULT;
save_flags(flags); spin_lock_irqsave(&lock, flags);
cli();
if (!pss_put_dspword(devc, 0x00d2)) { if (!pss_put_dspword(devc, 0x00d2)) {
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return -EIO; return -EIO;
} }
if (!pss_put_dspword(devc, (unsigned short)(dbuf.parm1 & 0xffff))) { if (!pss_put_dspword(devc, (unsigned short)(dbuf.parm1 & 0xffff))) {
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return -EIO; return -EIO;
} }
if (!pss_get_dspword(devc, &tmp)) { /* Read MSB */ if (!pss_get_dspword(devc, &tmp)) { /* Read MSB */
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return -EIO; return -EIO;
} }
dbuf.parm1 = tmp << 8; dbuf.parm1 = tmp << 8;
if (!pss_get_dspword(devc, &tmp)) { /* Read LSB */ if (!pss_get_dspword(devc, &tmp)) { /* Read LSB */
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
return -EIO; return -EIO;
} }
dbuf.parm1 |= tmp & 0x00ff; dbuf.parm1 |= tmp & 0x00ff;
restore_flags(flags); spin_unlock_irqrestore(&lock,flags);
if (copy_to_user(arg, &dbuf, sizeof(dbuf))) if (copy_to_user(arg, &dbuf, sizeof(dbuf)))
return -EFAULT; return -EFAULT;
return 0; return 0;
......
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