Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp234968pxb; Thu, 2 Sep 2021 03:02:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIL+g9PP2XqMmYo1BbDklNNIvy4UaRn+uEWx7yzJABOcxJfEyTBxKSWGxzi9icUioVHqW6 X-Received: by 2002:a92:4453:: with SMTP id a19mr1692660ilm.221.1630576948629; Thu, 02 Sep 2021 03:02:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630576948; cv=none; d=google.com; s=arc-20160816; b=nwIj2sQPzC4wFl68dAa+ooBh27nLk0lkK0maYFIEOkTZEn6hBrvM5eQu4ZNzzIRLM4 c5fTMgTdOHY2pcs1cO7bPZdODxd6LZfxdt47GrgImqJlh2VC7tBfohml+wziYjCoNvFC 9OJzfW7FtWD7pQAFLnPZIchXO+xQ+tOLe83HmxNkL4bTKFfsgU1oGgSniePVxh0T812Y BaIGQKlvY4uU844O4XwL9T3aJesUSVU/eB9OTpQYHzdKekkWY3zqjzudLeOImBV4e4f/ 8EI7LyEEJL4jnIK3rFEVOEozqSQJXF+0ZMO3fxtGXglkj8n0Vb23EXEt3/ylQUkCQzyZ NHOA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=wkK1D1D7yNI3TiVlGigfPBjagTE/hqUrUl558Xu7m2s=; b=ZUlc59biJaeJ6tLTQqJIqCLjfZ5qSww8+fn0s5k+BQyTuuEUd+69Bv2G4ZEf12K+4n daR8gW/ytNLFF3OlOSh4Y97jWevMPltb+I4Z/nxIwq4DgIXSrbseBFL8BcGWu9N1u/mO rw3HUSw3q2ToyNAo0mlJiMQ/bIDbFNxZopTNRvI5vaoebCZFuGN8qzaGL39lMvicacgW UxVftBB7Jc25ImtNjNBvL3Kprn6IhpyoES5zY2PcDPZoe2HpUC83YenjyWwQD1DFx8YN nACde319CgcVoYkRL9v8sZwZMAT3rgaWuaTS+/6Di9ySk/Jlxue3fGn/OLlAgnjyWB/f eLIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o16si1586666ils.161.2021.09.02.03.02.17; Thu, 02 Sep 2021 03:02:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245510AbhIBJ11 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 2 Sep 2021 05:27:27 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:62203 "EHLO relay2-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245489AbhIBJ1Z (ORCPT ); Thu, 2 Sep 2021 05:27:25 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id E1E9740006; Thu, 2 Sep 2021 09:26:25 +0000 (UTC) Date: Thu, 2 Sep 2021 11:26:19 +0200 From: Miquel Raynal To: "Sa, Nuno" Cc: Jonathan Cameron , Lars-Peter Clausen , Thomas Petazzoni , "linux-iio@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 12/16] iio: adc: max1027: Introduce an end of conversion helper Message-ID: <20210902112619.248bca16@xps13> In-Reply-To: References: <20210818111139.330636-1-miquel.raynal@bootlin.com> <20210818111139.330636-13-miquel.raynal@bootlin.com> Organization: Bootlin X-Mailer: Claws Mail 3.17.7 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nuno, "Sa, Nuno" wrote on Fri, 20 Aug 2021 07:28:17 +0000: > > -----Original Message----- > > From: Miquel Raynal > > Sent: Wednesday, August 18, 2021 1:12 PM > > To: Jonathan Cameron ; Lars-Peter Clausen > > > > Cc: Thomas Petazzoni ; linux- > > iio@vger.kernel.org; linux-kernel@vger.kernel.org; Miquel Raynal > > > > Subject: [PATCH 12/16] iio: adc: max1027: Introduce an end of > > conversion helper > > > > [External] > > > > For now this helper only waits for the maximum duration of a > > conversion, > > but it will soon be improved to properly handle the end of conversion > > interrupt. > > > > Signed-off-by: Miquel Raynal > > --- > > drivers/iio/adc/max1027.c | 23 +++++++++++++++++++++-- > > 1 file changed, 21 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c > > index afc3ce69f7ea..2d6485591761 100644 > > --- a/drivers/iio/adc/max1027.c > > +++ b/drivers/iio/adc/max1027.c > > @@ -60,6 +60,9 @@ > > #define MAX1027_NAVG_32 (0x03 << 2) > > #define MAX1027_AVG_EN BIT(4) > > > > +/* Device can achieve 300ksps so we assume a 3.33us conversion > > delay */ > > +#define MAX1027_CONVERSION_UDELAY 4 > > + > > enum max1027_id { > > max1027, > > max1029, > > @@ -236,6 +239,20 @@ struct max1027_state { > > u8 reg ____cacheline_aligned; > > }; > > > > +static DECLARE_WAIT_QUEUE_HEAD(max1027_queue); > > + > > +static int max1027_wait_eoc(struct iio_dev *indio_dev) > > +{ > > + unsigned int conversion_time = > > MAX1027_CONVERSION_UDELAY; > > + > > + if (indio_dev->active_scan_mask) > > + conversion_time *= hweight32(*indio_dev- > > >active_scan_mask); > > + > > + usleep_range(conversion_time, conversion_time * 2); > > + > > + return 0; > > +} > > + > > /* Scan from 0 to the highest requested channel */ > > static int max1027_configure_chans_to_scan(struct iio_dev > > *indio_dev) > > { > > @@ -310,9 +327,11 @@ static int max1027_read_single_value(struct > > iio_dev *indio_dev, > > /* > > * For an unknown reason, when we use the mode "10" (write > > * conversion register), the interrupt doesn't occur every time. > > - * So we just wait 1 ms. > > + * So we just wait the maximum conversion time and deliver > > the value. > > */ > > - mdelay(1); > > + ret = max1027_wait_eoc(indio_dev); > > + if (ret) > > + return ret; > > I'm a bit confused here... Why are we looking at the active_scan_mask? > Aren't we preventing this for running concurrently with buffering? Sorry for the confusion, at this stage the "if (active_masks)" is useless, I moved it later in the series when we actually start to use this EOC helper for the buffered reads as well. Thanks, Miquèl