From patchwork Wed Sep 30 10:01:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 313881 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:1081:0:0:0:0 with SMTP id r1csp47894ilj; Wed, 30 Sep 2020 03:02:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWVefJ43AQxrg+6TkLgZyaXCaREJ8AablYGSSUznQw0whgqOI8hQaF8bn1YioEuEXjdgdh X-Received: by 2002:a17:906:1f94:: with SMTP id t20mr1986651ejr.493.1601460152675; Wed, 30 Sep 2020 03:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601460152; cv=none; d=google.com; s=arc-20160816; b=tMjiL3GfPvcNhui9fabV1vsqqmRsw2GGfcf13x25N3RdUIhlSZ5n6Ulkq3lZltayaK HNYgG7KPlxEc//W+VBRm86eiZepcIV0HsYWgMc2dPnRX8f7XePqMmixNqoC6HnaWjuBe v29/jA6gb73XYW8FYqfxhCbhG0Tq43L9g2xYUw4f8XpbOWZYX3QMjvZ5GSMRMjKiulSk tX3YqF1UJ12vHfb7tqXE/s2YkLS742z0dwwpwc1xUyUVpRS5HquU3uI+ponPgaw0AAH+ 2Br51sgzk27bXL9h5ZSoG9Mh6XYrw7sgZhCIo6aVTSXWShGYLKsbX9P0Cn7ZN3V/Ns3r OPPQ== 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:date:subject:cc:to:from :dkim-signature; bh=SyrNRlrzgocwFtm4m1D+vgyjZWlJZcz7p/Dz+/oWD3I=; b=ziANiwQBHPGT2Z4RVcWBk9p+byQ/3Fj425gXzJE6ICNw8cUf0pbujP07aQYY1Vb69R DP3X5o5lkFw360Z8KzPCi92mt92jD2aHQ6Fe9JnMGeupJPn2Ak9rRG3glUAYuTeavO0o ByWc9iRcwiDqmQA/nQZEUH5eDKDsbdIQcCGovvwnzknvhLqE8hmgHrqNjLQQfV2D5FaT OaQZUpG0XA7D0G5MF2/YOWkG0l14fwsPCI+wVdrJ7dkSE3AZlH+kn8pevhhnbzM+ZdYi EwUcN+V+X3QiVGMbGa48sR/aSWkhDarUC2RxAw3BXAyJhHyOe8xsdmf1asrmw9CMs2vJ aXmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=m0zpqotB; 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 o23si797422ejj.533.2020.09.30.03.02.32; Wed, 30 Sep 2020 03:02:32 -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=m0zpqotB; 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 S1729353AbgI3KCa (ORCPT + 6 others); Wed, 30 Sep 2020 06:02:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729351AbgI3KC3 (ORCPT ); Wed, 30 Sep 2020 06:02:29 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59448C0613D0 for ; Wed, 30 Sep 2020 03:02:29 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id y17so1397048lfa.8 for ; Wed, 30 Sep 2020 03:02:29 -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=m0zpqotBVnmz/7C8jVSYyhqZBMEXJh33+flGjkdUOMwY+pgk0H+RmC2MBTAIFR3JRo CHWqmgecP0Qv0I/S7mtJLJxoNK91cr33eDtF7KO75/f1K0vuwtuZ5SwyGmGa7GsMqYgY hjaNrynyfZ42TSGgRaiM+UkCOAUcKWJVa+Pud+OZjbay3TBKBmTpp2/JkUXaCGykRORG VwSIcFz25PnTj8FkpIhrWtXpwV0djWXXs/MNnS85wSy7h8gyFyTlVqno1b7/XqcukJea uJOG7J2FiJZK+qd4mwUM71jT9a6Ezn99yPMBzge7LSFhrD+pLrSUq4MiKAwpNAOzQQuM zZkA== 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=sgyr7EduUMdrZhl2ySKIzgoOD84/3dZLszu70HVL4WMuBWPv5OG9+sJcJoVBQ0BsNL ZJbczVX823jJvR8cLb2puKIQ+DIQWutbw+LWrZOq1mE1WyemkmVLToIZvKJ5GmzOLxYx Yqd3s9QTtku/ybUAAJrY3P77nsSsLrI4WTZ2iV2A4Xz/PoctIpJu47cipl8GTwe8JbIb LIY0Exwmx04rj1XnU46ViVcOTtBhFm1onIpo+U087eDvg5Ta4+71v1NUjwtIaOEm2vxT dxng65j+uRuWNOGGWcMTiaoFMfVpeEr6RlwWcHuUdhYxDfkRYEaYVceFb84dCEsN7b9x YAsg== X-Gm-Message-State: AOAM533QsW2UPp+IYSrU+Gj/xBPGYIFDkxsy6jBH5GQfOtEeLxdoGRec RhRn1JfDd6/8dMn3pqHw/+IidQ== X-Received: by 2002:a19:8c03:: with SMTP id o3mr550531lfd.349.1601460147807; Wed, 30 Sep 2020 03:02:27 -0700 (PDT) Received: from eriador.lan ([188.162.64.138]) by smtp.gmail.com with ESMTPSA id w4sm132479lff.231.2020.09.30.03.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 03:02:27 -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 v6 04/10] iio: adc: qcom-vadc-common: use fixp_linear_interpolate Date: Wed, 30 Sep 2020 13:01:57 +0300 Message-Id: <20200930100203.1988374-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200930100203.1988374-1-dmitry.baryshkov@linaro.org> References: <20200930100203.1988374-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 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;