From patchwork Wed Oct 7 13:54:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 285121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9FDFC41604 for ; Wed, 7 Oct 2020 13:54:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 931D22193E for ; Wed, 7 Oct 2020 13:54:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="uFtBURH+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728571AbgJGNyz (ORCPT ); Wed, 7 Oct 2020 09:54:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728540AbgJGNyt (ORCPT ); Wed, 7 Oct 2020 09:54:49 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67245C0613D8 for ; Wed, 7 Oct 2020 06:54:49 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id d24so2374539lfa.8 for ; Wed, 07 Oct 2020 06:54:49 -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=uFtBURH+GBLaevo8g6cPWDqH7zEiO6ttieUedSBQrZea4Hlco0FLbEc5lMRvQv5Mo4 haQjIcg8xsZJzUID+l/b03Y3RmVN4a75yZaxf9dp6SvF7Be7dfm1R1LML3adXoh1Cag2 SZb2fL7/Hiy5QUvkDvRwLjcWeqPO1MrK3d6Ou/re6j71emqaPi+OVNPofZBA7drL+na/ ac91wolwQrvZd1zs4ay9ERrSLhW14kiaGK7QnjQRQn0Xp6C5XxFFYHxk5QhUh8lZ2qk8 wiDbobfDJjpr/Wx18Ne8HtD9SZW+d/KT6Uy1p/oyv4V5Jk/YIhsYAXU3RbI0N/Zvc6mc kRhg== 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=UCV522Xp5Hz6uhIkOslX8TSIDZ7WwtDER4gjU/Uqh6CMlTH9LAzKBnfp1AWtHYPrsD qk42azmG3cXZcMMcenHvkyMqgIy0TAFhuWgxFigD1LyVU26fLcRTG6OnOfJJ7l7lPQ7G wMODxdGqRAzxpt9qaOeT7dx2hxnVQzE9I0GA5Tfa7VaHtJ7xpw6dsTjRV48exjV8MFHv qc4ffWuJHRAO4OlbYxG7PY3ScLvOo0rAeuw0FMowHYZvYcM3xhojOGqXXIaa9/Q9VKgH +elPp3/vz/lQdl/8S6xp2T5oir5i4b/Ub3XUXyDWSh7BVQjypC4TW+hTgDY1Dxiakumf 20oA== X-Gm-Message-State: AOAM532Zes9f7lilOGdrwKO/fux7Eg8AAx7Bz8GQGqG14zteIRG2dY3Q vZrsNXj4VbyYwpLagiDGtoSxDw== X-Google-Smtp-Source: ABdhPJzbO3zNETMnpVpRvluAZ6FR3Gy1w+BTC/UFV5bpDYMWQfx0bDAXQGzVWG9SInalGLksvjGkBA== X-Received: by 2002:a05:6512:3702:: with SMTP id z2mr926943lfr.35.1602078887854; Wed, 07 Oct 2020 06:54:47 -0700 (PDT) Received: from localhost.localdomain ([188.162.65.250]) by smtp.gmail.com with ESMTPSA id n3sm339768lfq.274.2020.10.07.06.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Oct 2020 06:54:47 -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 , Jishnu Prakash , Jonathan Cameron Subject: [PATCH v7 04/10] iio: adc: qcom-vadc-common: use fixp_linear_interpolate Date: Wed, 7 Oct 2020 16:54:27 +0300 Message-Id: <20201007135433.1041979-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201007135433.1041979-1-dmitry.baryshkov@linaro.org> References: <20201007135433.1041979-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 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(-) 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;