diff options
author | Joshua Lang <joshualang@google.com> | 2018-06-04 14:08:22 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-06-17 09:05:14 +0200 |
commit | 3053339b17f8f3bf0e4f5350adb7097266cd6f1a (patch) | |
tree | 6c6afd970b3d2d8fd0ca5d865fa7826005d73b18 /drivers/staging | |
parent | 06e526f49b7a8280c62710265b699254a7cf3344 (diff) |
staging: goldfish: Clear audio read buffer status after each read
The buffer_status field is interrupt updated. After every read request,
the buffer_status read field should be reset so that on the next loop
iteration we don't read a stale value and read data before the
device is ready.
Signed-off-by: Joshua Lang <joshualang@google.com>
Signed-off-by: Roman Kiryanov <rkir@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/goldfish/goldfish_audio.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index 14e962ddfc3d..0b7c49c4dcb0 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -131,6 +131,7 @@ static ssize_t goldfish_audio_read(struct file *fp, char __user *buf, size_t count, loff_t *pos) { struct goldfish_audio *data = fp->private_data; + unsigned long irq_flags; int length; int result = 0; @@ -144,6 +145,10 @@ static ssize_t goldfish_audio_read(struct file *fp, char __user *buf, wait_event_interruptible(data->wait, data->buffer_status & AUDIO_INT_READ_BUFFER_FULL); + spin_lock_irqsave(&data->lock, irq_flags); + data->buffer_status &= ~AUDIO_INT_READ_BUFFER_FULL; + spin_unlock_irqrestore(&data->lock, irq_flags); + length = audio_read(data, AUDIO_READ_BUFFER_AVAILABLE); /* copy data to user space */ |