Commit 8aedeb7a authored by Jaroslav Kysela's avatar Jaroslav Kysela

[ALSA] Remove unnecessary ac97 spinlocks

ATIIXP driver,ATIIXP-modem driver,ENS1370/1+ driver,Intel8x0 driver
Intel8x0-modem driver,Maestro3 driver,VIA82xx driver
VIA82xx-modem driver
Removed unnecessary spinlocks in ac97 callbacks.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 9c0df338
...@@ -264,7 +264,6 @@ struct snd_atiixp { ...@@ -264,7 +264,6 @@ struct snd_atiixp {
ac97_t *ac97[NUM_ATI_CODECS]; ac97_t *ac97[NUM_ATI_CODECS];
spinlock_t reg_lock; spinlock_t reg_lock;
spinlock_t ac97_lock;
atiixp_dma_t dmas[NUM_ATI_DMAS]; atiixp_dma_t dmas[NUM_ATI_DMAS];
struct ac97_pcm *pcms[NUM_ATI_PCMS]; struct ac97_pcm *pcms[NUM_ATI_PCMS];
...@@ -476,20 +475,14 @@ static void snd_atiixp_codec_write(atiixp_t *chip, unsigned short codec, unsigne ...@@ -476,20 +475,14 @@ static void snd_atiixp_codec_write(atiixp_t *chip, unsigned short codec, unsigne
static unsigned short snd_atiixp_ac97_read(ac97_t *ac97, unsigned short reg) static unsigned short snd_atiixp_ac97_read(ac97_t *ac97, unsigned short reg)
{ {
atiixp_t *chip = ac97->private_data; atiixp_t *chip = ac97->private_data;
unsigned short data; return snd_atiixp_codec_read(chip, ac97->num, reg);
spin_lock(&chip->ac97_lock);
data = snd_atiixp_codec_read(chip, ac97->num, reg);
spin_unlock(&chip->ac97_lock);
return data;
} }
static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val)
{ {
atiixp_t *chip = ac97->private_data; atiixp_t *chip = ac97->private_data;
spin_lock(&chip->ac97_lock);
snd_atiixp_codec_write(chip, ac97->num, reg, val); snd_atiixp_codec_write(chip, ac97->num, reg, val);
spin_unlock(&chip->ac97_lock);
} }
/* /*
...@@ -1506,7 +1499,6 @@ static int __devinit snd_atiixp_create(snd_card_t *card, ...@@ -1506,7 +1499,6 @@ static int __devinit snd_atiixp_create(snd_card_t *card,
} }
spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->reg_lock);
spin_lock_init(&chip->ac97_lock);
init_MUTEX(&chip->open_mutex); init_MUTEX(&chip->open_mutex);
chip->card = card; chip->card = card;
chip->pci = pci; chip->pci = pci;
......
...@@ -247,7 +247,6 @@ struct snd_atiixp { ...@@ -247,7 +247,6 @@ struct snd_atiixp {
ac97_t *ac97[NUM_ATI_CODECS]; ac97_t *ac97[NUM_ATI_CODECS];
spinlock_t reg_lock; spinlock_t reg_lock;
spinlock_t ac97_lock;
atiixp_dma_t dmas[NUM_ATI_DMAS]; atiixp_dma_t dmas[NUM_ATI_DMAS];
struct ac97_pcm *pcms[NUM_ATI_PCMS]; struct ac97_pcm *pcms[NUM_ATI_PCMS];
...@@ -457,20 +456,14 @@ static void snd_atiixp_codec_write(atiixp_t *chip, unsigned short codec, unsigne ...@@ -457,20 +456,14 @@ static void snd_atiixp_codec_write(atiixp_t *chip, unsigned short codec, unsigne
static unsigned short snd_atiixp_ac97_read(ac97_t *ac97, unsigned short reg) static unsigned short snd_atiixp_ac97_read(ac97_t *ac97, unsigned short reg)
{ {
atiixp_t *chip = ac97->private_data; atiixp_t *chip = ac97->private_data;
unsigned short data; return snd_atiixp_codec_read(chip, ac97->num, reg);
spin_lock(&chip->ac97_lock);
data = snd_atiixp_codec_read(chip, ac97->num, reg);
spin_unlock(&chip->ac97_lock);
return data;
} }
static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) static void snd_atiixp_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val)
{ {
atiixp_t *chip = ac97->private_data; atiixp_t *chip = ac97->private_data;
spin_lock(&chip->ac97_lock);
snd_atiixp_codec_write(chip, ac97->num, reg, val); snd_atiixp_codec_write(chip, ac97->num, reg, val);
spin_unlock(&chip->ac97_lock);
} }
/* /*
...@@ -1228,7 +1221,6 @@ static int __devinit snd_atiixp_create(snd_card_t *card, ...@@ -1228,7 +1221,6 @@ static int __devinit snd_atiixp_create(snd_card_t *card,
} }
spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->reg_lock);
spin_lock_init(&chip->ac97_lock);
init_MUTEX(&chip->open_mutex); init_MUTEX(&chip->open_mutex);
chip->card = card; chip->card = card;
chip->pci = pci; chip->pci = pci;
......
...@@ -573,24 +573,18 @@ static void snd_es1370_codec_write(ak4531_t *ak4531, ...@@ -573,24 +573,18 @@ static void snd_es1370_codec_write(ak4531_t *ak4531,
unsigned short reg, unsigned short val) unsigned short reg, unsigned short val)
{ {
ensoniq_t *ensoniq = ak4531->private_data; ensoniq_t *ensoniq = ak4531->private_data;
unsigned long flags;
unsigned long end_time = jiffies + HZ / 10; unsigned long end_time = jiffies + HZ / 10;
#if 0 #if 0
printk("CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n", reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC)); printk("CODEC WRITE: reg = 0x%x, val = 0x%x (0x%x), creg = 0x%x\n", reg, val, ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC));
#endif #endif
do { do {
spin_lock_irqsave(&ensoniq->reg_lock, flags);
if (!(inl(ES_REG(ensoniq, STATUS)) & ES_1370_CSTAT)) { if (!(inl(ES_REG(ensoniq, STATUS)) & ES_1370_CSTAT)) {
outw(ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC)); outw(ES_1370_CODEC_WRITE(reg, val), ES_REG(ensoniq, 1370_CODEC));
spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
return; return;
} }
spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
#if 0
set_current_state(TASK_UNINTERRUPTIBLE); set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(1); schedule_timeout(1);
#endif
} while (time_after(end_time, jiffies)); } while (time_after(end_time, jiffies));
snd_printk("codec write timeout, status = 0x%x\n", inl(ES_REG(ensoniq, STATUS))); snd_printk("codec write timeout, status = 0x%x\n", inl(ES_REG(ensoniq, STATUS)));
} }
...@@ -603,11 +597,10 @@ static void snd_es1371_codec_write(ac97_t *ac97, ...@@ -603,11 +597,10 @@ static void snd_es1371_codec_write(ac97_t *ac97,
unsigned short reg, unsigned short val) unsigned short reg, unsigned short val)
{ {
ensoniq_t *ensoniq = ac97->private_data; ensoniq_t *ensoniq = ac97->private_data;
unsigned long flags;
unsigned int t, x; unsigned int t, x;
down(&ensoniq->src_mutex);
for (t = 0; t < POLL_COUNT; t++) { for (t = 0; t < POLL_COUNT; t++) {
spin_lock_irqsave(&ensoniq->reg_lock, flags);
if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) { if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) {
/* save the current state for latter */ /* save the current state for latter */
x = snd_es1371_wait_src_ready(ensoniq); x = snd_es1371_wait_src_ready(ensoniq);
...@@ -629,11 +622,11 @@ static void snd_es1371_codec_write(ac97_t *ac97, ...@@ -629,11 +622,11 @@ static void snd_es1371_codec_write(ac97_t *ac97,
/* restore SRC reg */ /* restore SRC reg */
snd_es1371_wait_src_ready(ensoniq); snd_es1371_wait_src_ready(ensoniq);
outl(x, ES_REG(ensoniq, 1371_SMPRATE)); outl(x, ES_REG(ensoniq, 1371_SMPRATE));
spin_unlock_irqrestore(&ensoniq->reg_lock, flags); up(&ensoniq->src_mutex);
return; return;
} }
spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
} }
up(&ensoniq->src_mutex);
snd_printk("codec write timeout at 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); snd_printk("codec write timeout at 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC)));
} }
...@@ -641,12 +634,11 @@ static unsigned short snd_es1371_codec_read(ac97_t *ac97, ...@@ -641,12 +634,11 @@ static unsigned short snd_es1371_codec_read(ac97_t *ac97,
unsigned short reg) unsigned short reg)
{ {
ensoniq_t *ensoniq = ac97->private_data; ensoniq_t *ensoniq = ac97->private_data;
unsigned long flags;
unsigned int t, x, fail = 0; unsigned int t, x, fail = 0;
__again: __again:
down(&ensoniq->src_mutex);
for (t = 0; t < POLL_COUNT; t++) { for (t = 0; t < POLL_COUNT; t++) {
spin_lock_irqsave(&ensoniq->reg_lock, flags);
if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) { if (!(inl(ES_REG(ensoniq, 1371_CODEC)) & ES_1371_CODEC_WIP)) {
/* save the current state for latter */ /* save the current state for latter */
x = snd_es1371_wait_src_ready(ensoniq); x = snd_es1371_wait_src_ready(ensoniq);
...@@ -676,19 +668,19 @@ static unsigned short snd_es1371_codec_read(ac97_t *ac97, ...@@ -676,19 +668,19 @@ static unsigned short snd_es1371_codec_read(ac97_t *ac97,
/* now wait for the stinkin' data (RDY) */ /* now wait for the stinkin' data (RDY) */
for (t = 0; t < POLL_COUNT; t++) { for (t = 0; t < POLL_COUNT; t++) {
if ((x = inl(ES_REG(ensoniq, 1371_CODEC))) & ES_1371_CODEC_RDY) { if ((x = inl(ES_REG(ensoniq, 1371_CODEC))) & ES_1371_CODEC_RDY) {
spin_unlock_irqrestore(&ensoniq->reg_lock, flags); up(&ensoniq->src_mutex);
return ES_1371_CODEC_READ(x); return ES_1371_CODEC_READ(x);
} }
} }
spin_unlock_irqrestore(&ensoniq->reg_lock, flags); up(&ensoniq->src_mutex);
if (++fail > 10) { if (++fail > 10) {
snd_printk("codec read timeout (final) at 0x%lx, reg = 0x%x [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), reg, inl(ES_REG(ensoniq, 1371_CODEC))); snd_printk("codec read timeout (final) at 0x%lx, reg = 0x%x [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), reg, inl(ES_REG(ensoniq, 1371_CODEC)));
return 0; return 0;
} }
goto __again; goto __again;
} }
spin_unlock_irqrestore(&ensoniq->reg_lock, flags);
} }
up(&ensoniq->src_mutex);
snd_printk("es1371: codec read timeout at 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC))); snd_printk("es1371: codec read timeout at 0x%lx [0x%x]\n", ES_REG(ensoniq, 1371_CODEC), inl(ES_REG(ensoniq, 1371_CODEC)));
return 0; return 0;
} }
......
...@@ -422,7 +422,6 @@ struct _snd_intel8x0 { ...@@ -422,7 +422,6 @@ struct _snd_intel8x0 {
unsigned int ac97_sdin[3]; unsigned int ac97_sdin[3];
spinlock_t reg_lock; spinlock_t reg_lock;
spinlock_t ac97_lock;
u32 bdbars_count; u32 bdbars_count;
struct snd_dma_buffer bdbars; struct snd_dma_buffer bdbars;
...@@ -590,13 +589,11 @@ static void snd_intel8x0_codec_write(ac97_t *ac97, ...@@ -590,13 +589,11 @@ static void snd_intel8x0_codec_write(ac97_t *ac97,
{ {
intel8x0_t *chip = ac97->private_data; intel8x0_t *chip = ac97->private_data;
spin_lock(&chip->ac97_lock);
if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) { if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) {
if (! chip->in_ac97_init) if (! chip->in_ac97_init)
snd_printk("codec_write %d: semaphore is not ready for register 0x%x\n", ac97->num, reg); snd_printk("codec_write %d: semaphore is not ready for register 0x%x\n", ac97->num, reg);
} }
iaputword(chip, reg + ac97->num * 0x80, val); iaputword(chip, reg + ac97->num * 0x80, val);
spin_unlock(&chip->ac97_lock);
} }
static unsigned short snd_intel8x0_codec_read(ac97_t *ac97, static unsigned short snd_intel8x0_codec_read(ac97_t *ac97,
...@@ -606,7 +603,6 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97, ...@@ -606,7 +603,6 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97,
unsigned short res; unsigned short res;
unsigned int tmp; unsigned int tmp;
spin_lock(&chip->ac97_lock);
if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) { if (snd_intel8x0_codec_semaphore(chip, ac97->num) < 0) {
if (! chip->in_ac97_init) if (! chip->in_ac97_init)
snd_printk("codec_read %d: semaphore is not ready for register 0x%x\n", ac97->num, reg); snd_printk("codec_read %d: semaphore is not ready for register 0x%x\n", ac97->num, reg);
...@@ -621,7 +617,6 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97, ...@@ -621,7 +617,6 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97,
res = 0xffff; res = 0xffff;
} }
} }
spin_unlock(&chip->ac97_lock);
return res; return res;
} }
...@@ -629,7 +624,6 @@ static void snd_intel8x0_codec_read_test(intel8x0_t *chip, unsigned int codec) ...@@ -629,7 +624,6 @@ static void snd_intel8x0_codec_read_test(intel8x0_t *chip, unsigned int codec)
{ {
unsigned int tmp; unsigned int tmp;
spin_lock(&chip->ac97_lock);
if (snd_intel8x0_codec_semaphore(chip, codec) >= 0) { if (snd_intel8x0_codec_semaphore(chip, codec) >= 0) {
iagetword(chip, codec * 0x80); iagetword(chip, codec * 0x80);
if ((tmp = igetdword(chip, ICHREG(GLOB_STA))) & ICH_RCS) { if ((tmp = igetdword(chip, ICHREG(GLOB_STA))) & ICH_RCS) {
...@@ -637,7 +631,6 @@ static void snd_intel8x0_codec_read_test(intel8x0_t *chip, unsigned int codec) ...@@ -637,7 +631,6 @@ static void snd_intel8x0_codec_read_test(intel8x0_t *chip, unsigned int codec)
iputdword(chip, ICHREG(GLOB_STA), tmp & ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI)); iputdword(chip, ICHREG(GLOB_STA), tmp & ~(ICH_SRI|ICH_PRI|ICH_TRI|ICH_GSCI));
} }
} }
spin_unlock(&chip->ac97_lock);
} }
/* /*
...@@ -670,7 +663,6 @@ static unsigned short snd_intel8x0_ali_codec_read(ac97_t *ac97, unsigned short r ...@@ -670,7 +663,6 @@ static unsigned short snd_intel8x0_ali_codec_read(ac97_t *ac97, unsigned short r
intel8x0_t *chip = ac97->private_data; intel8x0_t *chip = ac97->private_data;
unsigned short data = 0xffff; unsigned short data = 0xffff;
spin_lock(&chip->ac97_lock);
if (snd_intel8x0_ali_codec_semaphore(chip)) if (snd_intel8x0_ali_codec_semaphore(chip))
goto __err; goto __err;
reg |= ALI_CPR_ADDR_READ; reg |= ALI_CPR_ADDR_READ;
...@@ -681,7 +673,6 @@ static unsigned short snd_intel8x0_ali_codec_read(ac97_t *ac97, unsigned short r ...@@ -681,7 +673,6 @@ static unsigned short snd_intel8x0_ali_codec_read(ac97_t *ac97, unsigned short r
goto __err; goto __err;
data = igetword(chip, ICHREG(ALI_SPR)); data = igetword(chip, ICHREG(ALI_SPR));
__err: __err:
spin_unlock(&chip->ac97_lock);
return data; return data;
} }
...@@ -689,17 +680,13 @@ static void snd_intel8x0_ali_codec_write(ac97_t *ac97, unsigned short reg, unsig ...@@ -689,17 +680,13 @@ static void snd_intel8x0_ali_codec_write(ac97_t *ac97, unsigned short reg, unsig
{ {
intel8x0_t *chip = ac97->private_data; intel8x0_t *chip = ac97->private_data;
spin_lock(&chip->ac97_lock); if (snd_intel8x0_ali_codec_semaphore(chip))
if (snd_intel8x0_ali_codec_semaphore(chip)) {
spin_unlock(&chip->ac97_lock);
return; return;
}
iputword(chip, ICHREG(ALI_CPR), val); iputword(chip, ICHREG(ALI_CPR), val);
if (ac97->num) if (ac97->num)
reg |= ALI_CPR_ADDR_SECONDARY; reg |= ALI_CPR_ADDR_SECONDARY;
iputword(chip, ICHREG(ALI_CPR_ADDR), reg); iputword(chip, ICHREG(ALI_CPR_ADDR), reg);
snd_intel8x0_ali_codec_ready(chip, ALI_CSPSR_WRITE_OK); snd_intel8x0_ali_codec_ready(chip, ALI_CSPSR_WRITE_OK);
spin_unlock(&chip->ac97_lock);
} }
...@@ -2546,7 +2533,6 @@ static int __devinit snd_intel8x0_create(snd_card_t * card, ...@@ -2546,7 +2533,6 @@ static int __devinit snd_intel8x0_create(snd_card_t * card,
return -ENOMEM; return -ENOMEM;
} }
spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->reg_lock);
spin_lock_init(&chip->ac97_lock);
chip->device_type = device_type; chip->device_type = device_type;
chip->card = card; chip->card = card;
chip->pci = pci; chip->pci = pci;
......
...@@ -253,7 +253,6 @@ struct _snd_intel8x0m { ...@@ -253,7 +253,6 @@ struct _snd_intel8x0m {
ac97_t *ac97; ac97_t *ac97;
spinlock_t reg_lock; spinlock_t reg_lock;
spinlock_t ac97_lock;
struct snd_dma_buffer bdbars; struct snd_dma_buffer bdbars;
u32 bdbars_count; u32 bdbars_count;
...@@ -411,13 +410,11 @@ static void snd_intel8x0_codec_write(ac97_t *ac97, ...@@ -411,13 +410,11 @@ static void snd_intel8x0_codec_write(ac97_t *ac97,
{ {
intel8x0_t *chip = ac97->private_data; intel8x0_t *chip = ac97->private_data;
spin_lock(&chip->ac97_lock);
if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) { if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) {
if (! chip->in_ac97_init) if (! chip->in_ac97_init)
snd_printk("codec_write %d: semaphore is not ready for register 0x%x\n", ac97->num, reg); snd_printk("codec_write %d: semaphore is not ready for register 0x%x\n", ac97->num, reg);
} }
iaputword(chip, reg + ac97->num * 0x80, val); iaputword(chip, reg + ac97->num * 0x80, val);
spin_unlock(&chip->ac97_lock);
} }
static unsigned short snd_intel8x0_codec_read(ac97_t *ac97, static unsigned short snd_intel8x0_codec_read(ac97_t *ac97,
...@@ -427,7 +424,6 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97, ...@@ -427,7 +424,6 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97,
unsigned short res; unsigned short res;
unsigned int tmp; unsigned int tmp;
spin_lock(&chip->ac97_lock);
if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) { if (snd_intel8x0m_codec_semaphore(chip, ac97->num) < 0) {
if (! chip->in_ac97_init) if (! chip->in_ac97_init)
snd_printk("codec_read %d: semaphore is not ready for register 0x%x\n", ac97->num, reg); snd_printk("codec_read %d: semaphore is not ready for register 0x%x\n", ac97->num, reg);
...@@ -442,7 +438,6 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97, ...@@ -442,7 +438,6 @@ static unsigned short snd_intel8x0_codec_read(ac97_t *ac97,
res = 0xffff; res = 0xffff;
} }
} }
spin_unlock(&chip->ac97_lock);
return res; return res;
} }
...@@ -1177,7 +1172,6 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card, ...@@ -1177,7 +1172,6 @@ static int __devinit snd_intel8x0m_create(snd_card_t * card,
return -ENOMEM; return -ENOMEM;
} }
spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->reg_lock);
spin_lock_init(&chip->ac97_lock);
chip->device_type = device_type; chip->device_type = device_type;
chip->card = card; chip->card = card;
chip->pci = pci; chip->pci = pci;
......
...@@ -1835,34 +1835,24 @@ static unsigned short ...@@ -1835,34 +1835,24 @@ static unsigned short
snd_m3_ac97_read(ac97_t *ac97, unsigned short reg) snd_m3_ac97_read(ac97_t *ac97, unsigned short reg)
{ {
m3_t *chip = ac97->private_data; m3_t *chip = ac97->private_data;
unsigned short ret = 0;
unsigned long flags;
spin_lock_irqsave(&chip->reg_lock, flags);
if (snd_m3_ac97_wait(chip)) if (snd_m3_ac97_wait(chip))
goto __error; return 0xffff;
snd_m3_outb(chip, 0x80 | (reg & 0x7f), 0x30); snd_m3_outb(chip, 0x80 | (reg & 0x7f), CODEC_COMMAND);
if (snd_m3_ac97_wait(chip)) if (snd_m3_ac97_wait(chip))
goto __error; return 0xffff;
ret = snd_m3_inw(chip, 0x32); return snd_m3_inw(chip, CODEC_DATA);
__error:
spin_unlock_irqrestore(&chip->reg_lock, flags);
return ret;
} }
static void static void
snd_m3_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val) snd_m3_ac97_write(ac97_t *ac97, unsigned short reg, unsigned short val)
{ {
m3_t *chip = ac97->private_data; m3_t *chip = ac97->private_data;
unsigned long flags;
spin_lock_irqsave(&chip->reg_lock, flags);
if (snd_m3_ac97_wait(chip)) if (snd_m3_ac97_wait(chip))
goto __error; return;
snd_m3_outw(chip, val, 0x32); snd_m3_outw(chip, val, CODEC_DATA);
snd_m3_outb(chip, reg & 0x7f, 0x30); snd_m3_outb(chip, reg & 0x7f, CODEC_COMMAND);
__error:
spin_unlock_irqrestore(&chip->reg_lock, flags);
} }
......
...@@ -391,7 +391,6 @@ struct _snd_via82xx { ...@@ -391,7 +391,6 @@ struct _snd_via82xx {
unsigned int ac97_secondary; /* secondary AC'97 codec is present */ unsigned int ac97_secondary; /* secondary AC'97 codec is present */
spinlock_t reg_lock; spinlock_t reg_lock;
spinlock_t ac97_lock;
snd_info_entry_t *proc_entry; snd_info_entry_t *proc_entry;
#ifdef SUPPORT_JOYSTICK #ifdef SUPPORT_JOYSTICK
...@@ -564,10 +563,8 @@ static void snd_via82xx_codec_write(ac97_t *ac97, ...@@ -564,10 +563,8 @@ static void snd_via82xx_codec_write(ac97_t *ac97,
xval <<= VIA_REG_AC97_CODEC_ID_SHIFT; xval <<= VIA_REG_AC97_CODEC_ID_SHIFT;
xval |= reg << VIA_REG_AC97_CMD_SHIFT; xval |= reg << VIA_REG_AC97_CMD_SHIFT;
xval |= val << VIA_REG_AC97_DATA_SHIFT; xval |= val << VIA_REG_AC97_DATA_SHIFT;
spin_lock(&chip->ac97_lock);
snd_via82xx_codec_xwrite(chip, xval); snd_via82xx_codec_xwrite(chip, xval);
snd_via82xx_codec_ready(chip, ac97->num); snd_via82xx_codec_ready(chip, ac97->num);
spin_unlock(&chip->ac97_lock);
} }
static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg) static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg)
...@@ -580,10 +577,8 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg) ...@@ -580,10 +577,8 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg)
xval |= ac97->num ? VIA_REG_AC97_SECONDARY_VALID : VIA_REG_AC97_PRIMARY_VALID; xval |= ac97->num ? VIA_REG_AC97_SECONDARY_VALID : VIA_REG_AC97_PRIMARY_VALID;
xval |= VIA_REG_AC97_READ; xval |= VIA_REG_AC97_READ;
xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT; xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT;
spin_lock(&chip->ac97_lock);
while (1) { while (1) {
if (again++ > 3) { if (again++ > 3) {
spin_unlock(&chip->ac97_lock);
snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n", ac97->num, snd_via82xx_codec_xread(chip)); snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n", ac97->num, snd_via82xx_codec_xread(chip));
return 0xffff; return 0xffff;
} }
...@@ -595,7 +590,6 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg) ...@@ -595,7 +590,6 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg)
break; break;
} }
} }
spin_unlock(&chip->ac97_lock);
return val & 0xffff; return val & 0xffff;
} }
...@@ -2026,7 +2020,6 @@ static int __devinit snd_via82xx_create(snd_card_t * card, ...@@ -2026,7 +2020,6 @@ static int __devinit snd_via82xx_create(snd_card_t * card,
chip->revision = revision; chip->revision = revision;
spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->reg_lock);
spin_lock_init(&chip->ac97_lock);
spin_lock_init(&chip->rates[0].lock); spin_lock_init(&chip->rates[0].lock);
spin_lock_init(&chip->rates[1].lock); spin_lock_init(&chip->rates[1].lock);
chip->card = card; chip->card = card;
......
...@@ -260,7 +260,6 @@ struct _snd_via82xx_modem { ...@@ -260,7 +260,6 @@ struct _snd_via82xx_modem {
unsigned int ac97_secondary; /* secondary AC'97 codec is present */ unsigned int ac97_secondary; /* secondary AC'97 codec is present */
spinlock_t reg_lock; spinlock_t reg_lock;
spinlock_t ac97_lock;
snd_info_entry_t *proc_entry; snd_info_entry_t *proc_entry;
}; };
...@@ -426,10 +425,8 @@ static void snd_via82xx_codec_write(ac97_t *ac97, ...@@ -426,10 +425,8 @@ static void snd_via82xx_codec_write(ac97_t *ac97,
xval <<= VIA_REG_AC97_CODEC_ID_SHIFT; xval <<= VIA_REG_AC97_CODEC_ID_SHIFT;
xval |= reg << VIA_REG_AC97_CMD_SHIFT; xval |= reg << VIA_REG_AC97_CMD_SHIFT;
xval |= val << VIA_REG_AC97_DATA_SHIFT; xval |= val << VIA_REG_AC97_DATA_SHIFT;
spin_lock(&chip->ac97_lock);
snd_via82xx_codec_xwrite(chip, xval); snd_via82xx_codec_xwrite(chip, xval);
snd_via82xx_codec_ready(chip, ac97->num); snd_via82xx_codec_ready(chip, ac97->num);
spin_unlock(&chip->ac97_lock);
} }
static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg) static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg)
...@@ -442,10 +439,8 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg) ...@@ -442,10 +439,8 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg)
xval |= ac97->num ? VIA_REG_AC97_SECONDARY_VALID : VIA_REG_AC97_PRIMARY_VALID; xval |= ac97->num ? VIA_REG_AC97_SECONDARY_VALID : VIA_REG_AC97_PRIMARY_VALID;
xval |= VIA_REG_AC97_READ; xval |= VIA_REG_AC97_READ;
xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT; xval |= (reg & 0x7f) << VIA_REG_AC97_CMD_SHIFT;
spin_lock(&chip->ac97_lock);
while (1) { while (1) {
if (again++ > 3) { if (again++ > 3) {
spin_unlock(&chip->ac97_lock);
snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n", ac97->num, snd_via82xx_codec_xread(chip)); snd_printk(KERN_ERR "codec_read: codec %i is not valid [0x%x]\n", ac97->num, snd_via82xx_codec_xread(chip));
return 0xffff; return 0xffff;
} }
...@@ -457,7 +452,6 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg) ...@@ -457,7 +452,6 @@ static unsigned short snd_via82xx_codec_read(ac97_t *ac97, unsigned short reg)
break; break;
} }
} }
spin_unlock(&chip->ac97_lock);
return val & 0xffff; return val & 0xffff;
} }
...@@ -1124,7 +1118,6 @@ static int __devinit snd_via82xx_create(snd_card_t * card, ...@@ -1124,7 +1118,6 @@ static int __devinit snd_via82xx_create(snd_card_t * card,
} }
spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->reg_lock);
spin_lock_init(&chip->ac97_lock);
chip->card = card; chip->card = card;
chip->pci = pci; chip->pci = pci;
chip->irq = -1; chip->irq = -1;
......
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