Skip to content

Commit d4a7e05

Browse files
ppailletdlezcano
authored andcommitted
thermal: stm32: Rework sensor mode management
Be sure get_temp returns an error while disabling or enabling the device. Set THERMAL_DEVICE_ENABLED state at the end of power on function. Set THERMAL_DEVICE_DISABLED state at the beginning of power off function. Signed-off-by: Pascal Paillet <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d401652 commit d4a7e05

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/thermal/st/stm_thermal.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,17 @@ static int stm_sensor_power_on(struct stm_thermal_sensor *sensor)
160160
writel_relaxed(value, sensor->base +
161161
DTS_CFGR1_OFFSET);
162162

163+
sensor->mode = THERMAL_DEVICE_ENABLED;
164+
163165
return 0;
164166
}
165167

166168
static int stm_sensor_power_off(struct stm_thermal_sensor *sensor)
167169
{
168170
u32 value;
169171

172+
sensor->mode = THERMAL_DEVICE_DISABLED;
173+
170174
/* Stop measuring */
171175
value = readl_relaxed(sensor->base + DTS_CFGR1_OFFSET);
172176
value &= ~TS1_START;
@@ -374,7 +378,6 @@ static int stm_thermal_update_threshold(struct stm_thermal_sensor *sensor)
374378
{
375379
int ret;
376380

377-
sensor->mode = THERMAL_DEVICE_DISABLED;
378381

379382
ret = stm_sensor_power_off(sensor);
380383
if (ret)
@@ -576,8 +579,6 @@ static int stm_thermal_suspend(struct device *dev)
576579
if (ret)
577580
return ret;
578581

579-
sensor->mode = THERMAL_DEVICE_DISABLED;
580-
581582
return 0;
582583
}
583584

@@ -590,7 +591,6 @@ static int stm_thermal_resume(struct device *dev)
590591
if (ret)
591592
return ret;
592593

593-
sensor->mode = THERMAL_DEVICE_ENABLED;
594594

595595
return 0;
596596
}
@@ -718,8 +718,6 @@ static int stm_thermal_probe(struct platform_device *pdev)
718718
if (ret)
719719
goto err_tz;
720720

721-
sensor->mode = THERMAL_DEVICE_ENABLED;
722-
723721
dev_info(&pdev->dev, "%s: Driver initialized successfully\n",
724722
__func__);
725723

0 commit comments

Comments
 (0)