From patchwork Thu Jun 14 10:43:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 138546 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1941020lji; Thu, 14 Jun 2018 03:44:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJWjitmyQmBi4frF7kRr+cbt4xLHKbe4nTZJCgnC77VrmZo2I7x/h7GGJgicQlS4FSLRNY3 X-Received: by 2002:a17:902:7089:: with SMTP id z9-v6mr2397608plk.231.1528973063830; Thu, 14 Jun 2018 03:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528973063; cv=none; d=google.com; s=arc-20160816; b=O46BoQBnBNkpTYaWVZwksy1OQfjbukycsOJVKa1iBsN+5WoEhmtb2JOI0FrJ/9rpeC 8UQ22gENfPcuITDTDPlJRvIOfGHObmjN1/FW6t/Equc6YkDNdtH1vUDe5By1I/FvsC0k eo4jGhpH9Vw8Y8qgIcty75dnkyBY5cvYj1xVju77neZiVaHETLHMqbh/Sr53p4U6sqie vomOeFVbVmhTqm6sgG559cHR2fKx9Z49cn0n5g007FyXY8wXlP6ABAMzstK/5Ua6witS 8AiVblpaE+49OnaLJ3uHL+pcMDeWhx2JmLYj+ajOYp9e10djqVSWjIcG1khCBjLuv/Gh fiNA== 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=U39x3+GmFhXEta2G8HMZPe16wfFoZGxDiNc2P0jDGto=; b=c+tUryOLPAe0n1UQ+aNHBe4Sx51pJvjP/J0W3BeR8i9V85sxVtZQ7WtzM/+IIKxc3g 5rQqVsn1fnOK+NvOd56MYAwgROZN9Rxxzq5CWnETezFMgZ6UcJ4u/LeYXCff8XWpvJno aqVVK9Fv9GFbO26h6KS/Sd1g/RP8KXdp2E6Irqcr1V4KX33o3RiVc/Oy1xiUtupEpsGm TnJo7oga/kacL9NzDHRAkvbMQYFlRmURrkrI4SDXcmRGSPbyBsEgkmEFzlftNGcUZnuy C3mnWA1Q9AKxMt20NhxDlyH/RTVG2Sr5tUetD6aGqvW5SOOpELoeHGRHS3EIeHsfkkp4 zNog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dF5GopFe; 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 p187-v6si4281556pga.226.2018.06.14.03.44.23; Thu, 14 Jun 2018 03:44:23 -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=dF5GopFe; 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 S1755146AbeFNKoW (ORCPT + 30 others); Thu, 14 Jun 2018 06:44:22 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:45312 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934160AbeFNKoS (ORCPT ); Thu, 14 Jun 2018 06:44:18 -0400 Received: by mail-lf0-f66.google.com with SMTP id n3-v6so8639235lfe.12 for ; Thu, 14 Jun 2018 03:44:17 -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=U39x3+GmFhXEta2G8HMZPe16wfFoZGxDiNc2P0jDGto=; b=dF5GopFegu/UvdDWgUYCmYWd+7kSkmgl8FqCNJTpT59kgAuBFzpUDDwYNzeNZcI4z1 qA057hIqnAsl7FbKWAtj4Y/k1Auc3cRPBTbOgyNQrkMdygOcR5BOwY77cp5+KaXDsAaO fWFVFL3WWyhV8ERnaN7UsIE5/e99pHmvHZaIk= 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=U39x3+GmFhXEta2G8HMZPe16wfFoZGxDiNc2P0jDGto=; b=UNQynEa7EvO4xC7ZF7uXx9AVK4GhMSf9URPJNWvDmKZtGiUcboLqasXJ3nf1B1Elns zMFAPGj+JOowfbTOB8KouVKJOK1qlxSogvSNqWryNA9ExCevkgapGVp8pT+DnptWQlkM 868IiaJS0vEq1HoLIKZsLViLoWymRrUXUBFbcpQLeJ729yY2p3XRGNgpEBh4KIJAEth2 JWqEt82sr6qzpqaB6I5MdwS+5T+PXDp9eJuDGKoDob/VugcGKSRnLQ44ghjv66bnNWL4 mDPuk66d5SfTjinonhOJdhSd2PsXzeaDHB6RmiDI9ECzRxwaWA8s+I1O1u7LxNoC0Yh4 Bz8A== X-Gm-Message-State: APt69E2W+804hH9wDGwNSD3c05o2NHVuJ7sTDF0OYwJrWNk2+usWG3XR MLf0hLMAKHNxwhluBmcz8HAAdg68XEQ= X-Received: by 2002:a19:97cb:: with SMTP id z194-v6mr5976920lfd.17.1528973056378; Thu, 14 Jun 2018 03:44:16 -0700 (PDT) Received: from localhost (85-76-96-172-nat.elisa-mobile.fi. [85.76.96.172]) by smtp.gmail.com with ESMTPSA id v79-v6sm888693lje.78.2018.06.14.03.44.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jun 2018 03:44:15 -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 (open list:THERMAL) Subject: [PATCH v3 5/6] thermal: tsens: Check if we have valid data before reading Date: Thu, 14 Jun 2018 13:43:15 +0300 Message-Id: <383d28a935992f62e2ff707b01de63b53e7e8418.1528972165.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 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 abc8f13..76fb668 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)