]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: core: Use the new helper for the power refcount
authorTakashi Iwai <tiwai@suse.de>
Wed, 10 Jun 2026 15:45:32 +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 power refcount in the snd_card
object with the new helper functions.
Only a code cleanup, no functional changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20260610154538.51076-3-tiwai@suse.de
include/sound/core.h
sound/core/init.c

index a3f10294e834ea296b5c6ec748544d917122ee19..404785b7d885e672631d5281bae1574ebe91cfd0 100644 (file)
@@ -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 */
index 2408160b8ea13de33d43a581c38d1ff5ee38fd23..ed5af4e0ec1051685afff195864a9cb9c1fa7c75 100644 (file)
@@ -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;