Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp399692pxj; Thu, 3 Jun 2021 09:20:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1/wUIate20uDLx8OBGgEWcPmAF6DpZFDV4J/qQph/tMqK5/RaMlB0ZG2If2Qpy1rXroiV X-Received: by 2002:a17:906:490:: with SMTP id f16mr157393eja.541.1622737226065; Thu, 03 Jun 2021 09:20:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622737226; cv=none; d=google.com; s=arc-20160816; b=ch48JRFdqEuHSAg1TcL8mExcs305FngLFmWBLEsiyVDdkr0qH7UfqpeJBTX+h7ykd7 AEOqtK2C/pwwNbjzFNfdWovx7c1BqMPjilK3RoWoSqwiTgayGgo3BskzrNJhBiTuHLY+ eDpjcahEIk7aPS0I12g/FozSAVna0mRlVdtdGoZ2ahr32wmG+cgqml+vSXXEIZ4JoJyH MOW72NWtFtmZdZHsYBkIVuwcP8cY2wj/+EmFJsw4tRXTdMnk3ekYc34AE54YWMuvU021 sSPapjJqCYc9assLe9GUUOCga47t/PQDfg1LTdefqakMLwJon+EWxbDLVZSUnVmqlsfw RWkg== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Cv3+ckev9iYN1+SuswIzYpK+XcZSW1iIC7U+4qVwZig=; b=lFt1vMfrQd3zTB2MqQ9C5dqv9BooMeLu3FbIa71Bxfzb/gYQccd17HUC7l30Z7z6C0 V8CYst5abAtw8/wqGcSB/FAH8DZLgUnZta9vkMyGxunLQECME7KZ0YFCwYOfH5CH4D1w p5J9lZgMTP+3qsnRdmP3teARQcw6oEQi1uiEsCpqM/NW9NNImHj/5OhRIyFG7XFcIeIK UScLXGDT6epxVmlM2QU/8QC+RhhtatcImL6M1YxbURjapgM2EQndtgvZHTqgqrGNUZks EcbQZaz2a4bhiMFoy7d5gmRxMiSIMRjMpejTfEfot/51La/ONah1fcS2lvMLEYI80ozG r39Q== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn25si2310658ejc.434.2021.06.03.09.20.02; Thu, 03 Jun 2021 09:20:26 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229692AbhFCQU3 (ORCPT + 99 others); Thu, 3 Jun 2021 12:20:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:59890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhFCQU3 (ORCPT ); Thu, 3 Jun 2021 12:20:29 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (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 44611613D2; Thu, 3 Jun 2021 16:18:41 +0000 (UTC) Date: Thu, 3 Jun 2021 17:20:25 +0100 From: Jonathan Cameron To: Meng.Li@windriver.com Cc: lars@metafoo.de, Michael.Hennerich@analog.com, pmeerw@pmeerw.net, u.kleine-koenig@pengutronix.de, 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: <20210603172025.314b5ced@jic23-huawei> In-Reply-To: <20210601092805.18385-1-Meng.Li@windriver.com> References: <20210601092805.18385-1-Meng.Li@windriver.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 1 Jun 2021 17:28:05 +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. > > v2: > According to ltc2497 datasheet, the max value of conversion time is > 149.9 ms. So, add 20% to the 150msecs so that there is enough time > for data conversion. Version change logs go below the --- as we don't want to preserve them forever in the git history. I may have lost track of the discussion, but I thought the idea was that perhaps the longer time period would remove the need for the early return? Thanks, Jonathan > > 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 ++ > drivers/iio/adc/ltc2497.h | 2 +- > 2 files changed, 3 insertions(+), 1 deletion(-) > > 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; > } > > ret = i2c_smbus_write_byte(st->client, > diff --git a/drivers/iio/adc/ltc2497.h b/drivers/iio/adc/ltc2497.h > index d0b42dd6b8ad..e451930837d8 100644 > --- a/drivers/iio/adc/ltc2497.h > +++ b/drivers/iio/adc/ltc2497.h > @@ -2,7 +2,7 @@ > > #define LTC2497_ENABLE 0xA0 > #define LTC2497_CONFIG_DEFAULT LTC2497_ENABLE > -#define LTC2497_CONVERSION_TIME_MS 150ULL > +#define LTC2497_CONVERSION_TIME_MS 180ULL > > struct ltc2497core_driverdata { > struct regulator *ref;