From patchwork Thu Sep 3 13:21:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 249018 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp518915ilg; Thu, 3 Sep 2020 07:32:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4abxeWl7GQ/YAZ3q9FD3W6kn+xH0XDwNNkFWQ7yxy4toJ8pMHBUcADgot2OKqebZoSr+p X-Received: by 2002:aa7:d785:: with SMTP id s5mr3354854edq.154.1599143534215; Thu, 03 Sep 2020 07:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599143534; cv=none; d=google.com; s=arc-20160816; b=dl+BWGe2nzAXmflyYj2cculJDt49wUQZrbNcDiZ4JDbj0mq+EvGDrjYzsrHTaFNA6k E/MpdZeVp1uIei9qyufHsy7TdKNMv61N+1BMAQFzyvvmW+z9JEbP+aDnGzWaV/jQQFWq dgVPM8sIxH3MofRWvaCAOTon4d+H4Xt/gdE5l0X/HKTcqjM6i5N75Qw2TdLpC1UXrqTo 8fG5RBuL+ndJJ85ycx5nGQFp84MwQUVd7IqBinqLA8zxXQSDZRHxSW9/AASOSmBy4g+b cv3rcnPQaJpOKJsTu8PLhwkj6UuMMq+UvphATi+t0hRL7hQx/CziF4Zo+i/vr471S7UG GquQ== 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=wcVYXgQ5pttw1IKCDgQFlSKYdGXdwjbBjMlIEbUjqiQ=; b=VI+vCZ2XAlorpKwnknXgOtI9Q1Snavt/hhs3I/I69RJgZlMWE+lc5j5oCzf1I58SWw 0jTTZva1JV+8dLnt4qs3iwqVYMwouE9Z6CAx18e7qTyIuSYDCB5bMaeN3JyfVM+lcFt1 cZQmKVIoPJPybXIht3Bkds9TAEiepYuXjOc5pDHiX2jh9KQvzFQlibjDoxGuLoC+3nle wD2pMzudvB5BtZaRjXmc5sURG3pedXhQTBC8RbDoWbybqkiyAs2Yzveg4CyS+BPn9A9F emPazOdpPMP7WbN9DHpX+MMDjGeWtjqZ+GApHoqaPF5tSxmKMErxsr7so12WZCohVFpi ayzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iZLw1CfU; 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.14; Thu, 03 Sep 2020 07:32:14 -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=iZLw1CfU; 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 S1729356AbgICOcK (ORCPT + 6 others); Thu, 3 Sep 2020 10:32:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729307AbgICO1p (ORCPT ); Thu, 3 Sep 2020 10:27:45 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4FCEC061265 for ; Thu, 3 Sep 2020 06:21:22 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id w3so3662647ljo.5 for ; Thu, 03 Sep 2020 06:21:22 -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=wcVYXgQ5pttw1IKCDgQFlSKYdGXdwjbBjMlIEbUjqiQ=; b=iZLw1CfUpf3zao1xXVpOnJTFOmznOoCWLAU15PeWwd16NwdTP2lGXLKN4iSi6eR0i6 x+zv7dQuz4X0lGxw64dYnfTCDF3jXrFctSGJ1Qb+QeNWWJToXF/bayDRh0USlB20xWU2 xcYHy9v+xKy8bizid6TCyu1VQ/i1vAn+ZYkZk2cstVoPua/zC/DG9cLE91kpZAc022QI inCfL8jDqhQIVS0+/YW/M0U5Dr2hs/eG2r2Kgrzagdw+hTG4alTmxvysUoOrDg9TsXa1 hV4inadOBaQVDQGWmHe6zE2vy9Oz36Hyl8Nt+CDAvzGQefDphw08x4xz00sppiHbMINu t76w== 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=wcVYXgQ5pttw1IKCDgQFlSKYdGXdwjbBjMlIEbUjqiQ=; b=OmWzIUemWkGz6lSNjGjY9oUWHxkB++7q/6IziIiArpN2r3pgImaGLwEjZj+eBeCKKq 3MOPBlss0VlP/yEmMa/LpekdetymMYAatfABLVVX5TjtqMG0gM56VS2rfTbWwbyFRfTD uZ8JFkjT2PiIAP+IRz4Zy6mnoxqL/4IYh2tBSRX3QNncIkFLHmJnftW29gs9cvAotvDD zyiOmfV4wXKsPx3UxkHEI9S5kY6BXPOUi6Ra9xeIAvSWBjRfJQHUFbyRZaMVq5OoWg+Z upU+1QwrljqZ1D8yhtx1prirS54waPcVcBP+vYT+42Ig/r6XPiZ652XwYelGM4U/+eLc LtJQ== X-Gm-Message-State: AOAM533Mk9FYC8U/GUqYwAmsWp+S4gLg3/Qg44WR82E1a1OX2YxDfjPQ jGj4qHdswrb1UCzGYHJiJ4Rw6w== X-Received: by 2002:a2e:8215:: with SMTP id w21mr1246122ljg.43.1599139280959; Thu, 03 Sep 2020 06:21:20 -0700 (PDT) Received: from eriador.lan ([188.162.64.138]) by smtp.gmail.com with ESMTPSA id e23sm584220lfj.80.2020.09.03.06.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 06:21:20 -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, Craig Tatlor Subject: [PATCH v2 2/9] fixp-arith: add a linear interpolation function Date: Thu, 3 Sep 2020 16:21:02 +0300 Message-Id: <20200903132109.1914011-3-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 From: Craig Tatlor Adds a function to interpolate against two points, this is carried arount as a helper function by tons of drivers. Signed-off-by: Craig Tatlor Signed-off-by: Dmitry Baryshkov --- include/linux/fixp-arith.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) -- 2.28.0 diff --git a/include/linux/fixp-arith.h b/include/linux/fixp-arith.h index 8396013785ef..281cb4f83dbe 100644 --- a/include/linux/fixp-arith.h +++ b/include/linux/fixp-arith.h @@ -141,4 +141,23 @@ static inline s32 fixp_sin32_rad(u32 radians, u32 twopi) #define fixp_cos32_rad(rad, twopi) \ fixp_sin32_rad(rad + twopi / 4, twopi) +/** + * fixp_linear_interpolate() - interpolates a value from two known points + * + * @x0: x value of point 0 + * @y0: y value of point 0 + * @x1: x value of point 1 + * @y1: y value of point 1 + * @x: the linear interpolant + */ +static inline int fixp_linear_interpolate(int x0, int y0, int x1, int y1, int x) +{ + if (y0 == y1 || x == x0) + return y0; + if (x1 == x0 || x == x1) + return y1; + + return y0 + ((y1 - y0) * (x - x0) / (x1 - x0)); +} + #endif 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; From patchwork Thu Sep 3 13:21:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 249013 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp489071ilg; Thu, 3 Sep 2020 06:58:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxexUu5uEbjYM7WFA5w4s8A/M5T2dh0jf+s+BO7wVMYWeKYTCFlP9/E4emWq4SyuJdtS+il X-Received: by 2002:a17:906:91d3:: with SMTP id b19mr2361928ejx.235.1599141506842; Thu, 03 Sep 2020 06:58:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599141506; cv=none; d=google.com; s=arc-20160816; b=W6mBnUYqfFnmLXEfXEa67FsNclOqxvXVRQu7TCjLKvFAimdWAKTXhUl6RDaDMajucm PDlAfHwHsrqy1tvI/ybMHvevCpIWqExnxpYSsNCRcdEpnFJMOLWcOlHesVGiHrFuAxZy z0eGvqgNbioxrpJGj4SvDkOdv2qHC2fFOCWQj5dMaADe+gCFfFMFkGcW6ZpS/uM+XClg ON1lqwutdcEfoTP82d92zuGIU8NoMjfy1Kf/8NZdsH/9vEarnNQDJ847OyxS8mG9EYQO CgUIWgn6jmQBNBKcA941tC8tUni8lNSPcxE3TVOn6F395vQsh3gB04c9aRXkLhS5esLD Adbg== 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=eKxx9jGOwv41qjM0dB2DR64F278mvrQpwsZT854Hceo=; b=dWNTwlPNGQIHEoZ0Gcx9wGy5sixP6mRCZ9lUGkgBjgZFq2Sd+H+OEhfNGI60R8qG4w gVcV9QXI2lwLGbv9GbKo9l31GQvH+mp+DIdZNL8Z/P0UVbEBpIh7M0NciCSkyNj6+xLK sTUmS0cz+/UIVyCMGSm9MRceD66go5zQ2amfQDqwu4sP1TURqyfS5y3YNt22eSIc7MSS CnrHfvySxVNkAAxcVNVECo3WOL0KBpQ/49I7tw/XEKGX4YDD2BBdx04/gIs39q3tUQ7p xvwJTcpQ1DdPle4kGfAzL22jImWs/KWknqp2zCOzKY8lBeL/kTPt2k1YLN3Z8KJjLRAM jMRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w+ydrhIH; 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 b2si1881646ejk.222.2020.09.03.06.58.26; Thu, 03 Sep 2020 06:58:26 -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=w+ydrhIH; 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 S1729020AbgICN6P (ORCPT + 6 others); Thu, 3 Sep 2020 09:58:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728984AbgICN5y (ORCPT ); Thu, 3 Sep 2020 09:57:54 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08653C0611E1 for ; Thu, 3 Sep 2020 06:21:32 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id t23so3690899ljc.3 for ; Thu, 03 Sep 2020 06:21:31 -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=eKxx9jGOwv41qjM0dB2DR64F278mvrQpwsZT854Hceo=; b=w+ydrhIHhZ7wYAaA63bRQsevdR50iFtEsb8N3t9zizNA4ETwHB10nMe+vAU7P/pGV8 RLm1BZPCz13ulabvQkJT2zXNnziM7Gbn4CXQQXSUHMyM6WLgX9WBIPJ4RpvARtMVkfYd 5G3O9e31Xqj731ZKim63bAAdFY3JLMAUnf9wwUmA80BQSOt9TT+t7eVw1uSO71xh4Te8 hIfLIcejfPKclZLi71jYQ9rBZ6ncsPpCXOlsv80gjMOsEl3fm0wf+M+pp4uhzHX5xm4g +Nvjl1x6k5ylV4b4y7YQudDuvRtl9Aoi2b7J0660+t3c0ahgjC6Ll22RzgKYUBkq65uK yb8A== 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=eKxx9jGOwv41qjM0dB2DR64F278mvrQpwsZT854Hceo=; b=RioWQg5EeAO+fMQNqcKwMk02PSn3xJ9oE96tBBypv3vHo1zrdI/T84kXYiD7Z3JmOF L2O0baH29+FSmYMgG2xvwqS4VZJ2XOTiEAbN65iMOEUwSdyZuNLVRAdoQzsMu0PyqppC 5LVcPRyAhOwcs9NtvRatr8GP2MtEOgM0iSiUVNZA1aN4Wo0CbJ93XeBG4EnJ/vKR0Hby odwNQHrORujxzg25x4B3wtMT65gN6ZWLTh4+zcj80qyW+dTcnHFkl2LKu6bZ7LxTrbQY 5OkyiO87xjdqy3NTTISv+pLXmV8FQh+6NMcnkNwojH4ZyPxs+Gqg5ljaI2wIwn+F/47W qAhQ== X-Gm-Message-State: AOAM530ygVEKVGMdysJZHUq0HhFF0ZZpVOTk+j1qxTp5r8VtlhCYZSyL BPbgV0KYqTZvZ2sloEI83C7qmA== X-Received: by 2002:a2e:a165:: with SMTP id u5mr1211994ljl.393.1599139290520; Thu, 03 Sep 2020 06:21:30 -0700 (PDT) Received: from eriador.lan ([188.162.64.138]) by smtp.gmail.com with ESMTPSA id e23sm584220lfj.80.2020.09.03.06.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 06:21:29 -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 6/9] iio: adc: qcom-spmi-adc5: use of_device_get_match_data Date: Thu, 3 Sep 2020 16:21:06 +0300 Message-Id: <20200903132109.1914011-7-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 of_device_get_match_data() instead of hand-coding it manually. Signed-off-by: Dmitry Baryshkov --- drivers/iio/adc/qcom-spmi-adc5.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) -- 2.28.0 diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c index c2da8f068b87..0ac0b81bab7d 100644 --- a/drivers/iio/adc/qcom-spmi-adc5.c +++ b/drivers/iio/adc/qcom-spmi-adc5.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -807,8 +808,6 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node) struct adc5_channel_prop prop, *chan_props; struct device_node *child; unsigned int index = 0; - const struct of_device_id *id; - const struct adc5_data *data; int ret; adc->nchannels = of_get_available_child_count(node); @@ -827,24 +826,19 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node) chan_props = adc->chan_props; iio_chan = adc->iio_chans; - id = of_match_node(adc5_match_table, node); - if (id) - data = id->data; - else - data = &adc5_data_pmic; - adc->data = data; + adc->data = of_device_get_match_data(adc->dev); for_each_available_child_of_node(node, child) { - ret = adc5_get_dt_channel_data(adc, &prop, child, data); + ret = adc5_get_dt_channel_data(adc, &prop, child, adc->data); if (ret) { of_node_put(child); return ret; } prop.scale_fn_type = - data->adc_chans[prop.channel].scale_fn_type; + adc->data->adc_chans[prop.channel].scale_fn_type; *chan_props = prop; - adc_chan = &data->adc_chans[prop.channel]; + adc_chan = &adc->data->adc_chans[prop.channel]; iio_chan->channel = prop.channel; iio_chan->datasheet_name = prop.datasheet_name;