aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/card.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/card.c')
-rw-r--r--sound/usb/card.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 561bb74fd36..282f0fc9fed 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -339,7 +339,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
339 } 339 }
340 340
341 mutex_init(&chip->mutex); 341 mutex_init(&chip->mutex);
342 mutex_init(&chip->shutdown_mutex); 342 init_rwsem(&chip->shutdown_rwsem);
343 chip->index = idx; 343 chip->index = idx;
344 chip->dev = dev; 344 chip->dev = dev;
345 chip->card = card; 345 chip->card = card;
@@ -560,7 +560,7 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
560 560
561 card = chip->card; 561 card = chip->card;
562 mutex_lock(&register_mutex); 562 mutex_lock(&register_mutex);
563 mutex_lock(&chip->shutdown_mutex); 563 down_write(&chip->shutdown_rwsem);
564 chip->shutdown = 1; 564 chip->shutdown = 1;
565 chip->num_interfaces--; 565 chip->num_interfaces--;
566 if (chip->num_interfaces <= 0) { 566 if (chip->num_interfaces <= 0) {
@@ -582,11 +582,11 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
582 snd_usb_mixer_disconnect(p); 582 snd_usb_mixer_disconnect(p);
583 } 583 }
584 usb_chip[chip->index] = NULL; 584 usb_chip[chip->index] = NULL;
585 mutex_unlock(&chip->shutdown_mutex); 585 up_write(&chip->shutdown_rwsem);
586 mutex_unlock(&register_mutex); 586 mutex_unlock(&register_mutex);
587 snd_card_free_when_closed(card); 587 snd_card_free_when_closed(card);
588 } else { 588 } else {
589 mutex_unlock(&chip->shutdown_mutex); 589 up_write(&chip->shutdown_rwsem);
590 mutex_unlock(&register_mutex); 590 mutex_unlock(&register_mutex);
591 } 591 }
592} 592}
@@ -618,16 +618,20 @@ int snd_usb_autoresume(struct snd_usb_audio *chip)
618{ 618{
619 int err = -ENODEV; 619 int err = -ENODEV;
620 620
621 down_read(&chip->shutdown_rwsem);
621 if (!chip->shutdown && !chip->probing) 622 if (!chip->shutdown && !chip->probing)
622 err = usb_autopm_get_interface(chip->pm_intf); 623 err = usb_autopm_get_interface(chip->pm_intf);
624 up_read(&chip->shutdown_rwsem);
623 625
624 return err; 626 return err;
625} 627}
626 628
627void snd_usb_autosuspend(struct snd_usb_audio *chip) 629void snd_usb_autosuspend(struct snd_usb_audio *chip)
628{ 630{
631 down_read(&chip->shutdown_rwsem);
629 if (!chip->shutdown && !chip->probing) 632 if (!chip->shutdown && !chip->probing)
630 usb_autopm_put_interface(chip->pm_intf); 633 usb_autopm_put_interface(chip->pm_intf);
634 up_read(&chip->shutdown_rwsem);
631} 635}
632 636
633static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) 637static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)