From patchwork Sat Sep 22 22:21:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10611589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7DB7214BD for ; Sat, 22 Sep 2018 22:21:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BAD52A86B for ; Sat, 22 Sep 2018 22:21:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FDF92A8B1; Sat, 22 Sep 2018 22:21:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA9212A86B for ; Sat, 22 Sep 2018 22:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QYQILtxR2LkInl4oJkiXxa79S7fCjNxSUecEZUhwXmQ=; b=d95M9yIzr1cDCK K8h/XC7kxlxu7QHc/aOlnebw2l0z3np42BXD5mcsg5BVjhft+zr1CQ4Vp+hWpYqJaAZdxKqMDCHGF HHUQMC+EuRGtMxGw8gDI21/TLj9AdzbxFoqKxcrG1rWHUxb96fPTlEdc5R6r6i45/d1pK0CXgvU/R pbJSEcSESt/Qw3joTriGTEZPHeNuecOl7MunJHROwiLwmei/QJwJELFzWNvBEvGykH8mHxW34CzeQ MZML7C2u0DMsLkbr91hQKBH+WnB6ckPlpqDUoZkr+FznctGEICHqnLjOlhpz9mw41ereY49CCbHJH YycLo0Y3Wer5tAhk3YYg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3qHR-0001VR-N6; Sat, 22 Sep 2018 22:21:37 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g3qHG-0001Pp-26 for linux-amlogic@lists.infradead.org; Sat, 22 Sep 2018 22:21:27 +0000 Received: by mail-wm1-x343.google.com with SMTP id y13-v6so1817129wmi.1 for ; Sat, 22 Sep 2018 15:21:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5rgz25HDQtZ85/zPXPgNYfobxw8jeZ5e140Ni1THgpo=; b=gcRiGapIYsT9I/JRQWCRADIm16CAln7vnz3X/YsOPh+4IEmGGjJhdHq0aOssqDhO3/ z7KbcJReo3yO3whMUDj7TQvMVA2ay9AdYZ1klABBWbxKxEmIPaWHqqbbUu1Sjk9/Z2pe C1UaW/MSWw7HLerl9GSwzS4iNRkO4a8OxRhKB7s7blFoTpkG8FXSLI8FkyazS9GGzlhs fwcXeqb6AdOB8mxgkiHt1sgJ7QoF7Yit0vNAql30kgvHACuNiJ9qTgAdcA0H2KEjLmIn f7iB53StFrriToXeLZGwKswS+uXEB/xR1OIGP6UfjTSqmSGpWHCslWWdaBGpfGYgMib0 mMZw== 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=5rgz25HDQtZ85/zPXPgNYfobxw8jeZ5e140Ni1THgpo=; b=NFJmhpDLZuqeTImJgMxw1q6d110a/d8G+dNZzV6XALKJ8GS23wjRW1rUT+xPB2+zrd Y0XbFSKf10rky4DB2Y3R0RskAGfVGyZU4QHYH2ahxulyrpK7yaTzD1V2JTMc0oUCcBvN B10z7UyD8x/0AH+efgawy1y9u3odwdTLGKX8SGRsXEYLzSdsCUyaWOsTzSgxnHoIqOH8 gOxBif75wJnSScho6TnyCMStBEaZqu64VSytxLrMnZpZmwIVRg893AHAmvD9kiBqhxpb d4CfgNJVgez9Bsr38qd67S4E1aQEivAxbdcLx+ANuiz7UIoiVsa6KD5r93DDZARt6iNV TWWw== X-Gm-Message-State: ABuFfojQIBMTcQJKc6aRfcVmyHNLKx/XaYwSRnLnqdqBlEou2JTAASVB v/QizMQtNvAjJxCNZsv0n/UIdxdc X-Google-Smtp-Source: ANB0VdYU1/ttBlC9AHGbSnjNnoIIcg8wiquGCmSSHUoCsNQhQr03dYGYGnxkglSxm/3YiAbjHQUX/Q== X-Received: by 2002:a1c:9215:: with SMTP id u21-v6mr2474545wmd.106.1537654873854; Sat, 22 Sep 2018 15:21:13 -0700 (PDT) Received: from blackbox.darklights.net (p200300DCD74AC30035FEEB5F4EC70873.dip0.t-ipconnect.de. [2003:dc:d74a:c300:35fe:eb5f:4ec7:873]) by smtp.googlemail.com with ESMTPSA id l16-v6sm6395499wmc.38.2018.09.22.15.21.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Sep 2018 15:21:13 -0700 (PDT) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, linux-iio@vger.kernel.org Subject: [PATCH 3/3] iio: adc: meson-saradc: simplify access to meson_sar_adc_param Date: Sun, 23 Sep 2018 00:21:02 +0200 Message-Id: <20180922222102.12023-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180922222102.12023-1-martin.blumenstingl@googlemail.com> References: <20180922222102.12023-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180922_152126_098449_359D2811 X-CRM114-Status: GOOD ( 17.54 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Martin Blumenstingl , lars@metafoo.de, pmeerw@pmeerw.net, jic23@kernel.org, knaack.h@gmx.de Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 053ffe3c8cfe31 ("iio: adc: meson-saradc: squash and share the common adc platform data") put all the data which is needed at runtime from struct meson_sar_adc_data to a new struct meson_sar_adc_param so we can re-use the platform specific configuration without having to duplicate everything just to change the name. The only place where struct meson_sar_adc_data is now needed is the _probe function which has to pass the name to the iio_dev. All other functions only need access to struct meson_sar_adc_param. This means we can simplify struct meson_sar_adc_priv. The goal of this patch is to make the code a bit easier to read since this removes one level of nesting. No functional changes intended. Signed-off-by: Martin Blumenstingl --- drivers/iio/adc/meson_saradc.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 9d8f2139debc..1c4ba83c0725 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -234,7 +234,7 @@ struct meson_sar_adc_data { struct meson_sar_adc_priv { struct regmap *regmap; struct regulator *vref; - const struct meson_sar_adc_data *data; + const struct meson_sar_adc_param *param; struct clk *clkin; struct clk *core_clk; struct clk *adc_sel_clk; @@ -279,7 +279,7 @@ static int meson_sar_adc_calib_val(struct iio_dev *indio_dev, int val) /* use val_calib = scale * val_raw + offset calibration function */ tmp = div_s64((s64)val * priv->calibscale, MILLION) + priv->calibbias; - return clamp(tmp, 0, (1 << priv->data->param->resolution) - 1); + return clamp(tmp, 0, (1 << priv->param->resolution) - 1); } static int meson_sar_adc_wait_busy_clear(struct iio_dev *indio_dev) @@ -331,7 +331,7 @@ static int meson_sar_adc_read_raw_sample(struct iio_dev *indio_dev, } fifo_val = FIELD_GET(MESON_SAR_ADC_FIFO_RD_SAMPLE_VALUE_MASK, regval); - fifo_val &= GENMASK(priv->data->param->resolution - 1, 0); + fifo_val &= GENMASK(priv->param->resolution - 1, 0); *val = meson_sar_adc_calib_val(indio_dev, fifo_val); return 0; @@ -450,7 +450,7 @@ static int meson_sar_adc_lock(struct iio_dev *indio_dev) mutex_lock(&indio_dev->mlock); - if (priv->data->param->has_bl30_integration) { + if (priv->param->has_bl30_integration) { /* prevent BL30 from using the SAR ADC while we are using it */ regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELAY, MESON_SAR_ADC_DELAY_KERNEL_BUSY, @@ -478,7 +478,7 @@ static void meson_sar_adc_unlock(struct iio_dev *indio_dev) { struct meson_sar_adc_priv *priv = iio_priv(indio_dev); - if (priv->data->param->has_bl30_integration) + if (priv->param->has_bl30_integration) /* allow BL30 to use the SAR ADC again */ regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELAY, MESON_SAR_ADC_DELAY_KERNEL_BUSY, 0); @@ -562,7 +562,7 @@ static int meson_sar_adc_iio_info_read_raw(struct iio_dev *indio_dev, } *val = ret / 1000; - *val2 = priv->data->param->resolution; + *val2 = priv->param->resolution; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_CALIBBIAS: @@ -635,7 +635,7 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev) */ meson_sar_adc_set_chan7_mux(indio_dev, CHAN7_MUX_CH7_INPUT); - if (priv->data->param->has_bl30_integration) { + if (priv->param->has_bl30_integration) { /* * leave sampling delay and the input clocks as configured by * BL30 to make sure BL30 gets the values it expects when @@ -715,7 +715,7 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev) return ret; } - ret = clk_set_rate(priv->adc_clk, priv->data->param->clock_rate); + ret = clk_set_rate(priv->adc_clk, priv->param->clock_rate); if (ret) { dev_err(indio_dev->dev.parent, "failed to set adc clock rate\n"); @@ -728,7 +728,7 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev) static void meson_sar_adc_set_bandgap(struct iio_dev *indio_dev, bool on_off) { struct meson_sar_adc_priv *priv = iio_priv(indio_dev); - const struct meson_sar_adc_param *param = priv->data->param; + const struct meson_sar_adc_param *param = priv->param; u32 enable_mask; if (param->bandgap_reg == MESON_SAR_ADC_REG11) @@ -848,8 +848,8 @@ static int meson_sar_adc_calib(struct iio_dev *indio_dev) int ret, nominal0, nominal1, value0, value1; /* use points 25% and 75% for calibration */ - nominal0 = (1 << priv->data->param->resolution) / 4; - nominal1 = (1 << priv->data->param->resolution) * 3 / 4; + nominal0 = (1 << priv->param->resolution) / 4; + nominal1 = (1 << priv->param->resolution) * 3 / 4; meson_sar_adc_set_chan7_mux(indio_dev, CHAN7_MUX_VDD_DIV4); usleep_range(10, 20); @@ -1000,9 +1000,9 @@ static int meson_sar_adc_probe(struct platform_device *pdev) return -ENODEV; } - priv->data = match_data; + priv->param = match_data->param; - indio_dev->name = priv->data->name; + indio_dev->name = match_data->name; indio_dev->dev.parent = &pdev->dev; indio_dev->dev.of_node = pdev->dev.of_node; indio_dev->modes = INDIO_DIRECT_MODE; @@ -1026,7 +1026,7 @@ static int meson_sar_adc_probe(struct platform_device *pdev) return ret; priv->regmap = devm_regmap_init_mmio(&pdev->dev, base, - priv->data->param->regmap_config); + priv->param->regmap_config); if (IS_ERR(priv->regmap)) return PTR_ERR(priv->regmap);