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: 10501295 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 63F456035E for ; Mon, 2 Jul 2018 12:45:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5472D1FF81 for ; Mon, 2 Jul 2018 12:45:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 486861FFF9; Mon, 2 Jul 2018 12:45:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB0EB1FF81 for ; Mon, 2 Jul 2018 12:45:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753118AbeGBMpG (ORCPT ); Mon, 2 Jul 2018 08:45:06 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:34537 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753109AbeGBMpC (ORCPT ); Mon, 2 Jul 2018 08:45:02 -0400 Received: by mail-pl0-f67.google.com with SMTP id z9-v6so7916693plo.1 for ; Mon, 02 Jul 2018 05:45:01 -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=OF1NeXxx1EgPdperAdaiyR5jyvVvXpSkk/aTCKNeFfaTqXv8i4aqQLxov0C2CbLqTz loq95KIGbON4GagxtXMs+m/zdAfXjKWrw3YHGe3BfPhBbhFStQwyaRxT7lDlhhfeSyPe WC7c+oI/leOGF4yugK9+NCyyt+NjphqMMmRRtRUxf+3nWd4YtiZfwSmJ1nOxd1HZitX1 1RbU6Ps5V8ie2Vmf6EdlT4AKJr8B0aaxQFsoYgxrlbtUjXd2TbxsWkzgCeFYFi/xbht5 WCzrSi1+FV9vqw1UpqIGRY7LGO2H37Mn8e2VzJAR9sauJEN1YmdVpi4a/N0tX0cc/KAP 2BKw== X-Gm-Message-State: APt69E2AfFJs4F8imVVJk083SyPCBPNZdndBqPoLPOGYyhuiAyyWps8Q 6ty/b6PAQTrx8hALm+a6k5xjHB7JB4c= X-Google-Smtp-Source: ADUXVKK9QoQU7rnov/BsGPI2GaldJtcMBooU26t3+eEE6pogEeqfXgBplYi66Z0rhmuotDmSuHhmIA== 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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)