aboutsummaryrefslogtreecommitdiff
path: root/sound/usb/mixer.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-11-07 12:42:45 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-17 13:16:12 -0800
commit49e44e317fdb73d75a00a058df75a6b6fe172c08 (patch)
treeabeaf4b344a9f59e76fce60b7d129d7fa6a36582 /sound/usb/mixer.c
parent799c92f2aecb348e4a4c6dab80c7206e48caf201 (diff)
ALSA: usb-audio: Use rwsem for disconnect protection
commit 34f3c89fda4fba9fe689db22253ca8db2f5e6386 upstream. Replace mutex with rwsem for codec->shutdown protection so that concurrent accesses are allowed. Also add the protection to snd_usb_autosuspend() and snd_usb_autoresume(), too. Reported-by: Matthieu CASTET <matthieu.castet@parrot.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'sound/usb/mixer.c')
-rw-r--r--sound/usb/mixer.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index b3b63f76991..29ae209344d 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -292,7 +292,7 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int v
err = snd_usb_autoresume(cval->mixer->chip);
if (err < 0)
return -EIO;
- mutex_lock(&chip->shutdown_mutex);
+ down_read(&chip->shutdown_rwsem);
while (timeout-- > 0) {
if (chip->shutdown)
break;
@@ -310,7 +310,7 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int v
err = -EINVAL;
out:
- mutex_unlock(&chip->shutdown_mutex);
+ up_read(&chip->shutdown_rwsem);
snd_usb_autosuspend(cval->mixer->chip);
return err;
}
@@ -337,7 +337,7 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v
if (ret)
goto error;
- mutex_lock(&chip->shutdown_mutex);
+ down_read(&chip->shutdown_rwsem);
if (chip->shutdown)
ret = -ENODEV;
else {
@@ -346,7 +346,7 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
validx, idx, buf, size);
}
- mutex_unlock(&chip->shutdown_mutex);
+ up_read(&chip->shutdown_rwsem);
snd_usb_autosuspend(chip);
if (ret < 0) {
@@ -453,7 +453,7 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
err = snd_usb_autoresume(chip);
if (err < 0)
return -EIO;
- mutex_lock(&chip->shutdown_mutex);
+ down_read(&chip->shutdown_rwsem);
while (timeout-- > 0) {
if (chip->shutdown)
break;
@@ -471,7 +471,7 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
err = -EINVAL;
out:
- mutex_unlock(&chip->shutdown_mutex);
+ up_read(&chip->shutdown_rwsem);
snd_usb_autosuspend(chip);
return err;
}