static int snd_vt1724_pcm_hw_free(struct snd_pcm_substream *substream)
{
struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
+ bool released = false;
int i;
- guard(mutex)(&ice->open_mutex);
- /* unmark surround channels */
- for (i = 0; i < 3; i++)
- if (ice->pcm_reserved[i] == substream)
+ scoped_guard(mutex, &ice->open_mutex) {
+ /* unmark surround channels */
+ for (i = 0; i < 3; i++) {
+ if (ice->pcm_reserved[i] != substream)
+ continue;
ice->pcm_reserved[i] = NULL;
+ released = true;
+ }
+ }
+
+ if (released && ice->pcm_ds)
+ wake_up(&ice->pcm_ds->open_wait);
+
return 0;
}
scoped_guard(mutex, &ice->open_mutex) {
/* already used by PDMA0? */
if (ice->pcm_reserved[substream->number])
- return -EBUSY; /* FIXME: should handle blocking mode properly */
+ return -EAGAIN;
}
runtime->private_data = (void *)&vt1724_playback_dma_regs[substream->number];
ice->playback_con_substream_ds[substream->number] = substream;