From patchwork Thu Feb 7 10:49:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 157738 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp610768jaa; Thu, 7 Feb 2019 04:57:12 -0800 (PST) X-Google-Smtp-Source: AHgI3IbGuc2QOgQpx0Z0vxgRX0n8sWmQJWNj7KiUtFibXvGGK/iZTl9PLgK5HApmi53972TxZFAy X-Received: by 2002:a63:65c7:: with SMTP id z190mr9991008pgb.249.1549544232121; Thu, 07 Feb 2019 04:57:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549544232; cv=none; d=google.com; s=arc-20160816; b=PHk4Ss1mU5qn7HPhfdRN9JHdyCtbuwDJ/jwlM6r/Gpn14VXbqPvVC10ZouDcQLYzY+ O0Gav4jwn15FRz207HfMZbV+6aO+g2aJImjK6PhUDkIZGAd04CuBhXDeBQf9jkxBAATR RmDCdOXWyoebUGl5Hj1RpaqCR/IIqQowQ4Y+IQDAhfdG2AlaEXjgWgI/z0owcPcQLe8h WuCb/iNco7/uiW2/tzwnRtix+WGfTrBlX6KqiJAPXwAHxQDUEPK5ecZp804SVpsNyNxR IG6Ujpy0ZiYUTP42peZuN0YRcC/HFNVxmSIhVWl8hsBdyU0IGglDv5/XytENKcBFQjoY +ftA== 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 cv19si9981249plb.165.2019.02.07.04.57.11; Thu, 07 Feb 2019 04:57:12 -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 S1727383AbfBGM5K (ORCPT + 31 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(-) -- 2.17.1 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; }