diff options
author | Takashi Iwai <tiwai@suse.de> | 2015-08-26 04:20:59 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-08-26 09:40:18 -0400 |
commit | a6da499b76b1a75412f047ac388e9ffd69a5c55b (patch) | |
tree | bf1909a8394eb76613170abe24c32407fe4af597 | |
parent | 47ab154593827b1a8f0713a2b9dd445753d551d8 (diff) |
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>
-rw-r--r-- | sound/usb/card.c | 12 | ||||
-rw-r--r-- | sound/usb/usbaudio.h | 1 |
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, | |||
371 | chip->card = card; | 371 | chip->card = card; |
372 | chip->setup = device_setup[idx]; | 372 | chip->setup = device_setup[idx]; |
373 | chip->autoclock = autoclock; | 373 | chip->autoclock = autoclock; |
374 | chip->probing = 1; | 374 | atomic_set(&chip->active, 1); /* avoid autopm during probing */ |
375 | atomic_set(&chip->usage_count, 0); | 375 | atomic_set(&chip->usage_count, 0); |
376 | atomic_set(&chip->shutdown, 0); | 376 | atomic_set(&chip->shutdown, 0); |
377 | 377 | ||
@@ -503,7 +503,7 @@ static int usb_audio_probe(struct usb_interface *intf, | |||
503 | goto __error; | 503 | goto __error; |
504 | } | 504 | } |
505 | chip = usb_chip[i]; | 505 | chip = usb_chip[i]; |
506 | chip->probing = 1; | 506 | atomic_inc(&chip->active); /* avoid autopm */ |
507 | break; | 507 | break; |
508 | } | 508 | } |
509 | } | 509 | } |
@@ -563,8 +563,8 @@ static int usb_audio_probe(struct usb_interface *intf, | |||
563 | 563 | ||
564 | usb_chip[chip->index] = chip; | 564 | usb_chip[chip->index] = chip; |
565 | chip->num_interfaces++; | 565 | chip->num_interfaces++; |
566 | chip->probing = 0; | ||
567 | usb_set_intfdata(intf, chip); | 566 | usb_set_intfdata(intf, chip); |
567 | atomic_dec(&chip->active); | ||
568 | mutex_unlock(®ister_mutex); | 568 | mutex_unlock(®ister_mutex); |
569 | return 0; | 569 | return 0; |
570 | 570 | ||
@@ -572,7 +572,7 @@ static int usb_audio_probe(struct usb_interface *intf, | |||
572 | if (chip) { | 572 | if (chip) { |
573 | if (!chip->num_interfaces) | 573 | if (!chip->num_interfaces) |
574 | snd_card_free(chip->card); | 574 | snd_card_free(chip->card); |
575 | chip->probing = 0; | 575 | atomic_dec(&chip->active); |
576 | } | 576 | } |
577 | mutex_unlock(®ister_mutex); | 577 | mutex_unlock(®ister_mutex); |
578 | return err; | 578 | return err; |
@@ -668,8 +668,6 @@ int snd_usb_autoresume(struct snd_usb_audio *chip) | |||
668 | { | 668 | { |
669 | if (atomic_read(&chip->shutdown)) | 669 | if (atomic_read(&chip->shutdown)) |
670 | return -EIO; | 670 | return -EIO; |
671 | if (chip->probing) | ||
672 | return 0; | ||
673 | if (atomic_inc_return(&chip->active) == 1) | 671 | if (atomic_inc_return(&chip->active) == 1) |
674 | return usb_autopm_get_interface(chip->pm_intf); | 672 | return usb_autopm_get_interface(chip->pm_intf); |
675 | return 0; | 673 | return 0; |
@@ -677,8 +675,6 @@ int snd_usb_autoresume(struct snd_usb_audio *chip) | |||
677 | 675 | ||
678 | void snd_usb_autosuspend(struct snd_usb_audio *chip) | 676 | void snd_usb_autosuspend(struct snd_usb_audio *chip) |
679 | { | 677 | { |
680 | if (chip->probing) | ||
681 | return; | ||
682 | if (atomic_dec_and_test(&chip->active)) | 678 | if (atomic_dec_and_test(&chip->active)) |
683 | usb_autopm_put_interface(chip->pm_intf); | 679 | usb_autopm_put_interface(chip->pm_intf); |
684 | } | 680 | } |
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 { | |||
37 | struct usb_interface *pm_intf; | 37 | struct usb_interface *pm_intf; |
38 | u32 usb_id; | 38 | u32 usb_id; |
39 | struct mutex mutex; | 39 | struct mutex mutex; |
40 | unsigned int probing:1; | ||
41 | unsigned int autosuspended:1; | 40 | unsigned int autosuspended:1; |
42 | atomic_t active; | 41 | atomic_t active; |
43 | atomic_t shutdown; | 42 | atomic_t shutdown; |