Merge tag 'topic/iomem-mmap-vs-gup-2021-02-22' of git://anongit.freedesktop.org/drm/drm
[linux-2.6-microblaze.git] / sound / core / pcm.c
index be5714f..b163164 100644 (file)
@@ -729,7 +729,7 @@ static int _snd_pcm_new(struct snd_card *card, const char *id, int device,
        init_waitqueue_head(&pcm->open_wait);
        INIT_LIST_HEAD(&pcm->list);
        if (id)
-               strlcpy(pcm->id, id, sizeof(pcm->id));
+               strscpy(pcm->id, id, sizeof(pcm->id));
 
        err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK,
                                 playback_count);
@@ -1095,22 +1095,23 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
        mutex_lock(&pcm->open_mutex);
        wake_up(&pcm->open_wait);
        list_del_init(&pcm->list);
-       for (cidx = 0; cidx < 2; cidx++) {
-               for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) {
-                       snd_pcm_stream_lock_irq(substream);
-                       if (substream->runtime) {
-                               if (snd_pcm_running(substream))
-                                       snd_pcm_stop(substream,
-                                                    SNDRV_PCM_STATE_DISCONNECTED);
-                               /* to be sure, set the state unconditionally */
-                               substream->runtime->status->state = SNDRV_PCM_STATE_DISCONNECTED;
-                               wake_up(&substream->runtime->sleep);
-                               wake_up(&substream->runtime->tsleep);
-                       }
-                       snd_pcm_stream_unlock_irq(substream);
+
+       for_each_pcm_substream(pcm, cidx, substream) {
+               snd_pcm_stream_lock_irq(substream);
+               if (substream->runtime) {
+                       if (snd_pcm_running(substream))
+                               snd_pcm_stop(substream, SNDRV_PCM_STATE_DISCONNECTED);
+                       /* to be sure, set the state unconditionally */
+                       substream->runtime->status->state = SNDRV_PCM_STATE_DISCONNECTED;
+                       wake_up(&substream->runtime->sleep);
+                       wake_up(&substream->runtime->tsleep);
                }
+               snd_pcm_stream_unlock_irq(substream);
        }
 
+       for_each_pcm_substream(pcm, cidx, substream)
+               snd_pcm_sync_stop(substream, false);
+
        pcm_call_notify(pcm, n_disconnect);
        for (cidx = 0; cidx < 2; cidx++) {
                snd_unregister_device(&pcm->streams[cidx].dev);