diff options
author | Anson Huang <b20788@freescale.com> | 2013-07-08 15:06:40 +0800 |
---|---|---|
committer | Anson Huang <b20788@freescale.com> | 2013-07-09 12:32:01 +0800 |
commit | bf0aaca72f76175682ae74e2177b0494e9a1a19b (patch) | |
tree | 31877023a8b4011e8e5ea70f752ed367209277ac /drivers | |
parent | ddea6c35a8a6e3a88439a899c34eefdb6a8eeb62 (diff) |
ENGR00270045: thermal: Add timeout for temperature update
Need to add timeout for temperature update, otherwise, if suspend
comes during thermal sensor measurement, its power will be turned
off, and after resume, the delay work thread will never get
finish flag and result in thread forever loop, temperature will
never get updated. And if we wait for the measurement finish before
suspend, the time is too long for suspend, as one single measurement
would take as long as 100ms which is not good for suspend, so just
add a timeout.
Signed-off-by: Anson Huang <b20788@freescale.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mxc/thermal/thermal.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/mxc/thermal/thermal.c b/drivers/mxc/thermal/thermal.c index 39383e297216..cbe771d4379c 100644 --- a/drivers/mxc/thermal/thermal.c +++ b/drivers/mxc/thermal/thermal.c @@ -276,6 +276,7 @@ static int anatop_thermal_get_temp(struct thermal_zone_device *thermal, struct anatop_thermal *tz = thermal->devdata; unsigned int tmp; unsigned int reg; + unsigned int val; if (!tz) return -EINVAL; @@ -310,11 +311,16 @@ static int anatop_thermal_get_temp(struct thermal_zone_device *thermal, anatop_base + HW_ANADIG_TEMPSENSE0_SET); tmp = 0; + val = jiffies; /* read temperature values */ while ((__raw_readl(anatop_base + HW_ANADIG_TEMPSENSE0) - & BM_ANADIG_TEMPSENSE0_FINISHED) == 0) + & BM_ANADIG_TEMPSENSE0_FINISHED) == 0) { + if (time_after(jiffies, (unsigned long)(val + HZ / 2))) { + pr_info("Thermal sensor timeout, retry!\n"); + return 0; + } msleep(10); - + } reg = __raw_readl(anatop_base + HW_ANADIG_TEMPSENSE0); tmp = (reg & BM_ANADIG_TEMPSENSE0_TEMP_VALUE) >> BP_ANADIG_TEMPSENSE0_TEMP_VALUE; |