summaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-08-26 10:20:59 +0200
committerTakashi Iwai <tiwai@suse.de>2015-08-26 15:40:18 +0200
commita6da499b76b1a75412f047ac388e9ffd69a5c55b (patch)
treebf1909a8394eb76613170abe24c32407fe4af597 /sound/usb
parent47ab154593827b1a8f0713a2b9dd445753d551d8 (diff)
downloadlinux-stable-a6da499b76b1a75412f047ac388e9ffd69a5c55b.tar.gz
linux-stable-a6da499b76b1a75412f047ac388e9ffd69a5c55b.tar.bz2
linux-stable-a6da499b76b1a75412f047ac388e9ffd69a5c55b.zip
ALSA: usb-audio: Replace probing flag with active refcount
We can use active refcount for preventing autopm during probe. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/card.c12
-rw-r--r--sound/usb/usbaudio.h1
2 files changed, 4 insertions, 9 deletions
diff --git a/sound/usb/card.c b/sound/usb/card.c
index b6621bcba2dc..73c5833e7657 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -371,7 +371,7 @@ static int snd_usb_audio_create(struct usb_interface *intf,
chip->card = card;
chip->setup = device_setup[idx];
chip->autoclock = autoclock;
- chip->probing = 1;
+ atomic_set(&chip->active, 1); /* avoid autopm during probing */
atomic_set(&chip->usage_count, 0);
atomic_set(&chip->shutdown, 0);
@@ -503,7 +503,7 @@ static int usb_audio_probe(struct usb_interface *intf,
goto __error;
}
chip = usb_chip[i];
- chip->probing = 1;
+ atomic_inc(&chip->active); /* avoid autopm */
break;
}
}
@@ -563,8 +563,8 @@ static int usb_audio_probe(struct usb_interface *intf,
usb_chip[chip->index] = chip;
chip->num_interfaces++;
- chip->probing = 0;
usb_set_intfdata(intf, chip);
+ atomic_dec(&chip->active);
mutex_unlock(&register_mutex);
return 0;
@@ -572,7 +572,7 @@ static int usb_audio_probe(struct usb_interface *intf,
if (chip) {
if (!chip->num_interfaces)
snd_card_free(chip->card);
- chip->probing = 0;
+ atomic_dec(&chip->active);
}
mutex_unlock(&register_mutex);
return err;
@@ -668,8 +668,6 @@ int snd_usb_autoresume(struct snd_usb_audio *chip)
{
if (atomic_read(&chip->shutdown))
return -EIO;
- if (chip->probing)
- return 0;
if (atomic_inc_return(&chip->active) == 1)
return usb_autopm_get_interface(chip->pm_intf);
return 0;
@@ -677,8 +675,6 @@ int snd_usb_autoresume(struct snd_usb_audio *chip)
void snd_usb_autosuspend(struct snd_usb_audio *chip)
{
- if (chip->probing)
- return;
if (atomic_dec_and_test(&chip->active))
usb_autopm_put_interface(chip->pm_intf);
}
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
index eb1ea7182cdd..33a176437e2e 100644
--- a/sound/usb/usbaudio.h
+++ b/sound/usb/usbaudio.h
@@ -37,7 +37,6 @@ struct snd_usb_audio {
struct usb_interface *pm_intf;
u32 usb_id;
struct mutex mutex;
- unsigned int probing:1;
unsigned int autosuspended:1;
atomic_t active;
atomic_t shutdown;