]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: aloop: Use the new helper for stop-count refcount
authorTakashi Iwai <tiwai@suse.de>
Wed, 10 Jun 2026 15:45:34 +0000 (17:45 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 11 Jun 2026 07:34:09 +0000 (09:34 +0200)
Replace the open-code for managing the stop-count refcount with the
new helpers.
Only a code cleanup, no functional changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20260610154538.51076-5-tiwai@suse.de
sound/drivers/aloop.c

index 3f8488716a08275b90d1cd999f8b9883d6627973..06bfe09eae1a2423f624d8a6000aed4244346139 100644 (file)
@@ -100,8 +100,7 @@ struct loopback_cable {
        spinlock_t lock;
        struct loopback_pcm *streams[2];
        /* in-flight peer stops running outside cable->lock */
-       atomic_t stop_count;
-       wait_queue_head_t stop_wait;
+       struct snd_refcount stop_count;
        struct snd_pcm_hardware hw;
        /* flags */
        unsigned int valid;
@@ -371,7 +370,7 @@ static int loopback_check_format(struct loopback_cable *cable, int stream)
                                return -EIO;
                        else if (cruntime->state == SNDRV_PCM_STATE_RUNNING) {
                                /* close must not free the peer runtime below */
-                               atomic_inc(&cable->stop_count);
+                               snd_refcount_get(&cable->stop_count);
                                stop_capture = true;
                        }
                }
@@ -404,8 +403,7 @@ static int loopback_check_format(struct loopback_cable *cable, int stream)
 
        if (stop_capture) {
                snd_pcm_stop(dpcm_capt->substream, SNDRV_PCM_STATE_DRAINING);
-               if (atomic_dec_and_test(&cable->stop_count))
-                       wake_up(&cable->stop_wait);
+               snd_refcount_put(&cable->stop_count);
        }
 
        return 0;
@@ -1070,7 +1068,7 @@ static void free_cable(struct snd_pcm_substream *substream)
        }
 
        /* Pair with the stop_count increment in loopback_check_format(). */
-       wait_event(cable->stop_wait, !atomic_read(&cable->stop_count));
+       snd_refcount_sync(&cable->stop_count);
        if (other_alive)
                return;
 
@@ -1274,8 +1272,7 @@ static int loopback_open(struct snd_pcm_substream *substream)
                        goto unlock;
                }
                spin_lock_init(&cable->lock);
-               atomic_set(&cable->stop_count, 0);
-               init_waitqueue_head(&cable->stop_wait);
+               snd_refcount_init(&cable->stop_count);
                cable->hw = loopback_pcm_hardware;
                if (loopback->timer_source)
                        cable->ops = &loopback_snd_timer_ops;