From patchwork Wed Sep 9 14:42:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 249521 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ecf:0:0:0:0 with SMTP id i15csp2811ilk; Wed, 9 Sep 2020 09:49:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcTW4S1JoGqXwjYm9yX+M21LDtRC83GdYVNMCAZt3848AicKdkWAUs3inn+2qijRn/6ael X-Received: by 2002:a17:906:6b0b:: with SMTP id q11mr4740116ejr.412.1599670179048; Wed, 09 Sep 2020 09:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599670179; cv=none; d=google.com; s=arc-20160816; b=JNHou8dHEyPcVYv3ptXVldbcnfIlwaE0pjCGsAabg8Iiw/BGn2dGLtPnGjxG2mooH4 cijeiKG0YlLK6Ct013c5553LU94/TCF6HMRuDBU8RKcIaEL4XDrbsf6j39e2zQiH3jMy +ZwWiDPxmYFuIpxMMUK1r2wNl6/t+0rHVRQLu3oMmCC8mbFRqMvkH+gz0bGNDfdhfZqM qIueMPDKAspyuy0qJXddkcBxSS1V4/oQDP9ZxyYepi8innfd7BbvC2nyUphoCIP7rkcS RH7WvAIOZC7mV4cSzaKJXOqRMaGXE2F7dS1/8SpXNza2u7xqXJD2t3HzmTDN46i5cwpt 51VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SyrNRlrzgocwFtm4m1D+vgyjZWlJZcz7p/Dz+/oWD3I=; b=w552Z23W9NFF0rw6njZGfuqFpMLZJ35o+TATrIms/sxU8x0aTGht0yITCwNKJPBWun +ISg/4juHcTIZXCYrYl3OWg8Ok4zJM4lWy2J1K0rz716wg7204AgqNCZE/07jQwwsN8B ORic/FxSvesvyoUTX4+i1W60q62cgToyXAOKqhmbgCbyWDeSagClIbCWS6F8ZPAjVs9D keFDI715C98bF7S55J8fkrjew1jih0Cr1PUO6lRVj+wsPk6UhZ04lFlMaSt0lYJKCagh E2goEU8+UPrJ87zQ/Fq94+QX1WvTOQxGuy2Kl8aZL8onR+DTQZjY9zS0DW6QjTjnE4KU pCEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sOj1ib2k; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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. [23.128.96.18]) by mx.google.com with ESMTP id ot13si1845217ejb.450.2020.09.09.09.49.38; Wed, 09 Sep 2020 09:49:39 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sOj1ib2k; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 S1730625AbgIIQtf (ORCPT + 6 others); Wed, 9 Sep 2020 12:49:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730922AbgIIQHR (ORCPT ); Wed, 9 Sep 2020 12:07:17 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 824FFC0612B2 for ; Wed, 9 Sep 2020 07:43:14 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id a22so3848862ljp.13 for ; Wed, 09 Sep 2020 07:43:14 -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 :mime-version:content-transfer-encoding; bh=SyrNRlrzgocwFtm4m1D+vgyjZWlJZcz7p/Dz+/oWD3I=; b=sOj1ib2kl2SlVlUTM5hhtz7BMqvh2WSXwUCwvheygvKndh2ngHXDqcKNoc7mj8tYZk 01QtqZ0bxAWLEZ4WudeP6XKfC77xSfbEuYiJKkkb4u5AvEE7P6POu5pYSNWs8+yKaxd1 GfGyBAa6JywuElKfh3ASexqtPzVXubBXKO+KNhas2UbpFdGmVoNm16aURJLVm5M40p/p BUwT0qHygUiWcMVE03rPHC0/8QyZe2jyWehhW1WILAYmQFQcKv8Xc9MnhBNz5ok+ftQh T4K9KDD0uYhSoIAa0AcWpgL+oOXEklu53fwye3Tdx6FLAYax0gpgboJMl6zeIT2h2WF0 fIDQ== 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:mime-version:content-transfer-encoding; bh=SyrNRlrzgocwFtm4m1D+vgyjZWlJZcz7p/Dz+/oWD3I=; b=XjW1gHkYVgxx4umIZm98bdFRVMJHxiPP0klmKTqvIKGLv2kECe+ZuqX0qQT/VtpJ5L 5ote8YUqnhYDZtikbMWb0OoorWWd5DVwFLzUu2Fi+KhuPLlgtY1+Q2p+YrzedOUHQs5+ 6hYTI5mfYnRZetXbvDDFHv4f0iciT1jgNZy7V0FG0cItu7c6udTxvgqv+/Wopyr0x5lh rnromQP5VhRm6UUWANMQ46LXRH4ujixRcXO9m7rlQUY6LeiqWWZbBOONqTZx8PU3qghO 2jrxXF0qaKEmY8xFC3axn1gNwpoqF2d+97u8RwZlfSBi6BWx/sNQ33/5S40eb2ch2Ol/ S9uQ== X-Gm-Message-State: AOAM533VG6IQ0iVRwypozSXKjX4s5+WNe/Or5mdsYw3gLa1/BGe1pOub 749Ct+FdR9tKKNRNBvE6qFgmVQ== X-Received: by 2002:a2e:8798:: with SMTP id n24mr1956427lji.373.1599662592137; Wed, 09 Sep 2020 07:43:12 -0700 (PDT) Received: from eriador.lan ([188.162.64.155]) by smtp.gmail.com with ESMTPSA id t12sm621665lfk.26.2020.09.09.07.43.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 07:43:11 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Rob Herring , Zhang Rui , Daniel Lezcano , Amit Kucheria , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Manivannan Sadhasivam , Jonathan Cameron Subject: [PATCH v3 05/10] iio: adc: qcom-vadc-common: use fixp_linear_interpolate Date: Wed, 9 Sep 2020 17:42:43 +0300 Message-Id: <20200909144248.54327-6-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909144248.54327-1-dmitry.baryshkov@linaro.org> References: <20200909144248.54327-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Use new function fixp_linear_interpolate() instead of hand-coding the linear interpolation. Signed-off-by: Dmitry Baryshkov Reviewed-by: Jonathan Cameron --- drivers/iio/adc/qcom-vadc-common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.28.0 diff --git a/drivers/iio/adc/qcom-vadc-common.c b/drivers/iio/adc/qcom-vadc-common.c index d11f3343ad52..40d77b3af1bb 100644 --- a/drivers/iio/adc/qcom-vadc-common.c +++ b/drivers/iio/adc/qcom-vadc-common.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -368,10 +369,9 @@ static int qcom_vadc_map_voltage_temp(const struct vadc_map_pt *pts, } else { /* result is between search_index and search_index-1 */ /* interpolate linearly */ - *output = (((s32)((pts[i].y - pts[i - 1].y) * - (input - pts[i - 1].x)) / - (pts[i].x - pts[i - 1].x)) + - pts[i - 1].y); + *output = fixp_linear_interpolate(pts[i - 1].x, pts[i - 1].y, + pts[i].x, pts[i].y, + input); } return 0;