From e2fa74880987e9d6e3f8dcbff3f3eb260936842f Mon Sep 17 00:00:00 2001 From: Keerthy Date: Thu, 2 Jun 2016 14:24:50 +0530 Subject: thermal: of-thermal: Fix setting of set_emul_temp hook Currently thermal zone set_emul_temp is set unconditionally with of_thermal_set_emul_temp function. Set this only if the set_emul_temp hook is provided for thermal_zone_of_device_ops. This fixes emul_temp failures on platforms for which set_emul_temp hook is not populated. Fixes: "184a4bf623f (thermal: of: Extend current of-thermal.c code to allow setting emulated temp)" Suggested-by: Eduardo Valentin Signed-off-by: Keerthy Signed-off-by: Eduardo Valentin Conflicts: drivers/thermal/of-thermal.c Signed-off-by: Zhang Rui --- drivers/thermal/of-thermal.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/thermal/of-thermal.c') diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index 20822abc6682..972b0cfb69b1 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -192,9 +192,6 @@ static int of_thermal_set_emul_temp(struct thermal_zone_device *tz, { struct __thermal_zone *data = tz->devdata; - if (!data->ops || !data->ops->set_emul_temp) - return -EINVAL; - return data->ops->set_emul_temp(data->sensor_data, temp); } @@ -432,7 +429,9 @@ thermal_zone_of_add_sensor(struct device_node *zone, if (ops->set_trips) tzd->ops->set_trips = of_thermal_set_trips; - tzd->ops->set_emul_temp = of_thermal_set_emul_temp; + if (ops->set_emul_temp) + tzd->ops->set_emul_temp = of_thermal_set_emul_temp; + mutex_unlock(&tzd->lock); return tzd; -- cgit