summaryrefslogtreecommitdiff
path: root/sound/pci/nm256/nm256.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/nm256/nm256.c')
-rw-r--r--sound/pci/nm256/nm256.c37
1 files changed, 12 insertions, 25 deletions
diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c
index 39464d171f6b..da74b923bc88 100644
--- a/sound/pci/nm256/nm256.c
+++ b/sound/pci/nm256/nm256.c
@@ -446,27 +446,25 @@ snd_nm256_set_format(struct nm256 *chip, struct nm256_stream *s,
/* acquire interrupt */
static int snd_nm256_acquire_irq(struct nm256 *chip)
{
- mutex_lock(&chip->irq_mutex);
+ guard(mutex)(&chip->irq_mutex);
if (chip->irq < 0) {
if (request_irq(chip->pci->irq, chip->interrupt, IRQF_SHARED,
KBUILD_MODNAME, chip)) {
dev_err(chip->card->dev,
"unable to grab IRQ %d\n", chip->pci->irq);
- mutex_unlock(&chip->irq_mutex);
return -EBUSY;
}
chip->irq = chip->pci->irq;
chip->card->sync_irq = chip->irq;
}
chip->irq_acks++;
- mutex_unlock(&chip->irq_mutex);
return 0;
}
/* release interrupt */
static void snd_nm256_release_irq(struct nm256 *chip)
{
- mutex_lock(&chip->irq_mutex);
+ guard(mutex)(&chip->irq_mutex);
if (chip->irq_acks > 0)
chip->irq_acks--;
if (chip->irq_acks == 0 && chip->irq >= 0) {
@@ -474,7 +472,6 @@ static void snd_nm256_release_irq(struct nm256 *chip)
chip->irq = -1;
chip->card->sync_irq = -1;
}
- mutex_unlock(&chip->irq_mutex);
}
/*
@@ -547,12 +544,11 @@ snd_nm256_playback_trigger(struct snd_pcm_substream *substream, int cmd)
{
struct nm256 *chip = snd_pcm_substream_chip(substream);
struct nm256_stream *s = substream->runtime->private_data;
- int err = 0;
if (snd_BUG_ON(!s))
return -ENXIO;
- spin_lock(&chip->reg_lock);
+ guard(spinlock)(&chip->reg_lock);
switch (cmd) {
case SNDRV_PCM_TRIGGER_RESUME:
s->suspended = 0;
@@ -573,11 +569,9 @@ snd_nm256_playback_trigger(struct snd_pcm_substream *substream, int cmd)
}
break;
default:
- err = -EINVAL;
- break;
+ return -EINVAL;
}
- spin_unlock(&chip->reg_lock);
- return err;
+ return 0;
}
static int
@@ -585,12 +579,11 @@ snd_nm256_capture_trigger(struct snd_pcm_substream *substream, int cmd)
{
struct nm256 *chip = snd_pcm_substream_chip(substream);
struct nm256_stream *s = substream->runtime->private_data;
- int err = 0;
if (snd_BUG_ON(!s))
return -ENXIO;
- spin_lock(&chip->reg_lock);
+ guard(spinlock)(&chip->reg_lock);
switch (cmd) {
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
@@ -607,11 +600,9 @@ snd_nm256_capture_trigger(struct snd_pcm_substream *substream, int cmd)
}
break;
default:
- err = -EINVAL;
- break;
+ return -EINVAL;
}
- spin_unlock(&chip->reg_lock);
- return err;
+ return 0;
}
@@ -631,10 +622,9 @@ static int snd_nm256_pcm_prepare(struct snd_pcm_substream *substream)
s->periods = substream->runtime->periods;
s->cur_period = 0;
- spin_lock_irq(&chip->reg_lock);
+ guard(spinlock_irq)(&chip->reg_lock);
s->running = 0;
snd_nm256_set_format(chip, s, substream);
- spin_unlock_irq(&chip->reg_lock);
return 0;
}
@@ -999,7 +989,7 @@ snd_nm256_interrupt(int irq, void *dev_id)
/* Rather boring; check for individual interrupts and process them. */
- spin_lock(&chip->reg_lock);
+ guard(spinlock)(&chip->reg_lock);
if (status & NM_PLAYBACK_INT) {
status &= ~NM_PLAYBACK_INT;
NM_ACK_INT(chip, NM_PLAYBACK_INT);
@@ -1038,7 +1028,6 @@ snd_nm256_interrupt(int irq, void *dev_id)
NM_ACK_INT(chip, status);
}
- spin_unlock(&chip->reg_lock);
return IRQ_HANDLED;
}
@@ -1065,7 +1054,7 @@ snd_nm256_interrupt_zx(int irq, void *dev_id)
/* Rather boring; check for individual interrupts and process them. */
- spin_lock(&chip->reg_lock);
+ guard(spinlock)(&chip->reg_lock);
if (status & NM2_PLAYBACK_INT) {
status &= ~NM2_PLAYBACK_INT;
NM2_ACK_INT(chip, NM2_PLAYBACK_INT);
@@ -1103,7 +1092,6 @@ snd_nm256_interrupt_zx(int irq, void *dev_id)
NM2_ACK_INT(chip, status);
}
- spin_unlock(&chip->reg_lock);
return IRQ_HANDLED;
}
@@ -1392,9 +1380,8 @@ static int nm256_resume(struct device *dev)
for (i = 0; i < 2; i++) {
struct nm256_stream *s = &chip->streams[i];
if (s->substream && s->suspended) {
- spin_lock_irq(&chip->reg_lock);
+ guard(spinlock_irq)(&chip->reg_lock);
snd_nm256_set_format(chip, s, s->substream);
- spin_unlock_irq(&chip->reg_lock);
}
}