Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4225037pxj; Tue, 25 May 2021 03:12:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz811NL981XN9SaD0sSSNSL+iY5bsXUoZ0PUAL5e8dzHnET0BJAu/L25Y0gkKMjSxMkHoeu X-Received: by 2002:a02:7354:: with SMTP id a20mr30176391jae.94.1621937564006; Tue, 25 May 2021 03:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621937564; cv=none; d=google.com; s=arc-20160816; b=PdvkJGhTMRxJYTmgRhxtd8/MaM0FRXx6CmOMzIKMrAWTLixcbhZfnHMtsvmedKzgcG U1Muwk1Cs3qYqr4ekFJPyPHcxQpF1I+jvSee2LOzb3MTCA7kvG6xi79TcoxRNVRQRK9w Te1fDEGlis4c+RWGhT+qiiMKelDvLlr/rlNnky/BVeyOVfvBugCcW/NzqHOtwUVB557+ Sdm54GQ84KQ77qhbzIjYMQcjGZf9BHrnJIuOsMKwnu8mtSidziYJRxeB6TPvSpp07nMA QjQMwA3REVAeOsxjm5D2ihWeKRnieOpw/5eYMbZjOvyfL0bIo56E+jMMM3Tu823e5GyI jgig== 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=bl0ew1ns59d3zs9GX63Dqrc5f5eiWngBQvcatUnaYaA=; b=L02N4m8uT+QNolm5K7fcj4tGp0YpnCcj2ljN3fOtWuCksspu1Z/ebfoGFJPrriOSb5 j4u2C63GXHA9dyZWL8PoyActBTRObrbJ6YDj/XTtX+URbZU7PTWHe8D2RVtUvDLZdAtQ mgWaR65rGrqNUEQt6qb5EIKZxA4zzd9WW9kqJwVHxOdw/rAQE3yKV41aXZUVWFGfN5D+ +n6kQmPBrx0vzR9ZsWwS3nfmZ65ai9x4oWCB2RTATtqzss7e+LMEBukrBkgJznOQFV34 2mD4Q4IbaIR9Zgk2OgnKPauO0bt5TA+zS34CqlkPzvLDnLfcN1gbLcn5X4Nthkp2tYbX yNDw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p31si19447703jac.95.2021.05.25.03.12.15; Tue, 25 May 2021 03:12:43 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232286AbhEYIW1 convert rfc822-to-8bit (ORCPT + 99 others); Tue, 25 May 2021 04:22:27 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5549 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbhEYIWZ (ORCPT ); Tue, 25 May 2021 04:22:25 -0400 Received: from dggems706-chm.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Fq6Qg0hHrzwSnk; Tue, 25 May 2021 16:18:03 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by dggems706-chm.china.huawei.com (10.3.19.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 25 May 2021 16:20:53 +0800 Received: from localhost (10.52.120.147) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Tue, 25 May 2021 09:20:51 +0100 Date: Tue, 25 May 2021 09:19:02 +0100 From: Jonathan Cameron To: "Li, Meng" CC: Jonathan Cameron , Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= , "lars@metafoo.de" , "Michael.Hennerich@analog.com" , "pmeerw@pmeerw.net" , "linux-kernel@vger.kernel.org" , "linux-iio@vger.kernel.org" Subject: Re: [PATCH] driver: adc: ltc2497: return directly after reading the adc conversion value Message-ID: <20210525091902.000074b5@Huawei.com> In-Reply-To: References: <20210512045725.23390-1-Meng.Li@windriver.com> <20210519092104.pntanimcjg6s6fca@pengutronix.de> <20210521180150.0f4d1b5d@jic23-huawei> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.52.120.147] X-ClientProxiedBy: lhreml705-chm.china.huawei.com (10.201.108.54) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 24 May 2021 02:49:01 +0000 "Li, Meng" wrote: > > -----Original Message----- > > From: Jonathan Cameron > > Sent: Saturday, May 22, 2021 1:02 AM > > To: Uwe Kleine-K?nig > > Cc: Li, Meng ; lars@metafoo.de; > > Michael.Hennerich@analog.com; pmeerw@pmeerw.net; linux- > > kernel@vger.kernel.org; linux-iio@vger.kernel.org > > Subject: Re: [PATCH] driver: adc: ltc2497: return directly after reading the adc > > conversion value > > > > [Please note: This e-mail is from an EXTERNAL e-mail address] > > > > On Wed, 19 May 2021 11:21:04 +0200 > > Uwe Kleine-K?nig wrote: > > > > > On Wed, May 12, 2021 at 12:57:25PM +0800, Meng.Li@windriver.com > > wrote: > > > > From: Meng Li > > > > > > > > When read adc conversion value with below command: > > > > cat /sys/.../iio:device0/in_voltage0-voltage1_raw > > > > There is an error reported as below: > > > > ltc2497 0-0014: i2c transfer failed: -EREMOTEIO This i2c transfer > > > > issue is introduced by commit 69548b7c2c4f ("iio: > > > > adc: ltc2497: split protocol independent part in a separate module"). > > > > When extract the common code into ltc2497-core.c, it change the code > > > > logic of function ltc2497core_read(). With wrong reading sequence, > > > > the action of enable adc channel is sent to chip again during adc > > > > channel is in conversion status. In this way, there is no ack from > > > > chip, and then cause i2c transfer failed. > > > > In order to keep the code logic is the same with original ideal, it > > > > is need to return direct after reading the adc conversion value. > > > > > > > > Fixes: 69548b7c2c4f ("iio: adc: ltc2497: split protocol independent > > > > part in a separate module ") > > > > Cc: stable@vger.kernel.org > > > > Signed-off-by: Meng Li > > > > --- > > > > drivers/iio/adc/ltc2497.c | 2 ++ > > > > 1 file changed, 2 insertions(+) > > > > > > > > diff --git a/drivers/iio/adc/ltc2497.c b/drivers/iio/adc/ltc2497.c > > > > index 1adddf5a88a9..fd5a66860a47 100644 > > > > --- a/drivers/iio/adc/ltc2497.c > > > > +++ b/drivers/iio/adc/ltc2497.c > > > > @@ -41,6 +41,8 @@ static int ltc2497_result_and_measure(struct > > ltc2497core_driverdata *ddata, > > > > } > > > > > > > > *val = (be32_to_cpu(st->buf) >> 14) - (1 << 17); > > > > + > > > > + return ret; > > > > > > This looks wrong for me. The idea of the function > > > ltc2497_result_and_measure is that it reads the result and starts a > > > new measurement. I guess the problem is that > > > ltc2497_result_and_measure is called to early, not that it does too much. > > > > > > But note I don't have such a system handy to actually debug this any > > > more. > > > > @Meng Li, > > > > I see from the datasheet that the device can be used with an external > > oscillator. > > Is that the case on your boards, because if so the timing delay of 150msecs > > may be far too short. If not, perhaps the part is right at the upper end of > > timings and we just need to add 20% to the 150msecs to be sure of not > > hitting the limit? > > > > Hi Jonathan, > > Thanks for your very professional comments. > I check my board schematics, the pin 35 f0 is connected to GND, so I use the internal oscillator. Bad guess :( > In additional, I am not very understand your comment about the case of using internal oscillator. > Do you mean that you agree my patch and only need to change 150 into 180? > #define LTC2497_CONVERSION_TIME_MS 150ULL > => > #define LTC2497_CONVERSION_TIME_MS 180ULL Yes. Just give a little more time in case the oscillator is running a little slow. Jonathan > > Thanks, > Limeng > > > Thanks, > > > > Jonathan > > > > > > > > > > Best regards > > > Uwe > > > >