chip = card->private_data;
mutex_init(&chip->mutex);
- init_waitqueue_head(&chip->shutdown_wait);
chip->index = idx;
chip->dev = dev;
chip->card = card;
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;
/* 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) {
{
int err;
- atomic_inc(&chip->usage_count);
+ snd_refcount_get(&chip->usage_count);
if (atomic_read(&chip->shutdown)) {
err = -EIO;
goto error;
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);
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);
* 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)
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;