From patchwork Thu Sep 10 13:59:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 249624 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ecf:0:0:0:0 with SMTP id i15csp778694ilk; Thu, 10 Sep 2020 07:11:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQVTi0ojzKAJijswacLy2HnDRZaquvwArWbeYxH1VO/QK3uBI610+IZSnTiQ9xW06iy5in X-Received: by 2002:a17:906:194b:: with SMTP id b11mr8789207eje.159.1599747080756; Thu, 10 Sep 2020 07:11:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599747080; cv=none; d=google.com; s=arc-20160816; b=PcJwEoxgG5JLjRAkjgFfhq/PwFqYT+kKBFeErSCkYb/atPwgewnUfl4V9DBlRIaISR XyHwYu+xgwjvqHvyfSg6M62kPHUhJY981GMC9T/qxrcv1O5XYgb+GIVH4jeBv/5AkGCy b8ZsL0ylgXSwiCgpDxS2cyER/DpksZLdRUnHCQJEJ7mpxIXCJgsHqHHTki+oiZyc8F1x T6TLBzoc/0FI6i11PWPUmcKVqIVfNeA3cfPL5XXul+zyPq6tKoSd6AQy+Cn0lCOnteQS FBz9MacvPI+UK+y1PKaLcya8bzF1ccMeg1b4YuQCnvmW4M7A5vy+2HEZltwC/5ireRoA meBg== 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=zshmthP/CGPlhtu5OrE+Te968almCBvqGJVdDcgskLgEnGC3ZsLoMHGq/+4EUsgTfR BrxYrtiTF7zf+3K39aucX3Eh0ybBbAmGJaD2mjoV5tzS4jXak1ohiejtG6xMPfuIHV31 PpDHbOhO/jL4cprQu7nrYUmYSqoCX0SUFj/gk9gY+nZ7NmJEEZa5ugK7KqXt/HZv2RfV VF2udxJJ//Euy4MnXFRZNNSWTkjI0CHcmvrmXYCNAT0XrrCI1x3pxwsLRyPLJHlKlzWT PxyIt/qZc46/tyTfa4pqiPhb/0uqUU/O/KeHWQdzQpL4T1iD+i85tnLo+TVCVWkU8FCZ IwTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WF0RXK6c; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 mm8si3443087ejb.53.2020.09.10.07.11.20; Thu, 10 Sep 2020 07:11:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-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=WF0RXK6c; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-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 S1731120AbgIJOKt (ORCPT + 15 others); Thu, 10 Sep 2020 10:10:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731077AbgIJOJf (ORCPT ); Thu, 10 Sep 2020 10:09:35 -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 C16CAC061388 for ; Thu, 10 Sep 2020 07:00:20 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id s205so8314334lja.7 for ; Thu, 10 Sep 2020 07:00:20 -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=WF0RXK6c8RUr2Gomx+JVCl+LBDxVEGYpbxBgRK8Gx0gn8zhmt3BN9srE7t8MhbR36t H7R4z8lqw02iAe7fQQl7pweGAvYqC3fPDjYtGI8e2ECcgpCdaB/1AKXbQKiMLsUopkTr 7olOfskIpfCiUTYTTPob51oBFFRpjtg7JncF5hGhOSp9s2XtVjIFh8bwhevkxBps24P4 tv0msa7ig32jl0QSDxoWT5ZNrZulNIKpnmO/IvQeXz1vRGqkLtKe5LddEJor6fQ9Bone 5TpcKBzHslKPHz2C4xhDjmx+5SWWmvqLHZuIv3NN24XoWDFGfttsWxBYXtv4N6AhRV4D yVHg== 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=VZZKJZ9aw2G/YzrJ3rB4fruVie9PYGr6ir9C6vjdMEEDJwMLp537ksnGc+KbQaDCUR VZhlW0bsrALYXm3UdkjJAdWOf+xkSt6VIxCXWvyXgrdd4H5qkzyo+/1F6YaHkOfMxVAu 7AH+a/LWeB5rMVlk2pmO01W6OJ2rfW87SezYglxr0TYB01DkmW9jZ1Jc4Q4rYQ3vOPFv ZMeEZaDr1anWN37U26Rg/8+bplybwvTLB69Aa/0XfsWz9WIPvsEAESkCvSKlN+s6+aqS dJm5NRGsn+n07vnW0Vzjm9TK1nt6bG3ETRVnvVo3KOadQ8b3LM0KjAXao9vjZGHB58tN 22TQ== X-Gm-Message-State: AOAM5330o1cZeUvLCHKpHqM46OlKYM/pUCXP/A7p6g7ZT0y/P+6nPXMD VoYub9i3OKUiaZV5X5SUilYvjg== X-Received: by 2002:a2e:b4ba:: with SMTP id q26mr4146902ljm.79.1599746418934; Thu, 10 Sep 2020 07:00:18 -0700 (PDT) Received: from eriador.lan ([188.162.64.156]) by smtp.gmail.com with ESMTPSA id t82sm1367646lff.43.2020.09.10.07.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 07:00:18 -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 v4 05/10] iio: adc: qcom-vadc-common: use fixp_linear_interpolate Date: Thu, 10 Sep 2020 16:59:55 +0300 Message-Id: <20200910140000.324091-6-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200910140000.324091-1-dmitry.baryshkov@linaro.org> References: <20200910140000.324091-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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;