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

Commit 3053339b authored by Joshua Lang's avatar Joshua Lang Committed by Greg Kroah-Hartman
Browse files

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: default avatarJoshua Lang <joshualang@google.com>
Signed-off-by: default avatarRoman Kiryanov <rkir@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 06e526f4
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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 */