From patchwork Thu Sep 3 13:21:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 249017 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp518893ilg; Thu, 3 Sep 2020 07:32:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW9LpK+u4fRc0YdxehGft3NJIEUj2pGI3MsvivlQ34ogEEFBau7R/aWlnN56Ij1D3+uca5 X-Received: by 2002:a50:fc0b:: with SMTP id i11mr220096edr.164.1599143532031; Thu, 03 Sep 2020 07:32:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599143532; cv=none; d=google.com; s=arc-20160816; b=UqKcuxpcMBgZpdiCWMqrMOxLs2rrQKyUCstFpyplaxhAuO4MsVpi5Ugj0XyXYCqoLR mHeHISSDh1oZj4u56lGD70kPIE+Fec2DkLy6L9KLJrvGWeJdQVWnVumI1JoNhSA2//N/ DhsTJ63hXUMP+nEeC0qFYQLlyMHWFAuUJFcroOwpHgvdnw5l5qwh8a/6Q+FTfbvaSAeI xjHkiCu2vhBeYaRZ9kiGwIAT3Kcr2w5ZVPQX2cjfgvaZvNv+cERqIrKUEPJ7TVQ/eRoO G15qTEoG1HcmSrvBzVKvAyHpiNNAzinlbYLIGMmHe42DyAYBsrmBCGIY0bls5c1r1nI7 FJHw== 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=cQm3Ei3RR3aCnHJxoCJd7GJ9tvCqsDDg7qVL7cbFNi0=; b=Jewd9ayiz6ZPoBmYMmVbpSTsq3T+A0raFjcI8kxqqzcsDB8dQGNNnw6SFmdm5lzaya DN8YCchrtRUzM00axhm+UFMJ6O+3F6PxyM7L3YH5W47RvDNMxsfuZAicZm0WqG2nH6XV ANZZE8ZE5IgGj2SgmH05LFVWp71QHAU6BVI+/7Z1RNHvJx48lwLsP1cF0XtDMMzvyd65 R8u/vhhk27YgZSnRWA/qQxouGo1fxTlUDewLFgbqCPwbg77n8Xgz6V8WaP+LvwQlIHcR jxUZJf/m7lYaC8cZkoUB4T7nYsdHm/nnmUoW4ne0J7429xaK1vpU0hPMa+inFI2PZWNp +tTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="oKaX/2FC"; 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 e19si1787538edr.7.2020.09.03.07.32.11; Thu, 03 Sep 2020 07:32:12 -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="oKaX/2FC"; 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 S1729339AbgICOcI (ORCPT + 6 others); Thu, 3 Sep 2020 10:32:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729305AbgICO1p (ORCPT ); Thu, 3 Sep 2020 10:27:45 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DA20C061237 for ; Thu, 3 Sep 2020 06:21:27 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id u4so2790142ljd.10 for ; Thu, 03 Sep 2020 06:21:27 -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=cQm3Ei3RR3aCnHJxoCJd7GJ9tvCqsDDg7qVL7cbFNi0=; b=oKaX/2FC4xi8AE7Tbxleo6PkivkbjAs99jM9XHwwgd/JkCPtx7AsDJpisNurdXjAML HV3qLDwG7aixk5Sjw9q2R46BnWfN/LmST0aWGeZxQt4xEEs2yXkB7FyD2TKZgNatA9AM s5lQWS3jU7k2pJUW/yF8PzRbyvDQCvzB6zuINPPYkVWfhyMZWDqEniEFtL3QDRGL1iHO hlGIQci4gMdWmernvAlbqwZsZ/TuI6FaqF/63gnR4jLato/32yFOvDFRwVeUbOVGGQNr KyszmvxYZpLU1tQM3ziJ/SvokV1dNgKFnNWoAPcIHD9NeyY9Ss7ArN294b2bL1+hUyMu q3nQ== 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=cQm3Ei3RR3aCnHJxoCJd7GJ9tvCqsDDg7qVL7cbFNi0=; b=ptnsdTPdrfe+oPNjv2/oEIr+AASwnt5n6/L1nGKJnICYubKB4e0FxjkRGYvSY6F8O9 XMfqbuf4Xyg3ZBDB50a6vc+38qAz2zPUoC70WdnxCPZNVBVW29mrsewAQ2La08Tsbibr eewWYl+IuAN7rdlwyXFf/zCyejOHDLSwYRbP3W9cYW4G2YiygJHEzUO0gctk19y0BK4T pt+emnsDQdE4ZYzmVpXJSe62PRHTxqQxDyAAbVH2Sshsyf90yKWNtBuXlomCYeFC3YfB B/zhXFZjdwzfsVMnvamz8ZZOPxzKJ5cftc0CI3SoBt/zpYAaOJpzfmcKS3vIpLfCpq+T 3wwQ== X-Gm-Message-State: AOAM530i70sHS22Nmbsz67/jjv+M7iflPFkOt1k4P3oZk/3A5CKPT9f5 KG+rIV3H4GPE4FS1DdJKNd8PAA== X-Received: by 2002:a2e:9d95:: with SMTP id c21mr1263833ljj.359.1599139285839; Thu, 03 Sep 2020 06:21:25 -0700 (PDT) Received: from eriador.lan ([188.162.64.138]) by smtp.gmail.com with ESMTPSA id e23sm584220lfj.80.2020.09.03.06.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 06:21:25 -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 Subject: [PATCH v2 4/9] iio: adc: qcom-vadc-common: use fixp_linear_interpolate Date: Thu, 3 Sep 2020 16:21:04 +0300 Message-Id: <20200903132109.1914011-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200903132109.1914011-1-dmitry.baryshkov@linaro.org> References: <20200903132109.1914011-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 linar interpolation. Signed-off-by: Dmitry Baryshkov --- 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;