/* check whether the card is already registered */
chip = NULL;
- mutex_lock(®ister_mutex);
+ guard(mutex)(®ister_mutex);
for (i = 0; i < SNDRV_CARDS; i++)
if (enable[i])
if (i >= SNDRV_CARDS) {
dev_err(&device->dev, "no available " CARD_NAME " audio device\n");
- ret = -ENODEV;
- goto err;
+ return -ENODEV;
}
ret = hiface_chip_create(intf, device, i, quirk, &chip);
if (ret < 0)
- goto err;
+ return ret;
ret = hiface_pcm_init(chip, quirk ? quirk->extra_freq : 0);
if (ret < 0)
goto err_chip_destroy;
}
- mutex_unlock(®ister_mutex);
-
usb_set_intfdata(intf, chip);
return 0;
err_chip_destroy:
snd_card_free(chip->card);
-err:
- mutex_unlock(®ister_mutex);
return ret;
}
if (rt->panic)
return -EPIPE;
- mutex_lock(&rt->stream_mutex);
+ guard(mutex)(&rt->stream_mutex);
alsa_rt->hw = pcm_hw;
if (alsa_sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
if (!sub) {
struct device *device = &rt->chip->dev->dev;
- mutex_unlock(&rt->stream_mutex);
dev_err(device, "Invalid stream type\n");
return -EINVAL;
}
ret = snd_pcm_hw_constraint_list(alsa_sub->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&constraints_extra_rates);
- if (ret < 0) {
- mutex_unlock(&rt->stream_mutex);
+ if (ret < 0)
return ret;
- }
}
sub->instance = alsa_sub;
sub->active = false;
- mutex_unlock(&rt->stream_mutex);
return 0;
}
if (rt->panic)
return 0;
- mutex_lock(&rt->stream_mutex);
+ guard(mutex)(&rt->stream_mutex);
if (sub) {
hiface_pcm_stream_stop(rt);
spin_unlock_irqrestore(&sub->lock, flags);
}
- mutex_unlock(&rt->stream_mutex);
return 0;
}
if (!sub)
return -ENODEV;
- mutex_lock(&rt->stream_mutex);
+ guard(mutex)(&rt->stream_mutex);
hiface_pcm_stream_stop(rt);
if (rt->stream_state == STREAM_DISABLED) {
ret = hiface_pcm_set_rate(rt, alsa_rt->rate);
- if (ret) {
- mutex_unlock(&rt->stream_mutex);
+ if (ret)
return ret;
- }
ret = hiface_pcm_stream_start(rt);
- if (ret) {
- mutex_unlock(&rt->stream_mutex);
+ if (ret)
return ret;
- }
}
- mutex_unlock(&rt->stream_mutex);
return 0;
}
if (rt) {
rt->panic = true;
- mutex_lock(&rt->stream_mutex);
+ guard(mutex)(&rt->stream_mutex);
hiface_pcm_stream_stop(rt);
- mutex_unlock(&rt->stream_mutex);
}
}