From patchwork Fri Dec 4 02:54:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 337708 Delivered-To: patch@linaro.org Received: by 2002:a92:5e16:0:0:0:0:0 with SMTP id s22csp818535ilb; Thu, 3 Dec 2020 18:58:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/vF1YgRRIWTvutQSJ43WFenYD9dlO24t6GEtHSM2AoCrEC8s/ncueHTLIMmKzW3rpwr/D X-Received: by 2002:a17:906:3daa:: with SMTP id y10mr5137631ejh.23.1607050696552; Thu, 03 Dec 2020 18:58:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607050696; cv=none; d=google.com; s=arc-20160816; b=dTR48LqZuEQ2Jsp/nVcWC3bfx0nBVRuaqYeQLXhp2Cz8mBAWbbouG0HRzleyU1hdnm o4shYg4Cf+3/WI026ZlalXeD+LABhZfd+BjevF0ibP/udTRVU/RLBV5oj6RxOlIHzhAZ 0Tqcarnrs1bMuTlQZmNknsQUORh6Jz/zRhQeYXdau77sLreSN86O2ORd35IkO4XfwKY8 +LVo2hPHRnsv0jDs8lzktKKpBD+srLmU9lVkMRpkM+AXYja2TxLXQJKexibSFznzo59t T+bb2e81LSXTt9ikVlI0Et7PbSZmUQR4y17ufdae8JcZahqCt+KritrdrRIcWwD/f7hp I+0w== 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=kheJmCyDI4R5PgXqJsIVVX5lZh86mdMPpHXrUUt/fHo=; b=VD+mHQzjyI3kWYfEx58MaaRwybgmJAezBL1v4/QO34lKZCAn1ehOQdNIKpsyiDyJXH B0xPshiCvZeP8ECXi+lRaM3rMJkBMY4+izAHfnyXCpB/udSK+ECxEP7dGYIFY+2tz/ZJ nwjLNcEkWRpSAoQp/ALtT2LXpUNHBdA8WQpxdgu7ZocQ+s+vArGqkR+O4bUy1N0xTi+a GvRFJNoDt1DTc2XdZpQINq9Tg7Li5DzsL3R/Pc04dfGLgM178tAxRYBW2FAtefEbJJ3u FaGjGR+HmTx2HZx2YHQMDAGOrioWM8xX8NL3LOP6NB6pC5I4MlebNJ8OPEG5t9ffjcvH iK1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R6XRhBdo; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 i19si558396ejr.557.2020.12.03.18.58.16; Thu, 03 Dec 2020 18:58:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-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=R6XRhBdo; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-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 S1726488AbgLDC4y (ORCPT + 8 others); Thu, 3 Dec 2020 21:56:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726112AbgLDC4y (ORCPT ); Thu, 3 Dec 2020 21:56:54 -0500 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 4AA80C094241 for ; Thu, 3 Dec 2020 18:55:26 -0800 (PST) Received: by mail-lf1-x142.google.com with SMTP id s30so5723704lfc.4 for ; Thu, 03 Dec 2020 18:55:26 -0800 (PST) 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=kheJmCyDI4R5PgXqJsIVVX5lZh86mdMPpHXrUUt/fHo=; b=R6XRhBdoGrWXkV8N/DwEVhvjyVxFDq+6j6z5pACnCc3ycb0afXDbJdE91idETZGXcx JOko52r78Mtq601o7nd1Jo+lvMLQ9+4GOtKcgjNSY+1Isa7bC2jPVqSGNh/azmH43wT+ qnD1jOZpwFaUHQGuo4zFi8EUGQQAzbrE1PN/b4XCPpXWFL1dsbR8BL40v1Q6ynlsmnbc xwvrosg0BXiK5dBOYGZIjsIHinrOIkGPXhdZLfEdI/0ddTkUPeDoKqERIWzWhGEASrgU 2ByUHhMrFcPjKpycb5Iy8TtFALbEGk0YgO3pcoOA8QePnX6n5ZTBSlOhmpJPx5EPbLlG 3eCA== 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=kheJmCyDI4R5PgXqJsIVVX5lZh86mdMPpHXrUUt/fHo=; b=L26yy4Yiw44agnqY+xieUspchxOi+q11nZgZaKN3nBOgyk5hR80wqRr3stTQh+FNap J17uWmRjQLbUbBJJKVfAWlBd/nwSeNxLA6ca9plsOL1J4eQiZq99TGwT0qOxGVwFArB4 r28TO5yRu31Wc2HuIMEbomVAVmpO3lDRRv3SiYvrVs+zGzeYRcc7S2yG3uPslqT8TJHw YNKXFgYvP0Ms9megyLp79WswozkQBmcBqu564D6deGNpJ7k3u3bd0rFzswj5IDN9yp6T 1cSNyY/1cztm+fQd7qjdYAigGY847vs7BKGIJndYtPAh3Hye8DjrxX5iga+cU66CbPQK KDVw== X-Gm-Message-State: AOAM533lvbKTpVtTYUyK7VrB2hw3uV4ZJq3thTTdq7Vygxoi3quwJPrS GDAu7WXq6WboBTx3/TCAf1e7AA== X-Received: by 2002:a05:6512:36c7:: with SMTP id e7mr2696179lfs.79.1607050524841; Thu, 03 Dec 2020 18:55:24 -0800 (PST) Received: from eriador.lumag.spb.ru ([188.162.64.117]) by smtp.gmail.com with ESMTPSA id b8sm1131667ljo.68.2020.12.03.18.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 18:55:24 -0800 (PST) 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 v10 04/15] iio: adc: qcom-vadc-common: use fixp_linear_interpolate Date: Fri, 4 Dec 2020 05:54:58 +0300 Message-Id: <20201204025509.1075506-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201204025509.1075506-1-dmitry.baryshkov@linaro.org> References: <20201204025509.1075506-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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.29.2 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;