From: Clemens Ladisch Date: Mon, 15 Aug 2005 06:25:50 +0000 (+0200) Subject: [ALSA] usb-audio: properly lock hwptr_done accesses X-Git-Tag: upstream/snapshot3+hdmi~46871^2~39 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=daa150ef7d437d17973210f47a1c58623415df94;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git [ALSA] usb-audio: properly lock hwptr_done accesses USB generic driver Take the substream lock when reading hwptr_done to avoid a race condition with the updates in the URB callbacks. Signed-off-by: Clemens Ladisch --- diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 3f7930c..8d4a085 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c @@ -815,8 +815,14 @@ static int wait_clear_urbs(snd_usb_substream_t *subs) */ static snd_pcm_uframes_t snd_usb_pcm_pointer(snd_pcm_substream_t *substream) { - snd_usb_substream_t *subs = (snd_usb_substream_t *)substream->runtime->private_data; - return subs->hwptr_done; + snd_usb_substream_t *subs; + snd_pcm_uframes_t hwptr_done; + + subs = (snd_usb_substream_t *)substream->runtime->private_data; + spin_lock(&subs->lock); + hwptr_done = subs->hwptr_done; + spin_unlock(&subs->lock); + return hwptr_done; }