From patchwork Mon Jul 2 12:44:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 140746 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3952641ljj; Mon, 2 Jul 2018 05:45:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfPNXWYNqz5roYCcBQTkjFYMsi3BpqP9Exi2JiaIlWplMAfvDOc4/SpXAQLpkVo9zhWhx7t X-Received: by 2002:a63:6e0a:: with SMTP id j10-v6mr5037831pgc.321.1530535510426; Mon, 02 Jul 2018 05:45:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530535510; cv=none; d=google.com; s=arc-20160816; b=A7tqitYM89yL2Zz+3trIwJU9284ocb9Qg6r2XOq3cVW3pRlzljtjF05iP+AGC8WMl+ OqmdKktSZTUSZb9Wa/SBPS98HhgwM1Ut2VVTwQzPWWc8rDIX4wDbctpeY2YByIXf5LBW xnGaFHsJnkVBE7nQ7H6oe0ODh66G1kMwnhdSQTic73mSA29qlAnQEr4bYEqtSyJhIG0F 0kB1R0ExEHcyWJISZH7LIXYbR+0n3Hddxa5M0hi4LUw2xXKufm2gVgRU9GhnsNAo27s/ eFk/sYV+eBcwst0ufO0oBIPMdA0NWTWsZqtMzrMNnCsD70dH3tyC24MaI42cSx0I6qOi YPWw== 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 v22-v6si16000134plo.123.2018.07.02.05.45.10; Mon, 02 Jul 2018 05:45:10 -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 S1753146AbeGBMpH (ORCPT + 31 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(+) -- 2.7.4 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)