Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5753124imm; Tue, 12 Jun 2018 12:45:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIJ4Fb/o/4Gm8mASlKOvFXjxeIexUJXJQZaIldrTWmV3iFrrmUyH9PyOu0W7rHBxnHskJIH X-Received: by 2002:a65:4784:: with SMTP id e4-v6mr1497890pgs.58.1528832719333; Tue, 12 Jun 2018 12:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528832719; cv=none; d=google.com; s=arc-20160816; b=dxFG1YPufdcfG13+qCZ0iZUGAn2p/uLucauZ+fDG3d6yBqpAB+ey6fuVWaQW1saxbN iARSNrFkn8ZEGzGhkoqMKVKhai7hWesvJsHvq6dK/EJhRAPWlQ6s9exL3NyTSXDc/IQB h88l6SjOwUtm7BupvYy8mdIbuaZ93iZaArRNLnlqil9TvMBsKTx3NUv80MMA26KdgJSk 4COsbacHL5edt0Sh7YvOOUSBkm0JS4LAQ3zZU2IvLxIswTx7BBi3x8Jy2/uzZ4+6x1c/ zYUhwQWnzbJUydicEpeajCiDGCKo9cQymtPjVSiHrz80QXD6RNMvHk35V+gMt9pGVGWI +Jkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=B41EEUmPD91lDJ5Ytk33rHfhIZaofOEto0+sYlsK4zI=; b=YCHZRLMATtXG2D7aR1dA5x6b767yeK4XjGskepl5ZRsck8t6tZOoRRt4h3JmPlVthH s2jNdxLxMjg69U84dLsbLxxcEJgQTCMTc6CbuVjbGWnnVALD5G5QaSk4CeamiIWiwJMS 9UJIeHc7F/iRPYkGn2NrGgxCd9znbTQmPHWmW5yI1NMeUv2Oorfws/F0vR8/bcqxwOsj MnxSnabzmaZZ8woRBu8awZYggZs61Jnji+xS5MNxq/f+7DFqSDqfek8Dx9obmB+Jru0X aZ8xjwUCoWn9SlsKE1L1FItH9CNRb3y5WyWjLA8qEvs7mBYT512L/Msv0rHTZuHEpZYB cCxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JXRWLv0c; 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 s184-v6si719665pgb.172.2018.06.12.12.45.04; Tue, 12 Jun 2018 12:45:19 -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=JXRWLv0c; 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 S933744AbeFLTnp (ORCPT + 99 others); Tue, 12 Jun 2018 15:43:45 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35147 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932533AbeFLTnn (ORCPT ); Tue, 12 Jun 2018 15:43:43 -0400 Received: by mail-pg0-f68.google.com with SMTP id 15-v6so66498pge.2 for ; Tue, 12 Jun 2018 12:43:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=B41EEUmPD91lDJ5Ytk33rHfhIZaofOEto0+sYlsK4zI=; b=JXRWLv0cu9rMu1A7f1DhLPwktnnuByQSMfWU6EJ0cvGI84+qvQHfCGsw8uFRU3UB3x 8Pjde0FQgBFgef7/kbDHgRFyLkeLekl6kurx+SFlDlXYf35dAYi/g7ONnfkxPitoXv0c FEM1tArsbqzJrGhSfSWNdvfGVnzF4mKb8z4u4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=B41EEUmPD91lDJ5Ytk33rHfhIZaofOEto0+sYlsK4zI=; b=ID87wB1Mxx045ylh88cA7QSOcK6jZx0fg+fz1+KdTFojynovH9h99bOaQ2KhaPitjL 0sD6qYUaL6OYhqx6oPv4tFQSALzP2F6Z3erANA0rqiFDeUMIhu5B2ve58YUV2WCxvOdJ Dkt5dDFfx0fUXtcbAHrf+keCEHY3C+dBNWt6BIAoMXg73lPtTMSqvh42ePJIsppHsiLP u+b0sBVbkm2VCzrH4E0w7EZN3b6CXhLS7xiZUuTBPMOV/3bIdGutI16+5Ejtb8xGguQc 6zXYzSy9WDGAjdYOY+tdy5Ek4ckSz3jZFqmEEnOLKbrwSf+62KbeRqDuYLyXQ2qCMTt0 snqw== X-Gm-Message-State: APt69E1lvZPCMbL1QawE21/Axhgp5rSfFISk51cGenYH3VESg1aN4GC+ bkSX8f/SSPefvTKrPB8IIn1MhEPI7S8= X-Received: by 2002:a62:9652:: with SMTP id c79-v6mr1822869pfe.114.1528832622524; Tue, 12 Jun 2018 12:43:42 -0700 (PDT) Received: from minitux (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id m16-v6sm818258pgu.67.2018.06.12.12.43.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Jun 2018 12:43:41 -0700 (PDT) Date: Tue, 12 Jun 2018 12:43:40 -0700 From: Bjorn Andersson To: Amit Kucheria Cc: linux-kernel@vger.kernel.org, rnayak@codeaurora.org, linux-arm-msm@vger.kernel.org, edubezval@gmail.com, Zhang Rui , "open list:THERMAL" Subject: Re: [PATCH v2 5/5] thermal: tsens: Check if we have valid data before reading Message-ID: <20180612194340.GQ14924@minitux> References: <021331bdb04642e9ddf34accda65a93b850c4a23.1528799892.git.amit.kucheria@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <021331bdb04642e9ddf34accda65a93b850c4a23.1528799892.git.amit.kucheria@linaro.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 12 Jun 03:54 PDT 2018, Amit Kucheria wrote: > Signed-off-by: Amit Kucheria Reviewed-by: Bjorn Andersson Regards, Bjorn > --- > 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 >