aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
authorTakashi Iwai <tiwai@suse.de>2026-06-10 17:45:35 +0200
committerTakashi Iwai <tiwai@suse.de>2026-06-11 09:34:09 +0200
commitab8f7ffd63d5074c865935ad3720f0d995d2160f (patch)
tree8f191865b561960de95e05476336e9b4b6468895 /sound
parentc54888c1171e6a03b8325e03011cedc0a9781161 (diff)
downloadath-ab8f7ffd63d5074c865935ad3720f0d995d2160f.tar.gz
ALSA: usb-audio: Use the new helper for shutdown refcount
Replace the open-code for managing the shutdown 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-6-tiwai@suse.de
Diffstat (limited to 'sound')
-rw-r--r--sound/usb/card.c14
-rw-r--r--sound/usb/usbaudio.h5
2 files changed, 8 insertions, 11 deletions
diff --git a/sound/usb/card.c b/sound/usb/card.c
index f42d72cd03781..6a3b576fb0679 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -769,7 +769,6 @@ static int snd_usb_audio_create(struct usb_interface *intf,
chip = card->private_data;
mutex_init(&chip->mutex);
- init_waitqueue_head(&chip->shutdown_wait);
chip->index = idx;
chip->dev = dev;
chip->card = card;
@@ -778,7 +777,7 @@ static int snd_usb_audio_create(struct usb_interface *intf,
chip->autoclock = autoclock;
chip->lowlatency = lowlatency;
atomic_set(&chip->active, 1); /* avoid autopm during probing */
- atomic_set(&chip->usage_count, 0);
+ snd_refcount_init(&chip->usage_count);
atomic_set(&chip->shutdown, 0);
chip->usb_id = usb_id;
@@ -1107,8 +1106,7 @@ static bool __usb_audio_disconnect(struct usb_interface *intf,
/* wait until all pending tasks done;
* they are protected by snd_usb_lock_shutdown()
*/
- wait_event(chip->shutdown_wait,
- !atomic_read(&chip->usage_count));
+ snd_refcount_sync(&chip->usage_count);
snd_card_disconnect(card);
/* release the pcm resources */
list_for_each_entry(as, &chip->pcm_list, list) {
@@ -1166,7 +1164,7 @@ int snd_usb_lock_shutdown(struct snd_usb_audio *chip)
{
int err;
- atomic_inc(&chip->usage_count);
+ snd_refcount_get(&chip->usage_count);
if (atomic_read(&chip->shutdown)) {
err = -EIO;
goto error;
@@ -1177,8 +1175,7 @@ int snd_usb_lock_shutdown(struct snd_usb_audio *chip)
return 0;
error:
- if (atomic_dec_and_test(&chip->usage_count))
- wake_up(&chip->shutdown_wait);
+ snd_refcount_put(&chip->usage_count);
return err;
}
EXPORT_SYMBOL_GPL(snd_usb_lock_shutdown);
@@ -1187,8 +1184,7 @@ EXPORT_SYMBOL_GPL(snd_usb_lock_shutdown);
void snd_usb_unlock_shutdown(struct snd_usb_audio *chip)
{
snd_usb_autosuspend(chip);
- if (atomic_dec_and_test(&chip->usage_count))
- wake_up(&chip->shutdown_wait);
+ snd_refcount_put(&chip->usage_count);
}
EXPORT_SYMBOL_GPL(snd_usb_unlock_shutdown);
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
index e472aef6eb879..e26f9092417ed 100644
--- a/sound/usb/usbaudio.h
+++ b/sound/usb/usbaudio.h
@@ -7,6 +7,8 @@
* Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
*/
+#include <sound/core.h>
+
/* handling of USB vendor/product ID pairs as 32-bit numbers */
#define USB_ID(vendor, product) (((unsigned int)(vendor) << 16) | (product))
#define USB_ID_VENDOR(id) ((id) >> 16)
@@ -41,8 +43,7 @@ struct snd_usb_audio {
unsigned int system_suspend;
atomic_t active;
atomic_t shutdown;
- atomic_t usage_count;
- wait_queue_head_t shutdown_wait;
+ struct snd_refcount usage_count;
unsigned int quirk_flags;
unsigned int need_delayed_register:1; /* warn for delayed registration */
int num_interfaces;