Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3792438imm; Mon, 2 Jul 2018 05:47:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcU8pQ38odyGJifhtV5gJGqvT8K28pLbua8U7OymeJhPC9MpjzM20y9c04fdK8GSdtjdLs7 X-Received: by 2002:a63:614d:: with SMTP id v74-v6mr15733132pgb.328.1530535648808; Mon, 02 Jul 2018 05:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530535648; cv=none; d=google.com; s=arc-20160816; b=0EZgUBDgkwtGgSQum2EELXBIkVEeGN/uwVtmPxhtgje7DPa0j2ojHcj2pzIJ3Qe63y MRlqf2JDaQth2RmVkZEcWh3yPpkNLxyTORplbldDNreFWb0RkjUTQuwrTGTbJEkCb/SO Hgyi7ZrEjE25q19XStTtXFSK4u3vYeXDNhXaQgVjpqR6xpZjgMpbCLu8foLEl2odGiJ7 clAw+Px24aDOL26EjuNFIPZvgWETzUuc+eX9tH6TsO0uX/5f6ElEML0UbiWCfkRC+6LR LNES1RcuRHYSXrq2OcsDFJhXwd1iXYQImkkZ1qRvCjaEZxxuvADZGY9ekNqB/wFWwnc9 VUTQ== 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=p3koVhtRRzyhzphTmu+qmrI0x4JDa4s0PSex5KgY8no=; b=X2HtH4W77jfsBQ4Otcr466BKRImbpaYsx1wG9S9fRHyFGr5EX/Gp23nwywJbbmMcGd gAwo5cg72gD0jbVz7MGm449wQXPPRUiYL/o3YaenuvqaDNUCUdFWySQjgLCk5DkfhdXy DnwaOK5XfhAMPkTZ+9OKZdpNlthKrK8Xnz8xrV+dgRNyGR5Tmfshm1+ZRZNB1YYWToEH 6JnSxini3DEXrp7mQJsg3qGgCKKCCFlio4ur2XqFocG+p3kbfTfrntFnPPmu0nVweg0y 4qbZ73tTgkTFv++SLRg4LiqTXpi4SwLSItTBjjqviQ/b4YhzfBY51AHXM01SunLREkjM IdJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iMAf4CMk; 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 6-v6si3125235pgz.592.2018.07.02.05.47.13; Mon, 02 Jul 2018 05:47:28 -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=iMAf4CMk; 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 S1753138AbeGBMpH (ORCPT + 99 others); Mon, 2 Jul 2018 08:45:07 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:37293 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752146AbeGBMpD (ORCPT ); Mon, 2 Jul 2018 08:45:03 -0400 Received: by mail-pl0-f67.google.com with SMTP id 31-v6so7915247plc.4 for ; Mon, 02 Jul 2018 05:45:02 -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=p3koVhtRRzyhzphTmu+qmrI0x4JDa4s0PSex5KgY8no=; b=iMAf4CMkixc+6N4DEsUC+7GixyaVLiWNzVPXziMW0IhO6mxTMVfxYpSwvwENQdlKZc 5JUI+HpGPrnWnItKuszB2UUA/cjwQ2fr5EZcolwVdu39ea5JlbdXgShEZ2aSeMffdvS4 dBGoSokGFrgdG2+wu4oiD+ywb1VAhVpMmpGQY= 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=p3koVhtRRzyhzphTmu+qmrI0x4JDa4s0PSex5KgY8no=; b=Vlx+zrpjMW5gxJs1y8/gehOOpsoaauLXTliUXOHokdpyzNH+li0Y0/RAaKMIxoxJVt fnfzosDGakKLpzju0wq4ojhYuHra/VdJAEI6uRLyX3ReyvXDTXT7gQLX/etJETbUxTcM EQuH52UCwYQFeNiVR5l4pV484eQ5Xl9qBgi7Ng+gxib9OQIC4e1bOe6zWgcEt+osRDk4 peXovAgC8SkdRjMrDzuHbnwEg7hQEZaSFi7TwOxDUpl/8bbjdxjujO1aJP+g5MLYXdfl rdd+HsZtMFR8Isay0LBufGU2wuz+1jtKDsTUbza9o/wUZwoI8bt0qB+Z1B/kSxcONlrj tgPg== X-Gm-Message-State: APt69E2lrO0RhwEgbjk6d5GqR5AwDvtIZ/DiLJKVOhBgfg3BhHKfKooB GKs4OM9HvTM4W+aeEZAixlf7PaMPRMw= X-Received: by 2002:a17:902:7202:: with SMTP id ba2-v6mr25198257plb.119.1530535501540; Mon, 02 Jul 2018 05:45:01 -0700 (PDT) Received: from localhost ([49.248.63.129]) by smtp.gmail.com with ESMTPSA id c85-v6sm8483724pfd.110.2018.07.02.05.45.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 05:45:01 -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, smohanad@codeaurora.org, vivek.gautam@codeaurora.org, andy.gross@linaro.org, Zhang Rui , linux-pm@vger.kernel.org Subject: [PATCH v4 5/6] thermal: tsens: Check if we have valid data before reading Date: Mon, 2 Jul 2018 18:14:08 +0530 Message-Id: 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 Reviewed-by: Bjorn Andersson --- drivers/thermal/qcom/tsens-v2.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/thermal/qcom/tsens-v2.c b/drivers/thermal/qcom/tsens-v2.c index 1871945..0473f33 100644 --- a/drivers/thermal/qcom/tsens-v2.c +++ b/drivers/thermal/qcom/tsens-v2.c @@ -7,6 +7,9 @@ #include #include "tsens.h" +#define TRDY_OFFSET 0xe4 +#define TRDY_READY_BIT BIT(0) + #define STATUS_OFFSET 0xa0 #define LAST_TEMP_MASK 0xfff #define STATUS_VALID_BIT BIT(21) @@ -19,6 +22,12 @@ static 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