icnss2: Add check for max thermal state

Add check for maximum thermal state while setting
current state.

Change-Id: I4ade853d0cda1d8754486dc6dd8f53596fae7a9a
Signed-off-by: Naman Padhiar <npadhiar@codeaurora.org>
This commit is contained in:
Naman Padhiar 2021-07-23 09:47:58 +05:30 • committed by Gerrit - the friendly Code Review server
commit d915a46562

View file

@ -2257,17 +2257,23 @@ static int icnss_tcdev_set_cur_state(struct thermal_cooling_device *tcdev,
if (!penv->ops || !penv->ops->set_therm_cdev_state)
return 0;
if (thermal_state > icnss_tcdev->max_thermal_state)
return -EINVAL;
icnss_pr_vdbg("Cooling device set current state: %ld,for cdev id %d",
thermal_state, icnss_tcdev->tcdev_id);
mutex_lock(&penv->tcdev_lock);
icnss_tcdev->curr_thermal_state = thermal_state;
ret = penv->ops->set_therm_cdev_state(dev, thermal_state,
icnss_tcdev->tcdev_id);
if (!ret)
icnss_tcdev->curr_thermal_state = thermal_state;
mutex_unlock(&penv->tcdev_lock);
if (ret)
if (ret) {
icnss_pr_err("Setting Current Thermal State Failed: %d,for cdev id %d",
ret, icnss_tcdev->tcdev_id);
return ret;
}
return 0;
}