Linux IIO development
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Cosmin Tanislav <demonsingur@gmail.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Cosmin Tanislav <cosmin.tanislav@analog.com>,
	 Jonathan Cameron <jic23@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] iio: accel: adxl367: fix DEVID read after reset
Date: Wed, 07 Feb 2024 10:11:06 +0100	[thread overview]
Message-ID: <9c53981719f8d44c38a5eb32e629dcec4bd2c60a.camel@gmail.com> (raw)
In-Reply-To: <20240207033657.206171-1-demonsingur@gmail.com>

On Wed, 2024-02-07 at 05:36 +0200, Cosmin Tanislav wrote:
> regmap_read_poll_timeout() will not sleep before reading,
> causing the first read to return -ENXIO on I2C, since the
> chip does not respond to it while it is being reset.
> 
> The datasheet specifies that a soft reset operation has a
> latency of 7.5ms.
> 
> Add a 15ms sleep between reset and reading the DEVID register,
> and switch to a simple regmap_read() call.
> 
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---

This likely needs a Fixes: tag as well. With that,

Reviewed-by: Nuno Sa <nuno.sa@analog.com>

>  drivers/iio/accel/adxl367.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/accel/adxl367.c b/drivers/iio/accel/adxl367.c
> index 834ee6d63947..210228affb80 100644
> --- a/drivers/iio/accel/adxl367.c
> +++ b/drivers/iio/accel/adxl367.c
> @@ -1368,9 +1368,11 @@ static int adxl367_verify_devid(struct adxl367_state
> *st)
>  	unsigned int val;
>  	int ret;
>  
> -	ret = regmap_read_poll_timeout(st->regmap, ADXL367_REG_DEVID, val,
> -				       val == ADXL367_DEVID_AD, 1000, 10000);
> +	ret = regmap_read(st->regmap, ADXL367_REG_DEVID, &val);
>  	if (ret)
> +		return dev_err_probe(st->dev, ret, "Failed to read dev
> id\n");
> +
> +	if (val != ADXL367_DEVID_AD)
>  		return dev_err_probe(st->dev, -ENODEV,
>  				     "Invalid dev id 0x%02X, expected
> 0x%02X\n",
>  				     val, ADXL367_DEVID_AD);
> @@ -1449,6 +1451,8 @@ int adxl367_probe(struct device *dev, const struct
> adxl367_ops *ops,
>  	if (ret)
>  		return ret;
>  
> +	fsleep(15000);
> +
>  	ret = adxl367_verify_devid(st);
>  	if (ret)
>  		return ret;


      parent reply	other threads:[~2024-02-07  9:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-07  3:36 [PATCH 1/2] iio: accel: adxl367: fix DEVID read after reset Cosmin Tanislav
2024-02-07  3:36 ` [PATCH 2/2] iio: accel: adxl367: fix I2C FIFO data register Cosmin Tanislav
2024-02-07  9:08   ` Nuno Sá
2024-02-10 16:57     ` Jonathan Cameron
2024-02-25 14:33       ` Jonathan Cameron
2024-02-07  9:11 ` Nuno Sá [this message]

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=9c53981719f8d44c38a5eb32e629dcec4bd2c60a.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=cosmin.tanislav@analog.com \
    --cc=demonsingur@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox