public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Wan ZongShun <mcuos.com@gmail.com>,
	alsa-devel@alsa-project.org
Subject: [RFC][PATCH 4/5] ASoC: Fix missing spin_unlock_irqrestore
Date: Mon, 29 Nov 2010 17:42:47 +0800	[thread overview]
Message-ID: <1291023767.22911.9.camel@mola> (raw)
In-Reply-To: <1291023491.22911.1.camel@mola>

In nuc900_dma_hw_params(), if snd_pcm_lib_malloc_pages failed
it returns without calling spin_unlock_irqrestore().

Since snd_pcm_lib_malloc_pages() does not touch struct nuc900_audio,
we don't need to hold the lock while calling snd_pcm_lib_malloc_pages().
Fix it by moving spin_lock_irqsave() down to after snd_pcm_lib_malloc_pages().

In nuc900_dma_prepare(), spin_unlock_irqrestore() is missing in the error path.
Fix it by removing the return in default case.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---

hi ZongShun,
I don't have this hardware handy, could you help to test this patch
if you think this patch is ok.

Regards,
Axel

 sound/soc/nuc900/nuc900-pcm.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/sound/soc/nuc900/nuc900-pcm.c b/sound/soc/nuc900/nuc900-pcm.c
index 2245f8b..8263f56 100644
--- a/sound/soc/nuc900/nuc900-pcm.c
+++ b/sound/soc/nuc900/nuc900-pcm.c
@@ -50,12 +50,12 @@ static int nuc900_dma_hw_params(struct snd_pcm_substream *substream,
 	unsigned long flags;
 	int ret = 0;
 
-	spin_lock_irqsave(&nuc900_audio->lock, flags);
-
 	ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
 	if (ret < 0)
 		return ret;
 
+	spin_lock_irqsave(&nuc900_audio->lock, flags);
+
 	nuc900_audio->substream = substream;
 	nuc900_audio->dma_addr[substream->stream] = runtime->dma_addr;
 	nuc900_audio->buffersize[substream->stream] =
@@ -169,6 +169,7 @@ static int nuc900_dma_prepare(struct snd_pcm_substream *substream)
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct nuc900_audio *nuc900_audio = runtime->private_data;
 	unsigned long flags, val;
+	int ret = 0;
 
 	spin_lock_irqsave(&nuc900_audio->lock, flags);
 
@@ -197,10 +198,10 @@ static int nuc900_dma_prepare(struct snd_pcm_substream *substream)
 		AUDIO_WRITE(nuc900_audio->mmio + ACTL_RESET, val);
 		break;
 	default:
-		return -EINVAL;
+		ret = -EINVAL;
 	}
 	spin_unlock_irqrestore(&nuc900_audio->lock, flags);
-	return 0;
+	return ret;
 }
 
 static int nuc900_dma_trigger(struct snd_pcm_substream *substream, int cmd)
-- 
1.7.2




  parent reply	other threads:[~2010-11-29  9:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-29  9:38 [PATCH 0/5] Fix compile error and missing spin_unlock_irqrestore for NUC900 SoC audio Axel Lin
2010-11-29  9:39 ` [PATCH 1/5] ASoC: Fix compile error for nuc900-ac97.c Axel Lin
2010-11-29  9:40 ` [PATCH 2/5] ASoC: Fix prototype for nuc900_ac97_probe and nuc900_ac97_remove Axel Lin
2010-11-29  9:40 ` [PATCH 3/5] ASoC: Fix compile error for nuc900-pcm.c Axel Lin
2010-11-29  9:42 ` Axel Lin [this message]
2010-11-29 11:47   ` [RFC][PATCH 4/5] ASoC: Fix missing spin_unlock_irqrestore Mark Brown
2010-11-30  1:36     ` Wan ZongShun
2010-11-30 11:13       ` Mark Brown
2010-11-29  9:43 ` [PATCH 5/5] ASoC: Remove unneeded !! operations while checking return value of nuc900_checkready Axel Lin
2010-11-29 11:18 ` [PATCH 0/5] Fix compile error and missing spin_unlock_irqrestore for NUC900 SoC audio Liam Girdwood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1291023767.22911.9.camel@mola \
    --to=axel.lin@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@slimlogic.co.uk \
    --cc=mcuos.com@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox