Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1686273pxj; Wed, 19 May 2021 11:27:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsMA8JSecthJUtortdzavMEVpJ/1SD0V3qlyFjZBf2KTXX3xtkJrq/m8AcLnhJVzQDGxoS X-Received: by 2002:a17:906:a88c:: with SMTP id ha12mr468620ejb.129.1621448843536; Wed, 19 May 2021 11:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621448843; cv=none; d=google.com; s=arc-20160816; b=chzKY8cyU2U+HM3wVYQFIAIqFBYi0wJTFkRJBs7INo4CrrF/sjjbMUwlFJF56vWPdF hYAVgGf36zwmkWPGMueL/Ljcpf3nSUuhrWnSAwkB92z5UpAcuoSerUINnKtGaebQzwcu fzwvwpouYcpCQQb3dkxaRmOk1gFljBoUlYFzI6Clf/9rGqBGB7EWMbGC4pDwPyc7XgAZ WXMjLktuM2LNMkuIRaoOn/PxfvpnujRebekuxcq42KRzSE9CoB7S8UrGXJKrL3pMlexu 5wKw4qBmQRANjGwr5V2s7a67los+6yejWNeEA2oB2v6gNEktUFqtHQfvqf4aSLfAms6d BmwA== 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=uzTsxrIRQDdwJXLSOPk0/houDofR71j5xy+nL0IlSzk=; b=SXraLSUb6iRTXHH1ZSZ2ImuBbCGNTpiLGDRXPTavKpADQwIZ7+vh/kwqW7ARWmobtX myv+FNZ3s/k9qa6o+x5A0TkRpl35LNUULh0bW14BxUhe0I2NiPFwzP5oDbVHCN+z6A+M UoLVHqPrOPwnju3/+m9/o0awGGJaQ/L8Q77DT5sTFFPESocE5L4iilNZSkcph1aqTgBU XC7zGv73KXRPHRyzcLdqaexZ2pk1jyt2RFDazMfXCAtOWekQ6PC31LjmJjJuu6557963 aohztXXhvCZM19ATEsIOcXlpj5DmwSZmBhlCBSnK4wsqantlNmufIt/IrJgwoY2Yvkvq gT4w== 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 jj22si304511ejc.162.2021.05.19.11.26.59; Wed, 19 May 2021 11:27:23 -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 S1347029AbhERRqK (ORCPT + 99 others); Tue, 18 May 2021 13:46:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:46584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237923AbhERRqJ (ORCPT ); Tue, 18 May 2021 13:46:09 -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 44CD6611BF; Tue, 18 May 2021 17:44:49 +0000 (UTC) Date: Tue, 18 May 2021 18:46:07 +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: <20210518184607.45b8ccb5@jic23-huawei> In-Reply-To: <20210512045725.23390-1-Meng.Li@windriver.com> References: <20210512045725.23390-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 Wed, 12 May 2021 12:57:25 +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 @Uwe, I'm far from sure looking at the code what the intent is here. whilst it definitely changed as Meng Li has outlined, I'm not sure the fix is correct. Jonathan > --- > 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; > } > > ret = i2c_smbus_write_byte(st->client,