From: Takashi Iwai Date: Wed, 10 Jun 2026 15:45:34 +0000 (+0200) Subject: ALSA: aloop: Use the new helper for stop-count refcount X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c54888c1171e6a03b8325e03011cedc0a9781161;p=thirdparty%2Flinux.git ALSA: aloop: Use the new helper for stop-count refcount 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 Link: https://patch.msgid.link/20260610154538.51076-5-tiwai@suse.de --- diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c index 3f8488716a08..06bfe09eae1a 100644 --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -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;