From patchwork Mon Jan 15 10:33:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 124493 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp623909lje; Mon, 15 Jan 2018 02:35:05 -0800 (PST) X-Google-Smtp-Source: ACJfBosSYeDCiJznlG2IQn5c2uhI9QX9cJqc4rbpVKM75rwZMWKNhNlc2ulXYJxTCt4VTCrU8rmk X-Received: by 10.98.207.6 with SMTP id b6mr22442640pfg.187.1516012505425; Mon, 15 Jan 2018 02:35:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516012505; cv=none; d=google.com; s=arc-20160816; b=MFGilh+lgwvajgDraSDS3umhs9hHa7YFY+Rzf2yZWig/H9ZciBOiQGZMPlTOtiKVHS PBxwajgoAtms2Ew04bLWXDUBHNSywCTEFgtyyQ4CDUotyPhP4LMFhhl8LwITVFJdBR1y iZtDDexzbLohvy1P3G44ALLlxcmNrCMo+jcqV9AxWWZ+ZyhfFDbU+9fKfEKYcKXQV5Vv /vjmfdpypAaMhHvQ4wbFjFA8xEFQdFdrelkaWieheCJ7/mGXrmTgTzOc+oHnXZFkmpE9 nigOhClK5HkKAVMcaopTNS7SNUGHlLN5M4DKt73FcYr4loDiKNV4pTSMkMqBjJHlYfnk zXRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=yScdUZFy0T+h9wA/nAA4HEcRAdo3iTr/6GLJsu78TxU=; b=f2N8ihH8GRiMSY/orAji96cykprvMmc8U4USz7Vvg/CbtS0fjLlEVHFxpuxAwJ0Q19 Ey60pGRxU+0C3lGykiAF9NBgVru3z64MbsX7uOMg9VMGMC/iKmYvsMuN/1lvUVDdnXyQ xcnfsZQ2bht1IrOchjZk7exMAaHTH5nAs4jl9eSj1E2OIRWrtwA7rPwBa0cKit9R+tE/ r2Q7KZT8V63Y6KpMRNXOUCuDh2YmhZO97+Ky2Nz9lWsx5XyvxHOnuBCxorfDDwVOGO69 m9ReeQUMVFLKHQhQyKVjyK6h0EDLRaEl3B3pbJ6hSIwdOFeLhdaaCVko9fZYqlavH01y pl7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b25si12657457pfc.241.2018.01.15.02.35.05; Mon, 15 Jan 2018 02:35:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754755AbeAOKfC (ORCPT + 6 others); Mon, 15 Jan 2018 05:35:02 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:43741 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754496AbeAOKfB (ORCPT ); Mon, 15 Jan 2018 05:35:01 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 90ABD20890; Mon, 15 Jan 2018 11:34:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 1592B207A2; Mon, 15 Jan 2018 11:34:48 +0100 (CET) From: Quentin Schulz To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, robh+dt@kernel.org, mark.rutland@arm.com, wens@csie.org, sre@kernel.org, linux@armlinux.org.uk, maxime.ripard@free-electrons.com, lee.jones@linaro.org Cc: linux-iio@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, thomas.petazzoni@free-electrons.com, linux-sunxi@googlegroups.com, julian.calaby@gmail.com, Quentin Schulz Subject: [PATCH v3 01/16] iio: adc: axp20x_adc: put ADC rate setting in a per-variant function Date: Mon, 15 Jan 2018 11:33:35 +0100 Message-Id: <9488159b43c4cc8418afa9d1562d972c4631cb02.1516012352.git-series.quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: In-Reply-To: References: Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org To prepare for a new comer that set a different register with different values, move rate setting in a function that is specific to each AXP variant. Signed-off-by: Quentin Schulz --- drivers/iio/adc/axp20x_adc.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) -- git-series 0.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/iio/adc/axp20x_adc.c b/drivers/iio/adc/axp20x_adc.c index a30a972..3fc1b06 100644 --- a/drivers/iio/adc/axp20x_adc.c +++ b/drivers/iio/adc/axp20x_adc.c @@ -470,14 +470,18 @@ static const struct iio_info axp22x_adc_iio_info = { .read_raw = axp22x_read_raw, }; -static int axp20x_adc_rate(int rate) +static int axp20x_adc_rate(struct axp20x_adc_iio *info, int rate) { - return AXP20X_ADC_RATE_HZ(rate); + return regmap_update_bits(info->regmap, AXP20X_ADC_RATE, + AXP20X_ADC_RATE_MASK, + AXP20X_ADC_RATE_HZ(rate)); } -static int axp22x_adc_rate(int rate) +static int axp22x_adc_rate(struct axp20x_adc_iio *info, int rate) { - return AXP22X_ADC_RATE_HZ(rate); + return regmap_update_bits(info->regmap, AXP20X_ADC_RATE, + AXP20X_ADC_RATE_MASK, + AXP22X_ADC_RATE_HZ(rate)); } struct axp_data { @@ -485,7 +489,8 @@ struct axp_data { int num_channels; struct iio_chan_spec const *channels; unsigned long adc_en1_mask; - int (*adc_rate)(int rate); + int (*adc_rate)(struct axp20x_adc_iio *info, + int rate); bool adc_en2; struct iio_map *maps; }; @@ -554,8 +559,7 @@ static int axp20x_probe(struct platform_device *pdev) AXP20X_ADC_EN2_MASK, AXP20X_ADC_EN2_MASK); /* Configure ADCs rate */ - regmap_update_bits(info->regmap, AXP20X_ADC_RATE, AXP20X_ADC_RATE_MASK, - info->data->adc_rate(100)); + info->data->adc_rate(info, 100); ret = iio_map_array_register(indio_dev, info->data->maps); if (ret < 0) {