From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752816AbdLENM5 (ORCPT ); Tue, 5 Dec 2017 08:12:57 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:62643 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752126AbdLENMu (ORCPT ); Tue, 5 Dec 2017 08:12:50 -0500 Date: Tue, 5 Dec 2017 14:12:46 +0100 From: Andreas Klinger To: Jonathan Cameron Cc: knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, singhalsimran0@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] iio: hx711: fix bug in reset functionality Message-ID: <20171205131246.GC1958@arbeit> References: <20171130214445.GA27345@arbeit> <20171202132226.36bc96f3@archlinux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171202132226.36bc96f3@archlinux> User-Agent: Mutt/1.5.23 (2014-03-12) X-Provags-ID: V03:K0:dzuBnB7UcLNp6JCJOp/V3zmFdGSlznCwvrO2BS3yZRU19bGxOVB VPCA4Rq+oSMax16pWRZXI37K0svbVNqbZk+GX+jYpkBbrl0CHdoFQX0ZCT/xswK9sUfyqXk VHHLgutzXHqFNrJuqxFRd+VnSEWrrN5iSPxeDp7RxHz18lZ4JuoMWgiYM+nhDoceOy3i98P XioUzUZzJE1WrsRoNvDkg== X-UI-Out-Filterresults: notjunk:1;V01:K0:JVwoR21QWrM=:JCn+CD9kFJ6tXPEYsAdCJs oMy4+B9KqpEqWJfYOq/wXxcXZO6fAVhA6fhvjYgjvMmMHPa/rOepTzRnn0vxjNNrPLeksqDuy ZMKwrSsKWFpojbdBTWU/OkCQBJ3bAENInMjullsP1Xix+Fq+VAcrtgld5UPshbkFdJvWp8unD FDV7BVV2yEkTpdQOu7Uh7eauUonzwpJfb3pEfaUrhfjkdzYv5hpYr2McuTOnCnnqSEw1DySf5 DVe/EqOZ4fCbbmoEiug2w4/9yz1TjMtH2K1Z2qTPWxHIn8reJ6d1l3qClM3aapPF+FpiY6e/p +e+guruzghq/jwgl+HDYTZAXRz7rZf4u2NX0k+xCOmdBjXuNldJ3Qjsq+h7+kUcYWiWe7jjUW 4XETL7zSIHXgXJpl80d6XtXGQIYl4R/fRwsltWOFBO1AXJ5+2msbEVlK+fCeQi1NrWLUpOmbz 0pK0l/7kaa1VO4Nj20jefXYq/tPZyqpTvIfCRge/ttz/H32Oxuf20C65YJf+83cEG+apoRWWl 9NnquQ6H+jr0r9GsjHVnituymq6iP4qJWPBnM6VAxCIqPV19a9Wzr6vwnweQJcR4AIvchoo2m vyfBsI8dQc4yYYGBz58GUCHeoQVJdQ42KypPz38/n9zd9NVm6varxpep4Uu/8ylB5nrq4KPd8 7h4KXNDu4UkQcg90RIOuendHnUXC+LyWpWtY4lprGIAb7+3shnQ2Y34Wy1NSicRzYVfeMXx9u 9NPLiv7gqIlDsYLE6ary/yFn39Maf75b6pg9/Q== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jonathan, see answer to your question below. Andreas Jonathan Cameron schrieb am Sat, 02. Dec 13:22: > On Thu, 30 Nov 2017 22:44:45 +0100 > Andreas Klinger wrote: > > > return value in hx711_reset() should indicate status of dout > > otherwise the calling function is reporting an error als false positive > > > > wait up to 1 second until the device is in normal state > > by changing the channel on every trigger event it turned out that the > > former 100 ms are not enough for waiting until the device is in normal mode > > What is the ultimate result of this? I'm trying to assess if we want > to marked it for stable trees or just apply it ready for the next > merge window. It think it means that two reads too close to each > other will always result in an error for the second one rather than > the intended delay and then succeed? Exactly. If one is accessing to fast the second access will fail. Especially when using a trigger the second channel is never read without error. > > Thanks, > > Jonathan > > > > Signed-off-by: Andreas Klinger > > --- > > drivers/iio/adc/hx711.c | 13 ++++++------- > > 1 file changed, 6 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/iio/adc/hx711.c b/drivers/iio/adc/hx711.c > > index d773fd69a76d..eabd2e66aca3 100644 > > --- a/drivers/iio/adc/hx711.c > > +++ b/drivers/iio/adc/hx711.c > > @@ -153,15 +153,16 @@ static int hx711_wait_for_ready(struct hx711_data *hx711_data) > > int i, val; > > > > /* > > - * a maximum reset cycle time of 56 ms was measured. > > - * we round it up to 100 ms > > + * in some rare cases the reset takes quite a long time > > + * especially when the channel is changed. > > + * Allow up to one second for it > > */ > > for (i = 0; i < 100; i++) { > > val = gpiod_get_value(hx711_data->gpiod_dout); > > if (!val) > > break; > > - /* sleep at least 1 ms */ > > - msleep(1); > > + /* sleep at least 10 ms */ > > + msleep(10); > > } > > if (val) > > return -EIO; > > @@ -203,9 +204,7 @@ static int hx711_reset(struct hx711_data *hx711_data) > > * after a dummy read we need to wait vor readiness > > * for not mixing gain pulses with the clock > > */ > > - ret = hx711_wait_for_ready(hx711_data); > > - if (ret) > > - return ret; > > + val = hx711_wait_for_ready(hx711_data); > > } > > > > return val; > --