Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5174837imm; Tue, 12 Jun 2018 03:56:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIoSO6f4yla2xgD0EkXeHrUEtJO1EGoWOzdbI0qAmnEHe/Jy0sx5fzf9XRihBm9TNzMhJWD X-Received: by 2002:a63:b812:: with SMTP id p18-v6mr2866397pge.11.1528801013283; Tue, 12 Jun 2018 03:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528801013; cv=none; d=google.com; s=arc-20160816; b=SHbw9KlKeeHje3Ga/aHbcoVSLT9cABbPQjJ+d/OWitXlinJmO0qxbx8BATi2/lyic+ htXQ9xKdd+IiJOJd8Qnl0q8rWv7rxG4lSb+hDxJri1L1vXW4NJasBkkPI8vXKC7+ijx3 7qTPq/yA1/GkHpzt5j2huDwYt9TOwZx0ODEh+AX6lBYh6GgM8fGE4qpK/vgwz2qUcMRY VraPGtvLUeEc+Px+0mK881e7ZjO7cP1kh9UFNJmyvAaw95K3ZEBEEqA+FYXDiNcHjnQz GbiC5L/kDRIOpBunn6nrWYTU86+GHW1TKRwMz+rkY6Ob0zeuyAkv6ZYAR/az9a+lsv0f mKZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=IsTrdZ+kDihtM/XHpghRzKqziLMnz08SUOtIHPMaoHk=; b=I8P+S6Qg8Yp7Xw0+90uNh9zwxr/vAK7YeB/fMZ4H26fEiZiPh8VpFHEcHdB4geNWZ/ zgZhqdsl21fZko7QttJdiqJB/mdrMxsHPsPPgAuy0IJwW1kYSllx3H7QMH4xzZmFWnoX IL9y7sVoRHvNrK5Ni2M9b+Uvzr46s6DF8XisGofTxc+7nR7+3NY00QHGMgaOwVNhXgRP a28Roba5BW0ff+Xmw21mn63w32COzJzLk2nbSNtGPn40EBQYbETkUsFi+oF55dKEpIQC brfGC0gXXb7O+0d4JIaGGErivgW8NcVdSrVC27jYOhFqCf8hAt1R5bvK+cZyL4h2+uxo O8lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=isZzJiXi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r7-v6si526429pgn.326.2018.06.12.03.56.38; Tue, 12 Jun 2018 03:56:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=isZzJiXi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754341AbeFLKz7 (ORCPT + 99 others); Tue, 12 Jun 2018 06:55:59 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:39809 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933394AbeFLKz4 (ORCPT ); Tue, 12 Jun 2018 06:55:56 -0400 Received: by mail-lf0-f68.google.com with SMTP id t134-v6so35302927lff.6 for ; Tue, 12 Jun 2018 03:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=IsTrdZ+kDihtM/XHpghRzKqziLMnz08SUOtIHPMaoHk=; b=isZzJiXi+rLTzHRpafJw0fs25sc4Vi13LlgvCI0+WtbmNyJvAigBgGl6PF3870/xAQ v9KBEXySnExvg87WZ3yeSuXXUOdktnxloyDc2xuyBIhK9TjzSxxTfyEZ0XfpsRx1+1Je 6mAY59v72Qq3GYZSwmxh4mS4xcBnJGogj56LE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=IsTrdZ+kDihtM/XHpghRzKqziLMnz08SUOtIHPMaoHk=; b=mojhqvk6r4UB/Fp3eJwGOz2YoHUnFUXe9XUhoo816BePE6cviFLv3gcvYWsBHloqnv X5GaDYLLZNNnsRBdXPnXGu81HfxFh5eS8a75YMsKNEhHdUMoCU6Yu2FGRy1CYe3BSZGD dtSbmFMIuy718OoDREjz8V5Amu51pbWl2RsOA/9hezu9yryBJynMFrRiDizv70v5qB54 mpWHARNwyH3zEFHhLSqHeKSj+EA57lzTRn0C4iMwKvj+2F7FFrXssSmQ82/S4a/JoI0x /IikPn79XKrMktgCf+MmID40rZW5Z1+KM5xPJwLpUIVp0d6MtyFhsa6trThstmTRXQv8 gGmQ== X-Gm-Message-State: APt69E2kHI346t1UF5ikKk+JSmn5ZEuoylHQ09lFGgjCYl5+akVB/r2U O2fzGkiVa1hh3LkzzAOxSuIxCEQuGTg= X-Received: by 2002:a19:1c5:: with SMTP id 188-v6mr1919305lfb.67.1528800954642; Tue, 12 Jun 2018 03:55:54 -0700 (PDT) Received: from localhost (85-76-96-64-nat.elisa-mobile.fi. [85.76.96.64]) by smtp.gmail.com with ESMTPSA id r27-v6sm144699lfi.8.2018.06.12.03.55.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jun 2018 03:55:54 -0700 (PDT) From: Amit Kucheria 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 , 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 Message-Id: <021331bdb04642e9ddf34accda65a93b850c4a23.1528799892.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Amit Kucheria --- 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