Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp318147imj; Thu, 7 Feb 2019 04:57:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IYHJ9kaLmr+wGGc/sstS5daoNc2iUpOAx4edwy2IZThZ5cU/6ZWvelVLrmnUIwuYN8PBghk X-Received: by 2002:a62:3141:: with SMTP id x62mr15915963pfx.12.1549544272850; Thu, 07 Feb 2019 04:57:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549544272; cv=none; d=google.com; s=arc-20160816; b=Yxb7tA7IZ2da8wM8GWTH2JTQKnB8bGth4FbwlDfT/bkE9mZsUl6MOMB6c4TIQi3lp3 M07E268h76HJuNxrpBuohkKYCTyP8iiDVzDC/sJeG2psaEefZ3aaWELStIbo9uPRNVfi 68kP5Y4jBlUOcZwuidiNEthzDWpbDCA9NQuGo8ZemGx7VTXCecynEgc6X4XIGF+HgebO v+LG9H7aoWGgM2XVDShonKC1R1oh5Kh32TfxiVhKJi52/eGSBoNds4MI3ScmzYj56Okf fMEzMP8EocjDltWcp6I4iZSmyvLO0ZEsGq9jGsRmoGmHrvT/qyX8xIKQ2To/hVUmItl1 EQ0A== 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; bh=F38/1f+iUBZrVnisIpGjF3Hp0h3BqeGBxfZgCYkmLmo=; b=hHTonsI/6rJz7Hi/y60EUibHjIODmH/YGo8cKS8cAg3SgViDegpdE3jc8d6Sml5UpG w3qPHS3g8E8VFN/s97HMxI7YL3tYcA9zvjky++uCdKLxc/D6sItdmo9pBWOAX8UmAgDy KMtUbW0rbopRdBa/0uBXINlwIOoUa6iFDMGi9yTtD3WENO/1j1TeVMPTzMFDNczY0fUq vYosFgt6ga4JeHg5+n/QlApjmIqd4yXS2q6cnUOicsfpPKcVnO7klxDIF9cqwAwHguf5 BV7SvdUf+F0XzM5oS0RCs0cRx4T5zGbWHeV6ANbn0Zw2MJoI2cZFlAvOjCaKJ29C7ZyP MRjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L1bQ4mXV; 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 r28si683159pgm.317.2019.02.07.04.57.37; Thu, 07 Feb 2019 04:57:52 -0800 (PST) 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=L1bQ4mXV; 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 S1727372AbfBGM5K (ORCPT + 99 others); Thu, 7 Feb 2019 07:57:10 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36890 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727353AbfBGM5I (ORCPT ); Thu, 7 Feb 2019 07:57:08 -0500 Received: by mail-pl1-f194.google.com with SMTP id b5so4742791plr.4 for ; Thu, 07 Feb 2019 04:57:08 -0800 (PST) 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=F38/1f+iUBZrVnisIpGjF3Hp0h3BqeGBxfZgCYkmLmo=; b=L1bQ4mXVizD1Xxwy0FWGbtUwpPj9kj0ohpkP/IduUWPdiXE2UmcW+s3FTFOaABsenA iuklS8oBX0ipYWtzacQXGYeJ9zp4BiGWEmH0ZxgxzatybXiNCshzE9LlAot8yOszXhR7 tnEJsLwttLm8nnlhpz67Yd9Ty0xscHjwM4fuMMzKG+eyofMdNynrVIRS1MEfmYA0cTJ9 Hols7WCAd+kzqHaQnUIs0p1Rc7q9qP9iuL63EFcG7g+WWEzf7SCBhxzgtGpHYDtc9N4H 2yl2pEhJY4mZA1eUbh5QUmuYhG1pORp0GZxsWGnXOzMmbmm15r1RXJyYU8PFInGnUMI2 Djlg== 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=F38/1f+iUBZrVnisIpGjF3Hp0h3BqeGBxfZgCYkmLmo=; b=iwotzztEV3x2sHKtdtbdU78fHVaWxunrjdUH7vXhPVtoSoeVogw8733yTzbEOKBrbt GKkK1JxlLE12yCxPFghYX9G4jGyWyJV9m6/6mNxbKFUSu//lMrOVX3zTPIu7wH1TDpZG wWAXKbppkfN5fLhiLXyyUvLz98fIwGG1+eBwciLMms4hnva0FLf+t0fTwTv1Sq0bOWLi BwCvr7ylY8QbB7jydyFjG3h74co+J3dqFiDiDmAQ0aUPgE/f9lUBGFGc5YYfVLO3kDwi BY0YRNK0ub567q8UtAWPqyagh9ThYSvjBxAtKeaNCiSQJMiLhXYolID4l16xqumHWNVX yXIg== X-Gm-Message-State: AHQUAuZsf5AyCkSs1WEu/hIQ/Bbd40cMiaNJzHqJiiED/8UDrPq9PwzP sOaoY8KbAMUC69qTdZqQIx+oen8D/rQ= X-Received: by 2002:a17:902:1745:: with SMTP id i63mr16055283pli.145.1549544227583; Thu, 07 Feb 2019 04:57:07 -0800 (PST) Received: from localhost ([2402:3a80:c80:4138:75dd:3900:1d90:762f]) by smtp.gmail.com with ESMTPSA id y5sm42218744pge.49.2019.02.07.04.57.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Feb 2019 04:57:07 -0800 (PST) From: Amit Kucheria To: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, bjorn.andersson@linaro.org, edubezval@gmail.com, andy.gross@linaro.org, Daniel Lezcano , David Brown , Zhang Rui Cc: linux-pm@vger.kernel.org Subject: [PATCH v1 19/24] drivers: thermal: tsens: Common get_temp() learns to do ADC conversion Date: Thu, 7 Feb 2019 16:19:37 +0530 Message-Id: <187981aec80d2695c6cb4765600d2fe979122805.1549525708.git.amit.kucheria@linaro.org> X-Mailer: git-send-email 2.17.1 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 get_temp() learns to return temperature regardless of whether it is returned as ADC code or direct temperature. Signed-off-by: Amit Kucheria --- drivers/thermal/qcom/tsens-common.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c index ed975a2430d9..a935d2335eea 100644 --- a/drivers/thermal/qcom/tsens-common.c +++ b/drivers/thermal/qcom/tsens-common.c @@ -129,10 +129,15 @@ int get_temp_tsens_valid(struct tsens_priv *priv, int i, int *temp) if (ret) return ret; - mask = GENMASK(priv->fields[LAST_TEMP_0].msb, - priv->fields[LAST_TEMP_0].lsb); - /* Convert temperature from deciCelsius to milliCelsius */ - *temp = sign_extend32(last_temp, fls(mask) - 1) * 100; + if (priv->feat->adc) { + /* Convert temperature from ADC code to milliCelsius */ + *temp = code_to_degc(last_temp, s) * 1000; + } else { + mask = GENMASK(priv->fields[LAST_TEMP_0].msb, + priv->fields[LAST_TEMP_0].lsb); + /* Convert temperature from deciCelsius to milliCelsius */ + *temp = sign_extend32(last_temp, fls(mask) - 1) * 100; + } return 0; } -- 2.17.1