Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp889939pxb; Wed, 27 Oct 2021 14:32:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUSf6nRh9s/7wc7W1M+koCxE7hqSQbsdDl1EKwHSFhqwI9WWU5D7X/aQ3jT/NshueafJPq X-Received: by 2002:a17:90b:1c8f:: with SMTP id oo15mr179427pjb.169.1635370374457; Wed, 27 Oct 2021 14:32:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635370374; cv=none; d=google.com; s=arc-20160816; b=csLfyF8izm9G/PgZmlHX68vmFQzGW7qE7sB+kGNAqj28pRflGKABM8ogJQt3yCeHj7 Fgfj4ZRz9L9o4UDrUhFiM6v6agYe/DETbgBOoMlD7vhleFIb9lTw+FIpM00nHc4H0HhQ QzPeGmVCyZ0ich5mgdizE+NBew7asqemAp9mm4uq+tA/WT3fs3xwJ+GTEfTNTYK3R6ZS ykSHXBKYSJadwYKmVkFMR8guiaspUpnLrswj7ejB7bdldiE1sAvJjJ6xUCwbVfQIBsLF IxC4xgPlpyne8ouf8dZeLLytDnFMtIz3WDhyULsI6m4u56OkXKf5vx6mZqNsGFuHShZa isFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=qPtCczC+5WPD5lR4cD8UdJvQuxtnO43EiOuj2yonr80=; b=nE4q46O1/WvFzHd2oyaf3NUyJRiUA1p4U/w239k70tWvlr/xF6n1Mxk/czeXSGSmia Q7gDA29DkzeV2fi9DlGvQPjLmzhtxh0RrflGVNLnKBwSU2Y0Q+A6nq/azZ4XeXGqRzEH ZgW2A8DJEohm+bY3e6j9u8OurpXfSGyxVRjWr2NDBpuyIcso5zWVCASFhDO4Mdadoad9 MfustHl/ag+Go7CM9E3AXQpShSxkZKdhx3gEa55/tNz08txdxj8Hc1BSWNE7FW7HpewJ Pq7JdqZfGzSzXmu7P3T+WMiIbDk11pYXOvfdGzuM+D9nKksf7+leeMo+WDGn9A2iqCkR 64/A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f184si1400849pfg.299.2021.10.27.14.32.41; Wed, 27 Oct 2021 14:32:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238263AbhJ0Rv0 (ORCPT + 97 others); Wed, 27 Oct 2021 13:51:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:47848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231252AbhJ0RvQ (ORCPT ); Wed, 27 Oct 2021 13:51:16 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DF74A6109D; Wed, 27 Oct 2021 17:48:44 +0000 (UTC) Date: Wed, 27 Oct 2021 18:53:10 +0100 From: Jonathan Cameron To: Jishnu Prakash Cc: , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH V2 2/3] iio: adc: qcom-vadc-common: add reverse scaling for PMIC5 Gen2 ADC_TM Message-ID: <20211027185310.25552207@jic23-huawei> In-Reply-To: <1635264275-12530-3-git-send-email-quic_jprakash@quicinc.com> References: <1635264275-12530-1-git-send-email-quic_jprakash@quicinc.com> <1635264275-12530-3-git-send-email-quic_jprakash@quicinc.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 Oct 2021 21:34:34 +0530 Jishnu Prakash wrote: > Add reverse scaling function for PMIC5 Gen2 ADC_TM, to convert > temperature to raw ADC code, for setting thresholds for > thermistor channels. > > Signed-off-by: Jishnu Prakash This little utility function looks fine to me. Acked-by: Jonathan Cameron > --- > drivers/iio/adc/qcom-vadc-common.c | 11 +++++++++++ > include/linux/iio/adc/qcom-vadc-common.h | 2 ++ > 2 files changed, 13 insertions(+) > > diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c > index 1472389..194d7c3 100644 > --- a/drivers/iio/adc/qcom-vadc-common.c > +++ b/drivers/iio/adc/qcom-vadc-common.c > @@ -677,6 +677,17 @@ u16 qcom_adc_tm5_temp_volt_scale(unsigned int prescale_ratio, > } > EXPORT_SYMBOL(qcom_adc_tm5_temp_volt_scale); > > +u16 qcom_adc_tm5_gen2_temp_res_scale(int temp) > +{ > + int64_t resistance; > + > + resistance = qcom_vadc_map_temp_voltage(adcmap7_100k, > + ARRAY_SIZE(adcmap7_100k), temp); > + > + return div64_s64(resistance * RATIO_MAX_ADC7, resistance + R_PU_100K); > +} > +EXPORT_SYMBOL(qcom_adc_tm5_gen2_temp_res_scale); > + > int qcom_adc5_hw_scale(enum vadc_scale_fn_type scaletype, > unsigned int prescale_ratio, > const struct adc5_data *data, > diff --git a/include/linux/iio/adc/qcom-vadc-common.h b/include/linux/iio/adc/qcom-vadc-common.h > index 33f60f4..598a5d2 100644 > --- a/include/linux/iio/adc/qcom-vadc-common.h > +++ b/include/linux/iio/adc/qcom-vadc-common.h > @@ -161,6 +161,8 @@ int qcom_adc5_hw_scale(enum vadc_scale_fn_type scaletype, > u16 qcom_adc_tm5_temp_volt_scale(unsigned int prescale_ratio, > u32 full_scale_code_volt, int temp); > > +u16 qcom_adc_tm5_gen2_temp_res_scale(int temp); > + > int qcom_adc5_prescaling_from_dt(u32 num, u32 den); > > int qcom_adc5_hw_settle_time_from_dt(u32 value, const unsigned int *hw_settle);