From c5892fccf6012718f7f335c2bfe340850e090c96 Mon Sep 17 00:00:00 2001 From: Deru Wang Date: Wed, 3 Feb 2021 15:25:16 +0800 Subject: [PATCH] asoc: modify the ref_count check for substream These controls are used in both runtime and non-runtime. The current ref_count check will block its use under non-runtime. Change-Id: If98cf5e2c81e22818637b5c0e99764fbc0d08741 Signed-off-by: Deru Wang --- asoc/msm-pcm-loopback-v2.c | 4 ++-- asoc/msm-pcm-q6-v2.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/asoc/msm-pcm-loopback-v2.c b/asoc/msm-pcm-loopback-v2.c index 03424cf9cc61..ef97e732d0ff 100644 --- a/asoc/msm-pcm-loopback-v2.c +++ b/asoc/msm-pcm-loopback-v2.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2013-2020, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2021, The Linux Foundation. All rights reserved. */ #include @@ -950,7 +950,7 @@ static int msm_pcm_channel_mixer_cfg_ctl_put(struct snd_kcontrol *kcontrol, chmixer_pspd); mutex_lock(&loopback_session_lock); - if (substream->ref_count <= 0) { + if (substream->runtime && substream->ref_count <= 0) { pr_err_ratelimited("%s: substream ref_count:%d invalid\n", __func__, substream->ref_count); mutex_unlock(&loopback_session_lock); diff --git a/asoc/msm-pcm-q6-v2.c b/asoc/msm-pcm-q6-v2.c index 1f869d1a4859..f79ef63a8d3f 100644 --- a/asoc/msm-pcm-q6-v2.c +++ b/asoc/msm-pcm-q6-v2.c @@ -1862,7 +1862,7 @@ static int msm_pcm_chmap_ctl_put(struct snd_kcontrol *kcontrol, return 0; mutex_lock(&pdata->lock); - if (substream->ref_count <= 0) { + if (substream->runtime && substream->ref_count <= 0) { pr_err_ratelimited("%s: substream ref_count:%d invalid\n", __func__, substream->ref_count); mutex_unlock(&pdata->lock); @@ -1935,7 +1935,7 @@ static int msm_pcm_chmap_ctl_get(struct snd_kcontrol *kcontrol, return 0; /* no channels set */ mutex_lock(&pdata->lock); - if (substream->ref_count <= 0) { + if (substream->runtime && substream->ref_count <= 0) { pr_err_ratelimited("%s: substream ref_count:%d invalid\n", __func__, substream->ref_count); mutex_unlock(&pdata->lock); @@ -2240,7 +2240,7 @@ static int msm_pcm_channel_mixer_cfg_ctl_put(struct snd_kcontrol *kcontrol, } mutex_lock(&pdata->lock); - if (substream->ref_count <= 0) { + if (substream->runtime && substream->ref_count <= 0) { pr_err_ratelimited("%s: substream ref_count:%d invalid\n", __func__, substream->ref_count); mutex_unlock(&pdata->lock);