From: Takashi Iwai Date: Wed, 10 Jun 2026 15:45:32 +0000 (+0200) Subject: ALSA: core: Use the new helper for the power refcount X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fa8d8b6c18b3443b65d42ced33bc9e36683e886;p=thirdparty%2Flinux.git ALSA: core: Use the new helper for the power refcount Replace the open code for managing the power refcount in the snd_card object with the new helper functions. Only a code cleanup, no functional changes. Signed-off-by: Takashi Iwai Link: https://patch.msgid.link/20260610154538.51076-3-tiwai@suse.de --- diff --git a/include/sound/core.h b/include/sound/core.h index a3f10294e834..404785b7d885 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -160,9 +160,8 @@ struct snd_card { #ifdef CONFIG_PM unsigned int power_state; /* power state */ - atomic_t power_ref; wait_queue_head_t power_sleep; - wait_queue_head_t power_ref_sleep; + struct snd_refcount power_ref; #endif #if IS_ENABLED(CONFIG_SND_MIXER_OSS) @@ -197,7 +196,7 @@ static inline void snd_power_change_state(struct snd_card *card, unsigned int st */ static inline void snd_power_ref(struct snd_card *card) { - atomic_inc(&card->power_ref); + snd_refcount_get(&card->power_ref); } /** @@ -206,8 +205,7 @@ static inline void snd_power_ref(struct snd_card *card) */ static inline void snd_power_unref(struct snd_card *card) { - if (atomic_dec_and_test(&card->power_ref)) - wake_up(&card->power_ref_sleep); + snd_refcount_put(&card->power_ref); } /** @@ -219,7 +217,7 @@ static inline void snd_power_unref(struct snd_card *card) */ static inline void snd_power_sync_ref(struct snd_card *card) { - wait_event(card->power_ref_sleep, !atomic_read(&card->power_ref)); + snd_refcount_sync(&card->power_ref); } /* init.c */ diff --git a/sound/core/init.c b/sound/core/init.c index 2408160b8ea1..ed5af4e0ec10 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -328,8 +328,7 @@ static int snd_card_init(struct snd_card *card, struct device *parent, mutex_init(&card->memory_mutex); #ifdef CONFIG_PM init_waitqueue_head(&card->power_sleep); - init_waitqueue_head(&card->power_ref_sleep); - atomic_set(&card->power_ref, 0); + snd_refcount_init(&card->power_ref); #endif init_waitqueue_head(&card->remove_sleep); card->sync_irq = -1;