linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amit Kucheria <amit.kucheria@linaro.org>
To: linux-kernel@vger.kernel.org
Cc: rnayak@codeaurora.org, linux-arm-msm@vger.kernel.org,
	bjorn.andersson@linaro.org, edubezval@gmail.com,
	Zhang Rui <rui.zhang@intel.com>,
	linux-pm@vger.kernel.org (open list:THERMAL)
Subject: [PATCH v2 5/5] thermal: tsens: Check if we have valid data before reading
Date: Tue, 12 Jun 2018 13:54:57 +0300	[thread overview]
Message-ID: <021331bdb04642e9ddf34accda65a93b850c4a23.1528799892.git.amit.kucheria@linaro.org> (raw)
In-Reply-To: <cover.1528799892.git.amit.kucheria@linaro.org>
In-Reply-To: <cover.1528799892.git.amit.kucheria@linaro.org>

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
---
 drivers/thermal/qcom/tsens-common.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c
index 961ace4..f510e61 100644
--- a/drivers/thermal/qcom/tsens-common.c
+++ b/drivers/thermal/qcom/tsens-common.c
@@ -114,6 +114,9 @@ int get_temp_common(struct tsens_device *tmdev, int id, int *temp)
 #define STATUS_VALID_BIT	BIT(21)
 #define CODE_SIGN_BIT		BIT(11)
 
+#define TRDY_OFFSET     	0xe4
+#define TRDY_READY_BIT  	BIT(0)
+
 int get_temp_tsens_v2(struct tsens_device *tmdev, int id, int *temp)
 {
 	struct tsens_sensor *s = &tmdev->sensor[id];
@@ -121,6 +124,12 @@ int get_temp_tsens_v2(struct tsens_device *tmdev, int id, int *temp)
 	unsigned int sensor_addr;
 	int last_temp = 0, last_temp2 = 0, last_temp3 = 0, ret;
 
+	ret = regmap_read(tmdev->map, TRDY_OFFSET, &code);
+	if (ret)
+		return ret;
+	if (code & TRDY_READY_BIT)
+		return -ENODATA;
+
 	sensor_addr = STATUS_OFFSET + s->hw_id * 4;
 	ret = regmap_read(tmdev->map, sensor_addr, &code);
 	if (ret)
-- 
2.7.4


  parent reply	other threads:[~2018-06-12 10:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12 10:54 [PATCH v2 0/5] thermal: tsens: Prepare for version 2 of TSENS IP Amit Kucheria
2018-06-12 10:54 ` [PATCH v2 1/5] thermal: tsens: Get rid of unused fields in structure Amit Kucheria
2018-06-12 10:54 ` [PATCH v2 2/5] dt: qcom: 8996: thermal: Move to DT initialisation Amit Kucheria
2018-06-12 19:35   ` Bjorn Andersson
2018-06-13  8:13     ` Amit Kucheria
2018-06-12 10:54 ` [PATCH v2 3/5] thermal: tsens: Move 8996 get_temp() to common code for reuse Amit Kucheria
2018-06-12 19:43   ` Bjorn Andersson
2018-06-12 20:55     ` Amit Kucheria
2018-06-12 10:54 ` [PATCH v2 4/5] thermal: tsens: Add support for SDM845 Amit Kucheria
2018-06-12 19:28   ` Rob Herring
2018-06-14  6:48   ` Vivek Gautam
2018-06-14 10:24     ` Amit Kucheria
2018-06-12 10:54 ` Amit Kucheria [this message]
2018-06-12 19:43   ` [PATCH v2 5/5] thermal: tsens: Check if we have valid data before reading Bjorn Andersson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=021331bdb04642e9ddf34accda65a93b850c4a23.1528799892.git.amit.kucheria@linaro.org \
    --to=amit.kucheria@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=edubezval@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rnayak@codeaurora.org \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).