aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/mixer.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-10-15 06:16:02 -0400
committerTakashi Iwai <tiwai@suse.de>2012-10-30 06:07:00 -0400
commit34f3c89fda4fba9fe689db22253ca8db2f5e6386 (patch)
tree213e1b6e6ceaee42dc4f9ec74307794dc7a83b20 /sound/usb/mixer.c
parent978520b75f0a1ce82b17e1e8186417250de6d545 (diff)
ALSA: usb-audio: Use rwsem for disconnect protection
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> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
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 c2ef11ccd66a..298070e8f2d4 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
292 err = snd_usb_autoresume(cval->mixer->chip); 292 err = snd_usb_autoresume(cval->mixer->chip);
293 if (err < 0) 293 if (err < 0)
294 return -EIO; 294 return -EIO;
295 mutex_lock(&chip->shutdown_mutex); 295 down_read(&chip->shutdown_rwsem);
296 while (timeout-- > 0) { 296 while (timeout-- > 0) {
297 if (chip->shutdown) 297 if (chip->shutdown)
298 break; 298 break;
@@ -310,7 +310,7 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int v
310 err = -EINVAL; 310 err = -EINVAL;
311 311
312 out: 312 out:
313 mutex_unlock(&chip->shutdown_mutex); 313 up_read(&chip->shutdown_rwsem);
314 snd_usb_autosuspend(cval->mixer->chip); 314 snd_usb_autosuspend(cval->mixer->chip);
315 return err; 315 return err;
316} 316}
@@ -337,7 +337,7 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v
337 if (ret) 337 if (ret)
338 goto error; 338 goto error;
339 339
340 mutex_lock(&chip->shutdown_mutex); 340 down_read(&chip->shutdown_rwsem);
341 if (chip->shutdown) 341 if (chip->shutdown)
342 ret = -ENODEV; 342 ret = -ENODEV;
343 else { 343 else {
@@ -346,7 +346,7 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v
346 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 346 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
347 validx, idx, buf, size); 347 validx, idx, buf, size);
348 } 348 }
349 mutex_unlock(&chip->shutdown_mutex); 349 up_read(&chip->shutdown_rwsem);
350 snd_usb_autosuspend(chip); 350 snd_usb_autosuspend(chip);
351 351
352 if (ret < 0) { 352 if (ret < 0) {
@@ -453,7 +453,7 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
453 err = snd_usb_autoresume(chip); 453 err = snd_usb_autoresume(chip);
454 if (err < 0) 454 if (err < 0)
455 return -EIO; 455 return -EIO;
456 mutex_lock(&chip->shutdown_mutex); 456 down_read(&chip->shutdown_rwsem);
457 while (timeout-- > 0) { 457 while (timeout-- > 0) {
458 if (chip->shutdown) 458 if (chip->shutdown)
459 break; 459 break;
@@ -471,7 +471,7 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
471 err = -EINVAL; 471 err = -EINVAL;
472 472
473 out: 473 out:
474 mutex_unlock(&chip->shutdown_mutex); 474 up_read(&chip->shutdown_rwsem);
475 snd_usb_autosuspend(chip); 475 snd_usb_autosuspend(chip);
476 return err; 476 return err;
477} 477}