diff --git a/asoc/codecs/bolero/bolero-cdc.c b/asoc/codecs/bolero/bolero-cdc.c index 76c9d4064276..4fe18e221229 100644 --- a/asoc/codecs/bolero/bolero-cdc.c +++ b/asoc/codecs/bolero/bolero-cdc.c @@ -1180,6 +1180,21 @@ int bolero_runtime_suspend(struct device *dev) } EXPORT_SYMBOL(bolero_runtime_suspend); +bool bolero_check_core_votes(struct device *dev) +{ + struct bolero_priv *priv = dev_get_drvdata(dev->parent); + bool ret = true; + + mutex_lock(&priv->vote_lock); + if ((priv->lpass_core_hw_vote && !priv->core_hw_vote_count) || + (priv->lpass_audio_hw_vote && !priv->core_audio_vote_count)) + ret = false; + mutex_unlock(&priv->vote_lock); + + return ret; +} +EXPORT_SYMBOL(bolero_check_core_votes); + static const struct of_device_id bolero_dt_match[] = { {.compatible = "qcom,bolero-codec"}, {} diff --git a/asoc/codecs/bolero/bolero-cdc.h b/asoc/codecs/bolero/bolero-cdc.h index 957389cea2d0..f104f88a34bb 100644 --- a/asoc/codecs/bolero/bolero-cdc.h +++ b/asoc/codecs/bolero/bolero-cdc.h @@ -84,6 +84,7 @@ int bolero_tx_clk_switch(struct snd_soc_component *component); int bolero_register_event_listener(struct snd_soc_component *component, bool enable); void bolero_wsa_pa_on(struct device *dev); +bool bolero_check_core_votes(struct device *dev); #else static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb) { @@ -158,5 +159,10 @@ static inline int bolero_register_event_listener( static void bolero_wsa_pa_on(struct device *dev) { } + +static inline bool bolero_check_core_votes(struct device *dev) +{ + return false; +} #endif /* CONFIG_SND_SOC_BOLERO */ #endif /* BOLERO_CDC_H */ diff --git a/asoc/codecs/bolero/rx-macro.c b/asoc/codecs/bolero/rx-macro.c index 671e495ab419..ec71d4a777c8 100644 --- a/asoc/codecs/bolero/rx-macro.c +++ b/asoc/codecs/bolero/rx-macro.c @@ -3572,7 +3572,10 @@ static int rx_macro_core_vote(void *handle, bool enable) pm_runtime_mark_last_busy(rx_priv->dev); } - return 0; + if (bolero_check_core_votes(rx_priv->dev)) + return 0; + else + return -EINVAL; } static int rx_swrm_clock(void *handle, bool enable) diff --git a/asoc/codecs/bolero/tx-macro.c b/asoc/codecs/bolero/tx-macro.c index 97d9f7e35b3f..ca88bfa1582a 100644 --- a/asoc/codecs/bolero/tx-macro.c +++ b/asoc/codecs/bolero/tx-macro.c @@ -1952,7 +1952,6 @@ static int tx_macro_clk_switch(struct snd_soc_component *component) static int tx_macro_core_vote(void *handle, bool enable) { struct tx_macro_priv *tx_priv = (struct tx_macro_priv *) handle; - int ret = 0; if (tx_priv == NULL) { pr_err("%s: tx priv data is NULL\n", __func__); @@ -1964,7 +1963,10 @@ static int tx_macro_core_vote(void *handle, bool enable) pm_runtime_mark_last_busy(tx_priv->dev); } - return ret; + if (bolero_check_core_votes(tx_priv->dev)) + return 0; + else + return -EINVAL; } static int tx_macro_swrm_clock(void *handle, bool enable) diff --git a/asoc/codecs/bolero/wsa-macro.c b/asoc/codecs/bolero/wsa-macro.c index 34c23f486865..03bea4e0e964 100644 --- a/asoc/codecs/bolero/wsa-macro.c +++ b/asoc/codecs/bolero/wsa-macro.c @@ -2802,7 +2802,6 @@ static void wsa_macro_init_reg(struct snd_soc_component *component) static int wsa_macro_core_vote(void *handle, bool enable) { struct wsa_macro_priv *wsa_priv = (struct wsa_macro_priv *) handle; - int ret = 0; if (wsa_priv == NULL) { pr_err("%s: wsa priv data is NULL\n", __func__); @@ -2814,7 +2813,10 @@ static int wsa_macro_core_vote(void *handle, bool enable) pm_runtime_mark_last_busy(wsa_priv->dev); } - return ret; + if (bolero_check_core_votes(wsa_priv->dev)) + return 0; + else + return -EINVAL; } static int wsa_swrm_clock(void *handle, bool enable)