[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190218191141.3729-10-andrew.smirnov@gmail.com>
Date: Mon, 18 Feb 2019 11:11:38 -0800
From: Andrey Smirnov <andrew.smirnov@...il.com>
To: linux-pm@...r.kernel.org
Cc: Andrey Smirnov <andrew.smirnov@...il.com>,
Chris Healy <cphealy@...il.com>,
Lucas Stach <l.stach@...gutronix.de>,
Zhang Rui <rui.zhang@...el.com>,
Eduardo Valentin <edubezval@...il.com>,
Daniel Lezcano <daniel.lezcano@...aro.org>, linux-imx@....com,
linux-kernel@...r.kernel.org
Subject: [PATCH 09/12] thermal: qoriq: Do not report invalid temperature reading
Before returning measured temperature data to upper layer we need to
make sure that the reading was marked as "valid" to avoid reporting
bogus data.
Signed-off-by: Andrey Smirnov <andrew.smirnov@...il.com>
Cc: Chris Healy <cphealy@...il.com>
Cc: Lucas Stach <l.stach@...gutronix.de>
Cc: Zhang Rui <rui.zhang@...el.com>
Cc: Eduardo Valentin <edubezval@...il.com>
Cc: Daniel Lezcano <daniel.lezcano@...aro.org>
Cc: linux-imx@....com
Cc: linux-pm@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
---
drivers/thermal/qoriq_thermal.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c
index 6478d7a8168f..3d520d3b2da4 100644
--- a/drivers/thermal/qoriq_thermal.c
+++ b/drivers/thermal/qoriq_thermal.c
@@ -37,6 +37,7 @@
#define REGS_TRITSR(n) (0x100 + 16 * (n)) /* Immediate Temperature
* Site Register
*/
+#define TRITSR_V BIT(31)
#define REGS_TTRnCR(n) (0xf10 + 4 * (n)) /* Temperature Range n
* Control Register
*/
@@ -55,8 +56,10 @@ static int tmu_get_temp(void *p, int *temp)
struct qoriq_tmu_data *data = p;
regmap_read(data->regmap, REGS_TRITSR(data->sensor_id), &val);
- *temp = (val & 0xff) * 1000;
+ if (!(val & TRITSR_V))
+ return -ENODATA;
+ *temp = (val & 0xff) * 1000;
return 0;
}
--
2.20.1
Powered by blists - more mailing lists