dsp: codecs: Add flag to check if wait event initialized before access

Add flag to check if wait event initialized before access.

Change-Id: Ib4b4654dfe1b0a18506ae6fb8029296a5f780fe9
Signed-off-by: Vatsal Bucha <vbucha@codeaurora.org>
This commit is contained in:
Vatsal Bucha 2021-03-22 16:11:08 +05:30 • committed by Gerrit - the friendly Code Review server
commit 0d30652d51
3 changed files with 8 additions and 4 deletions

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (C) 2008 Google, Inc.
* Copyright (C) 2008 HTC Corporation
* Copyright (c) 2009-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2009-2021, The Linux Foundation. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@ -1340,6 +1340,7 @@ int audio_aio_open(struct q6audio_aio *audio, struct file *file)
audio->pcm_cfg.sample_rate = 48000;
audio->pcm_cfg.channel_count = 2;
audio->wake_event_initialized = false;
/* Only AIO interface */
if (file->f_flags & O_NONBLOCK) {
pr_debug("%s[%pK]:set to aio interface\n", __func__, audio);
@ -1373,6 +1374,7 @@ int audio_aio_open(struct q6audio_aio *audio, struct file *file)
audio->drv_ops.out_flush(audio);
audio->opened = 1;
audio->reset_event = false;
audio->wake_event_initialized = true;
file->private_data = audio;
audio->codec_ioctl = audio_aio_ioctl;
audio->codec_compat_ioctl = audio_aio_compat_ioctl;

View file

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (C) 2008 Google, Inc.
* Copyright (C) 2008 HTC Corporation
* Copyright (c) 2009-2018, 2020 The Linux Foundation. All rights reserved.
* Copyright (c) 2009-2018, 2020-2021 The Linux Foundation. All rights reserved.
*/
#include <linux/fs.h>
@ -188,6 +188,7 @@ struct q6audio_aio {
int rflush; /* Read flush */
int wflush; /* Write flush */
bool reset_event;
bool wake_event_initialized;
long (*codec_ioctl)(struct file *, unsigned int, unsigned long);
long (*codec_compat_ioctl)(struct file *, unsigned int, unsigned long);
};

View file

@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
*/
#include <linux/module.h>
@ -110,7 +110,8 @@ void audio_aio_cb(uint32_t opcode, uint32_t token,
pr_err("%s: Received opcode:0x%x\n", __func__, opcode);
audio->stopped = 1;
audio->reset_event = true;
wake_up(&audio->event_wait);
if (audio->wake_event_initialized)
wake_up(&audio->event_wait);
break;
default:
break;