All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Li, Meng" <Meng.Li@windriver.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: "lars@metafoo.de" <lars@metafoo.de>,
	"Michael.Hennerich@analog.com" <Michael.Hennerich@analog.com>,
	"pmeerw@pmeerw.net" <pmeerw@pmeerw.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>
Subject: RE: [PATCH] driver: adc: ltc2497: return directly after reading the adc conversion value
Date: Mon, 24 May 2021 02:49:01 +0000	[thread overview]
Message-ID: <PH0PR11MB519159873BE8CB7ACA227826F1269@PH0PR11MB5191.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20210521180150.0f4d1b5d@jic23-huawei>



> -----Original Message-----
> From: Jonathan Cameron <jic23@kernel.org>
> Sent: Saturday, May 22, 2021 1:02 AM
> To: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: Li, Meng <Meng.Li@windriver.com>; 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 <u.kleine-koenig@pengutronix.de> wrote:
> 
> > On Wed, May 12, 2021 at 12:57:25PM +0800, Meng.Li@windriver.com
> wrote:
> > > From: Meng Li <Meng.Li@windriver.com>
> > >
> > > 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 <Meng.Li@windriver.com>
> > > ---
> > >  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.
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

Thanks,
Limeng

> Thanks,
> 
> Jonathan
> 
> 
> >
> > Best regards
> > Uwe
> >


  reply	other threads:[~2021-05-24  2:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12  4:57 [PATCH] driver: adc: ltc2497: return directly after reading the adc conversion value Meng.Li
2021-05-18 17:46 ` Jonathan Cameron
2021-05-19  9:21 ` Uwe Kleine-König
2021-05-21 17:01   ` Jonathan Cameron
2021-05-24  2:49     ` Li, Meng [this message]
2021-05-25  8:19       ` Jonathan Cameron
2021-05-24  2:53   ` Li, Meng
2021-05-25  8:22     ` Felix Knopf
2021-05-25 10:36       ` Li, Meng
2021-06-01  9:28 Meng.Li
2021-06-03 16:20 ` Jonathan Cameron
2021-06-04  2:16   ` Li, Meng
2021-06-04  6:13     ` Uwe Kleine-König
2021-06-04  6:43       ` Li, Meng
2021-06-04  8:20         ` Jonathan Cameron
2021-06-04  8:53           ` Uwe Kleine-König
2021-06-04  9:04             ` Li, Meng
2021-06-04  9:32               ` Uwe Kleine-König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PH0PR11MB519159873BE8CB7ACA227826F1269@PH0PR11MB5191.namprd11.prod.outlook.com \
    --to=meng.li@windriver.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.