Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d915a465 authored by Naman Padhiar's avatar Naman Padhiar Committed by Gerrit - the friendly Code Review server
Browse files

icnss2: Add check for max thermal state



Add check for maximum thermal state while setting
current state.

Change-Id: I4ade853d0cda1d8754486dc6dd8f53596fae7a9a
Signed-off-by: default avatarNaman Padhiar <npadhiar@codeaurora.org>
parent 879de41f
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -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;
}