Skip to content

Commit

Permalink
ALSA: pcm: Don't call register and disconnect callbacks for internal PCM
Browse files Browse the repository at this point in the history
The internal PCM (aka DPCM backend PCM) doesn't need any registration
procedure, thus currently we bail out immediately at dev_register
callback.  Similarly, its counterpart, dev_disconnect callback, is
superfluous for the internal PCM.  For simplifying and avoiding the
conflicting disconnect call for internal PCM objects, this patch drops
dev_register and dev_disconnect callbacks for the internal ops.

The only uncertain thing by this action is whether skipping the PCM
state change to SNDRV_PCM_STATE_DISCONNECT for the internal PCM is
mandatory.  Looking through the current implementations, this doesn't
look so, hence dropping the whole dev_disconnect would make more
sense.

Tested-by: Kuninori Morimoto <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Oct 18, 2017
1 parent c44027c commit 8b645e4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions sound/core/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,9 @@ static int _snd_pcm_new(struct snd_card *card, const char *id, int device,
.dev_register = snd_pcm_dev_register,
.dev_disconnect = snd_pcm_dev_disconnect,
};
static struct snd_device_ops internal_ops = {
.dev_free = snd_pcm_dev_free,
};

if (snd_BUG_ON(!card))
return -ENXIO;
Expand All @@ -801,7 +804,8 @@ static int _snd_pcm_new(struct snd_card *card, const char *id, int device,
if (err < 0)
goto free_pcm;

err = snd_device_new(card, SNDRV_DEV_PCM, pcm, &ops);
err = snd_device_new(card, SNDRV_DEV_PCM, pcm,
internal ? &internal_ops : &ops);
if (err < 0)
goto free_pcm;

Expand Down Expand Up @@ -1099,8 +1103,6 @@ static int snd_pcm_dev_register(struct snd_device *device)
if (snd_BUG_ON(!device || !device->device_data))
return -ENXIO;
pcm = device->device_data;
if (pcm->internal)
return 0;

mutex_lock(&register_mutex);
err = snd_pcm_add(pcm);
Expand Down Expand Up @@ -1159,12 +1161,10 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
snd_pcm_stream_unlock_irq(substream);
}
}
if (!pcm->internal) {
pcm_call_notify(pcm, n_disconnect);
}

pcm_call_notify(pcm, n_disconnect);
for (cidx = 0; cidx < 2; cidx++) {
if (!pcm->internal)
snd_unregister_device(&pcm->streams[cidx].dev);
snd_unregister_device(&pcm->streams[cidx].dev);
free_chmap(&pcm->streams[cidx]);
}
mutex_unlock(&pcm->open_mutex);
Expand Down

0 comments on commit 8b645e4

Please sign in to comment.