Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01ae3b51 authored by Frank Schaefer's avatar Frank Schaefer Committed by Mauro Carvalho Chehab
Browse files

[media] em28xx-audio: fix user counting in snd_em28xx_capture_open()



dev->adev.users always needs to be increased when snd_em28xx_capture_open() is
called and succeeds.

Signed-off-by: default avatarFrank Schäfer <fschaefer.oss@googlemail.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 1d184b0b
Loading
Loading
Loading
Loading
+11 −11
Original line number Original line Diff line number Diff line
@@ -252,7 +252,7 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
{
{
	struct em28xx *dev = snd_pcm_substream_chip(substream);
	struct em28xx *dev = snd_pcm_substream_chip(substream);
	struct snd_pcm_runtime *runtime = substream->runtime;
	struct snd_pcm_runtime *runtime = substream->runtime;
	int ret = 0;
	int nonblock, ret = 0;


	if (!dev) {
	if (!dev) {
		em28xx_err("BUG: em28xx can't find device struct."
		em28xx_err("BUG: em28xx can't find device struct."
@@ -265,15 +265,15 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)


	dprintk("opening device and trying to acquire exclusive lock\n");
	dprintk("opening device and trying to acquire exclusive lock\n");


	runtime->hw = snd_em28xx_hw_capture;
	nonblock = !!(substream->f_flags & O_NONBLOCK);
	if ((dev->alt == 0 || dev->is_audio_only) && dev->adev.users == 0) {
		int nonblock = !!(substream->f_flags & O_NONBLOCK);

	if (nonblock) {
	if (nonblock) {
		if (!mutex_trylock(&dev->lock))
		if (!mutex_trylock(&dev->lock))
		return -EAGAIN;
		return -EAGAIN;
	} else
	} else
		mutex_lock(&dev->lock);
		mutex_lock(&dev->lock);

	runtime->hw = snd_em28xx_hw_capture;
	if ((dev->alt == 0 || dev->is_audio_only) && dev->adev.users == 0) {
		if (dev->is_audio_only)
		if (dev->is_audio_only)
			/* vendor audio is on a separate interface */
			/* vendor audio is on a separate interface */
			dev->alt = 1;
			dev->alt = 1;
@@ -299,10 +299,10 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
		ret = em28xx_audio_analog_set(dev);
		ret = em28xx_audio_analog_set(dev);
		if (ret < 0)
		if (ret < 0)
			goto err;
			goto err;
	}


	dev->adev.users++;
	dev->adev.users++;
	mutex_unlock(&dev->lock);
	mutex_unlock(&dev->lock);
	}


	/* Dynamically adjust the period size */
	/* Dynamically adjust the period size */
	snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
	snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);