dev_dbg(codec->card->dev, "alloc_voice: type=%d rec=%d\n", type, rec);
- spin_lock_irq(&codec->voice_alloc);
+ guard(spinlock_irq)(&codec->voice_alloc);
if (type == SNDRV_ALI_VOICE_TYPE_PCM) {
idx = channel > 0 ? snd_ali_alloc_pcm_channel(codec, channel) :
snd_ali_find_free_channel(codec,rec);
if (idx < 0) {
dev_err(codec->card->dev, "ali_alloc_voice: err.\n");
- spin_unlock_irq(&codec->voice_alloc);
return NULL;
}
pvoice = &(codec->synth.voices[idx]);
pvoice->use = 1;
pvoice->pcm = 1;
pvoice->mode = rec;
- spin_unlock_irq(&codec->voice_alloc);
return pvoice;
}
- spin_unlock_irq(&codec->voice_alloc);
return NULL;
}
if (!pvoice->use)
return;
snd_ali_clear_voices(codec, pvoice->number, pvoice->number);
- spin_lock_irq(&codec->voice_alloc);
- private_free = pvoice->private_free;
- private_data = pvoice->private_data;
- pvoice->private_free = NULL;
- pvoice->private_data = NULL;
- if (pvoice->pcm)
- snd_ali_free_channel_pcm(codec, pvoice->number);
- pvoice->use = pvoice->pcm = pvoice->synth = 0;
- pvoice->substream = NULL;
- spin_unlock_irq(&codec->voice_alloc);
+ scoped_guard(spinlock_irq, &codec->voice_alloc) {
+ private_free = pvoice->private_free;
+ private_data = pvoice->private_data;
+ pvoice->private_free = NULL;
+ pvoice->private_data = NULL;
+ if (pvoice->pcm)
+ snd_ali_free_channel_pcm(codec, pvoice->number);
+ pvoice->use = pvoice->pcm = pvoice->synth = 0;
+ pvoice->substream = NULL;
+ }
if (private_free)
private_free(private_data);
}
snd_pcm_trigger_done(s, substream);
}
}
- spin_lock(&codec->reg_lock);
+ guard(spinlock)(&codec->reg_lock);
if (!do_start)
outl(what, ALI_REG(codec, ALI_STOP));
val = inl(ALI_REG(codec, ALI_AINTEN));
if (do_start)
outl(what, ALI_REG(codec, ALI_START));
dev_dbg(codec->card->dev, "trigger: what=%xh whati=%xh\n", what, whati);
- spin_unlock(&codec->reg_lock);
return 0;
}
dev_dbg(codec->card->dev, "playback_prepare ...\n");
- spin_lock_irq(&codec->reg_lock);
-
+ guard(spinlock_irq)(&codec->reg_lock);
+
/* set Delta (rate) value */
Delta = snd_ali_convert_rate(runtime->rate, 0);
CTRL,
EC);
}
- spin_unlock_irq(&codec->reg_lock);
return 0;
}
struct snd_ali_voice *pvoice = runtime->private_data;
unsigned int cso;
- spin_lock(&codec->reg_lock);
- if (!pvoice->running) {
- spin_unlock(&codec->reg_lock);
+ guard(spinlock)(&codec->reg_lock);
+ if (!pvoice->running)
return 0;
- }
outb(pvoice->number, ALI_REG(codec, ALI_GC_CIR));
cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2));
- spin_unlock(&codec->reg_lock);
dev_dbg(codec->card->dev, "playback pointer returned cso=%xh.\n", cso);
cso %= runtime->buffer_size;
struct snd_ali_voice *pvoice = runtime->private_data;
unsigned int cso;
- spin_lock(&codec->reg_lock);
- if (!pvoice->running) {
- spin_unlock(&codec->reg_lock);
+ guard(spinlock)(&codec->reg_lock);
+ if (!pvoice->running)
return 0;
- }
outb(pvoice->number, ALI_REG(codec, ALI_GC_CIR));
cso = inw(ALI_REG(codec, ALI_CSO_ALPHA_FMS + 2));
- spin_unlock(&codec->reg_lock);
cso %= runtime->buffer_size;
return cso;
spdif_enable = ucontrol->value.integer.value[0] ? 1 : 0;
- spin_lock_irq(&codec->reg_lock);
+ guard(spinlock_irq)(&codec->reg_lock);
switch (kcontrol->private_value) {
case 0:
spdif_enable = (codec->spdif_mask & 0x02) ? 1 : 0;
break;
}
ucontrol->value.integer.value[0] = spdif_enable;
- spin_unlock_irq(&codec->reg_lock);
return 0;
}
spdif_enable = ucontrol->value.integer.value[0] ? 1 : 0;
- spin_lock_irq(&codec->reg_lock);
+ guard(spinlock_irq)(&codec->reg_lock);
switch (kcontrol->private_value) {
case 0:
change = (codec->spdif_mask & 0x02) ? 1 : 0;
default:
break;
}
- spin_unlock_irq(&codec->reg_lock);
return change;
}
for (i = 0; i < chip->num_of_codecs; i++)
snd_ac97_suspend(chip->ac97[i]);
- spin_lock_irq(&chip->reg_lock);
+ guard(spinlock_irq)(&chip->reg_lock);
im->regs[ALI_MISCINT >> 2] = inl(ALI_REG(chip, ALI_MISCINT));
/* im->regs[ALI_START >> 2] = inl(ALI_REG(chip, ALI_START)); */
/* stop all HW channel */
outl(0xffffffff, ALI_REG(chip, ALI_STOP));
- spin_unlock_irq(&chip->reg_lock);
return 0;
}
struct snd_ali_image *im = &chip->image;
int i, j;
- spin_lock_irq(&chip->reg_lock);
-
- for (i = 0; i < ALI_CHANNELS; i++) {
- outb(i, ALI_REG(chip, ALI_GC_CIR));
- for (j = 0; j < ALI_CHANNEL_REGS; j++)
- outl(im->channel_regs[i][j], ALI_REG(chip, j*4 + 0xe0));
- }
+ scoped_guard(spinlock_irq, &chip->reg_lock) {
+ for (i = 0; i < ALI_CHANNELS; i++) {
+ outb(i, ALI_REG(chip, ALI_GC_CIR));
+ for (j = 0; j < ALI_CHANNEL_REGS; j++)
+ outl(im->channel_regs[i][j], ALI_REG(chip, j*4 + 0xe0));
+ }
- for (i = 0; i < ALI_GLOBAL_REGS; i++) {
- if ((i*4 == ALI_MISCINT) || (i*4 == ALI_STOP) ||
- (i*4 == ALI_START))
- continue;
- outl(im->regs[i], ALI_REG(chip, i*4));
+ for (i = 0; i < ALI_GLOBAL_REGS; i++) {
+ if ((i*4 == ALI_MISCINT) || (i*4 == ALI_STOP) ||
+ (i*4 == ALI_START))
+ continue;
+ outl(im->regs[i], ALI_REG(chip, i*4));
+ }
+
+ /* start HW channel */
+ outl(im->regs[ALI_START >> 2], ALI_REG(chip, ALI_START));
+ /* restore IRQ enable bits */
+ outl(im->regs[ALI_MISCINT >> 2], ALI_REG(chip, ALI_MISCINT));
}
-
- /* start HW channel */
- outl(im->regs[ALI_START >> 2], ALI_REG(chip, ALI_START));
- /* restore IRQ enable bits */
- outl(im->regs[ALI_MISCINT >> 2], ALI_REG(chip, ALI_MISCINT));
-
- spin_unlock_irq(&chip->reg_lock);
for (i = 0 ; i < chip->num_of_codecs; i++)
snd_ac97_resume(chip->ac97[i]);