diff --git a/asoc/codecs/lpass-cdc/lpass-cdc-wsa-macro.c b/asoc/codecs/lpass-cdc/lpass-cdc-wsa-macro.c index 541410e695..e629f7bb4f 100644 --- a/asoc/codecs/lpass-cdc/lpass-cdc-wsa-macro.c +++ b/asoc/codecs/lpass-cdc/lpass-cdc-wsa-macro.c @@ -2846,19 +2846,23 @@ static int lpass_cdc_wsa_macro_set_cur_state( { struct lpass_cdc_wsa_macro_priv *wsa_priv = cdev->devdata; - if (!wsa_priv) { + if (!wsa_priv || !wsa_priv->dev) { pr_err("%s: cdev->devdata is NULL\n", __func__); return -EINVAL; } - if (state < wsa_priv->thermal_max_state) + if (state <= wsa_priv->thermal_max_state) { wsa_priv->thermal_cur_state = state; - else - wsa_priv->thermal_cur_state = wsa_priv->thermal_max_state; + } else { + dev_err(wsa_priv->dev, + "%s: incorrect requested state:%d\n", + __func__, state); + return -EINVAL; + } dev_dbg(wsa_priv->dev, - "%s: requested state:%d, actual state: %d\n", - __func__, state, wsa_priv->thermal_cur_state); + "%s: set the thermal current state to %d\n", + __func__, wsa_priv->thermal_cur_state); schedule_work(&wsa_priv->lpass_cdc_wsa_macro_cooling_work); diff --git a/asoc/codecs/lpass-cdc/lpass-cdc-wsa2-macro.c b/asoc/codecs/lpass-cdc/lpass-cdc-wsa2-macro.c index 81e22a412f..521a56ad8a 100644 --- a/asoc/codecs/lpass-cdc/lpass-cdc-wsa2-macro.c +++ b/asoc/codecs/lpass-cdc/lpass-cdc-wsa2-macro.c @@ -2844,19 +2844,23 @@ static int lpass_cdc_wsa2_macro_set_cur_state( { struct lpass_cdc_wsa2_macro_priv *wsa2_priv = cdev->devdata; - if (!wsa2_priv) { + if (!wsa2_priv || !wsa2_priv->dev) { pr_err("%s: cdev->devdata is NULL\n", __func__); return -EINVAL; } - if (state < wsa2_priv->thermal_max_state) + if (state <= wsa2_priv->thermal_max_state) { wsa2_priv->thermal_cur_state = state; - else - wsa2_priv->thermal_cur_state = wsa2_priv->thermal_max_state; + } else { + dev_err(wsa2_priv->dev, + "%s: incorrect requested state:%d\n", + __func__, state); + return -EINVAL; + } dev_dbg(wsa2_priv->dev, - "%s: requested state:%d, actual state: %d\n", - __func__, state, wsa2_priv->thermal_cur_state); + "%s: set the thermal current state to %d\n", + __func__, wsa2_priv->thermal_cur_state); schedule_work(&wsa2_priv->lpass_cdc_wsa2_macro_cooling_work);