Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp2495192img; Sun, 24 Mar 2019 10:13:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxF2TZxGuJ9UoP/1rSkhVEepGC5UKp7cI3T3ZWjJP4tTg2L9uBgmGRmKjLg8v81vnnYx1QK X-Received: by 2002:a17:902:7785:: with SMTP id o5mr1817943pll.33.1553447619200; Sun, 24 Mar 2019 10:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553447619; cv=none; d=google.com; s=arc-20160816; b=blidemhE6h3mCCs8a4T+IMLisqNpDioSO1MXZ/UfxLH4BZ/oVA3GME5r6M9hC+uGNn ZBTJFsfsr6IQ7TIkTsCj8VTv0D0dJBYfPedeCzvy4WSgFtf2+uheARQynJbQ+YeJznTj Tc9bYQg8K+284YHV4V7ZjRdCHHJQw7bNi7b7rkCvg2ayVd81e6do9eJ2Z0uAlfN8a4ef AxMpvdE4LKSt8EF3QjL/x40H1QeGyNJnQqknbbzZjJGGeY2PIaBHd6Uiw6t8JeP6Ller PqCvswK75QVkfte1ylbmwTFw3d/FuOvBFHIDLtOVgPWwoc5X/LFcDTswoqBQFTCNjHWF /lsg== 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:subject:cc:to:from:date :dkim-signature; bh=r7SRDxgwDl3+Tsg18wg+96Z2e5L/OeZOlnn27sA9Ye8=; b=qgoTgOvEkOfTLf7+oPP1hcnCiMW9vVfERzt5Y4A9A02Mvlbvz2tS6DcktusPDcrSW9 td7L6vet71sGOSPDy288DZMaDM4fy27e1ppaw9ino0Auntv3/ujrLrD7OUmDi4dl+VTn F0mtTqiSPbjvkkXuMHMfHHhtD75LyQkcPUNWbFoBJHmI6p9lPLGDot0li4t54/0v1K3M Zzkh3Ff50NkcHZf0xNDQukb44haPhmRB4IijdQNh0iAHPtdk9VJTjnEHRVgrON06ABcB so9uZotgnE+b+sbb5DAdLd4ZMWVz9WnIK7wr5ezP6c3GxpYQXz5wG7E+3YvkHGD6h4SG n4jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ryai+PKx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s21si566528plq.211.2019.03.24.10.13.24; Sun, 24 Mar 2019 10:13:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ryai+PKx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728890AbfCXRMu (ORCPT + 99 others); Sun, 24 Mar 2019 13:12:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:34550 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728642AbfCXRMt (ORCPT ); Sun, 24 Mar 2019 13:12:49 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D8A502087F; Sun, 24 Mar 2019 17:12:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553447568; bh=wxEVUIOVR28lMtF1wwMqBmSMZBwZ6mSS/LE474j3grU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ryai+PKxZG2ImA5XPZ54Y/sgGYy3WimplJ+XhO+MfZJT4yEsTSlSrKODPHU2mlj9k pMTOwJB14V7Sgn/7uJlAoQkaWUcRD0gbdb1YZghRtIzSPR/E1NoTAq9GKuNmo6BR5d V4QffoFAFEjaL9gkU+2/amojP8wOTvdDjm26F28c= Date: Sun, 24 Mar 2019 17:12:42 +0000 From: Jonathan Cameron To: Fabrice Gasnier Cc: , , , , , , , , , , Subject: Re: [PATCH v2 8/8] iio: adc: stm32-dfsdm: claim direct mode for raw read and settings Message-ID: <20190324171242.67d7a486@archlinux> In-Reply-To: <1553186849-6261-9-git-send-email-fabrice.gasnier@st.com> References: <1553186849-6261-1-git-send-email-fabrice.gasnier@st.com> <1553186849-6261-9-git-send-email-fabrice.gasnier@st.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 Mar 2019 17:47:29 +0100 Fabrice Gasnier wrote: > Claim direct mode to ensure no buffer mode is in use for: > - single conversion > - sample rate setting (must be set when filter isn't enabled). > - oversampling ratio (must be set when filter isn't enabled). > > Signed-off-by: Fabrice Gasnier Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > drivers/iio/adc/stm32-dfsdm-adc.c | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c > index 51688eb..ca42946 100644 > --- a/drivers/iio/adc/stm32-dfsdm-adc.c > +++ b/drivers/iio/adc/stm32-dfsdm-adc.c > @@ -1039,16 +1039,23 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev, > > switch (mask) { > case IIO_CHAN_INFO_OVERSAMPLING_RATIO: > + ret = iio_device_claim_direct_mode(indio_dev); > + if (ret) > + return ret; > ret = stm32_dfsdm_set_osrs(fl, 0, val); > if (!ret) > adc->oversamp = val; > - > + iio_device_release_direct_mode(indio_dev); > return ret; > > case IIO_CHAN_INFO_SAMP_FREQ: > if (!val) > return -EINVAL; > > + ret = iio_device_claim_direct_mode(indio_dev); > + if (ret) > + return ret; > + > switch (ch->src) { > case DFSDM_CHANNEL_SPI_CLOCK_INTERNAL: > spi_freq = adc->dfsdm->spi_master_freq; > @@ -1070,9 +1077,11 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev, > if (ret < 0) { > dev_err(&indio_dev->dev, > "Not able to find parameter that match!\n"); > + iio_device_release_direct_mode(indio_dev); > return ret; > } > adc->sample_freq = val; > + iio_device_release_direct_mode(indio_dev); > > return 0; > } > @@ -1089,11 +1098,15 @@ static int stm32_dfsdm_read_raw(struct iio_dev *indio_dev, > > switch (mask) { > case IIO_CHAN_INFO_RAW: > + ret = iio_device_claim_direct_mode(indio_dev); > + if (ret) > + return ret; > ret = iio_hw_consumer_enable(adc->hwc); > if (ret < 0) { > dev_err(&indio_dev->dev, > "%s: IIO enable failed (channel %d)\n", > __func__, chan->channel); > + iio_device_release_direct_mode(indio_dev); > return ret; > } > ret = stm32_dfsdm_single_conv(indio_dev, chan, val); > @@ -1102,8 +1115,10 @@ static int stm32_dfsdm_read_raw(struct iio_dev *indio_dev, > dev_err(&indio_dev->dev, > "%s: Conversion failed (channel %d)\n", > __func__, chan->channel); > + iio_device_release_direct_mode(indio_dev); > return ret; > } > + iio_device_release_direct_mode(indio_dev); > return IIO_VAL_INT; > > case IIO_CHAN_INFO_OVERSAMPLING_RATIO: