* [PATCH 1/2] iio: accel: adxl367: fix DEVID read after reset
@ 2024-02-07 3:36 Cosmin Tanislav
2024-02-07 3:36 ` [PATCH 2/2] iio: accel: adxl367: fix I2C FIFO data register Cosmin Tanislav
2024-02-07 9:11 ` [PATCH 1/2] iio: accel: adxl367: fix DEVID read after reset Nuno Sá
0 siblings, 2 replies; 6+ messages in thread
From: Cosmin Tanislav @ 2024-02-07 3:36 UTC (permalink / raw)
Cc: Lars-Peter Clausen, Michael Hennerich, Cosmin Tanislav,
Jonathan Cameron, linux-iio, linux-kernel, Cosmin Tanislav
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>
---
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;
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] iio: accel: adxl367: fix I2C FIFO data register
2024-02-07 3:36 [PATCH 1/2] iio: accel: adxl367: fix DEVID read after reset Cosmin Tanislav
@ 2024-02-07 3:36 ` Cosmin Tanislav
2024-02-07 9:08 ` Nuno Sá
2024-02-07 9:11 ` [PATCH 1/2] iio: accel: adxl367: fix DEVID read after reset Nuno Sá
1 sibling, 1 reply; 6+ messages in thread
From: Cosmin Tanislav @ 2024-02-07 3:36 UTC (permalink / raw)
Cc: Lars-Peter Clausen, Michael Hennerich, Cosmin Tanislav,
Jonathan Cameron, linux-iio, linux-kernel, Cosmin Tanislav
As specified in the datasheet, the I2C FIFO data register is
0x18, not 0x42. 0x42 was used by mistake when adapting the
ADXL372 driver.
Fix this mistake.
Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
---
drivers/iio/accel/adxl367_i2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/accel/adxl367_i2c.c b/drivers/iio/accel/adxl367_i2c.c
index b595fe94f3a3..62c74bdc0d77 100644
--- a/drivers/iio/accel/adxl367_i2c.c
+++ b/drivers/iio/accel/adxl367_i2c.c
@@ -11,7 +11,7 @@
#include "adxl367.h"
-#define ADXL367_I2C_FIFO_DATA 0x42
+#define ADXL367_I2C_FIFO_DATA 0x18
struct adxl367_i2c_state {
struct regmap *regmap;
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] iio: accel: adxl367: fix I2C FIFO data register
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
0 siblings, 1 reply; 6+ messages in thread
From: Nuno Sá @ 2024-02-07 9:08 UTC (permalink / raw)
To: Cosmin Tanislav
Cc: Lars-Peter Clausen, Michael Hennerich, Cosmin Tanislav,
Jonathan Cameron, linux-iio, linux-kernel
On Wed, 2024-02-07 at 05:36 +0200, Cosmin Tanislav wrote:
> As specified in the datasheet, the I2C FIFO data register is
> 0x18, not 0x42. 0x42 was used by mistake when adapting the
> ADXL372 driver.
>
> Fix this mistake.
>
> Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> ---
This needs a Fixes: tag. With that:
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> drivers/iio/accel/adxl367_i2c.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/adxl367_i2c.c b/drivers/iio/accel/adxl367_i2c.c
> index b595fe94f3a3..62c74bdc0d77 100644
> --- a/drivers/iio/accel/adxl367_i2c.c
> +++ b/drivers/iio/accel/adxl367_i2c.c
> @@ -11,7 +11,7 @@
>
> #include "adxl367.h"
>
> -#define ADXL367_I2C_FIFO_DATA 0x42
> +#define ADXL367_I2C_FIFO_DATA 0x18
>
> struct adxl367_i2c_state {
> struct regmap *regmap;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] iio: accel: adxl367: fix DEVID read after reset
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:11 ` Nuno Sá
1 sibling, 0 replies; 6+ messages in thread
From: Nuno Sá @ 2024-02-07 9:11 UTC (permalink / raw)
To: Cosmin Tanislav
Cc: Lars-Peter Clausen, Michael Hennerich, Cosmin Tanislav,
Jonathan Cameron, linux-iio, linux-kernel
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;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] iio: accel: adxl367: fix I2C FIFO data register
2024-02-07 9:08 ` Nuno Sá
@ 2024-02-10 16:57 ` Jonathan Cameron
2024-02-25 14:33 ` Jonathan Cameron
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2024-02-10 16:57 UTC (permalink / raw)
To: Nuno Sá
Cc: Cosmin Tanislav, Lars-Peter Clausen, Michael Hennerich,
Cosmin Tanislav, linux-iio, linux-kernel
On Wed, 07 Feb 2024 10:08:38 +0100
Nuno Sá <noname.nuno@gmail.com> wrote:
> On Wed, 2024-02-07 at 05:36 +0200, Cosmin Tanislav wrote:
> > As specified in the datasheet, the I2C FIFO data register is
> > 0x18, not 0x42. 0x42 was used by mistake when adapting the
> > ADXL372 driver.
For future reference (not worth a v2): You could wrap a little longer - 75
chars is fine normally for commit messages.
> >
> > Fix this mistake.
> >
> > Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> > ---
>
> This needs a Fixes: tag. With that:
>
> Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Fine to just reply to each of these emails with an appropriate
fixes tag - no need for a v2.
>
> > drivers/iio/accel/adxl367_i2c.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/accel/adxl367_i2c.c b/drivers/iio/accel/adxl367_i2c.c
> > index b595fe94f3a3..62c74bdc0d77 100644
> > --- a/drivers/iio/accel/adxl367_i2c.c
> > +++ b/drivers/iio/accel/adxl367_i2c.c
> > @@ -11,7 +11,7 @@
> >
> > #include "adxl367.h"
> >
> > -#define ADXL367_I2C_FIFO_DATA 0x42
> > +#define ADXL367_I2C_FIFO_DATA 0x18
> >
> > struct adxl367_i2c_state {
> > struct regmap *regmap;
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] iio: accel: adxl367: fix I2C FIFO data register
2024-02-10 16:57 ` Jonathan Cameron
@ 2024-02-25 14:33 ` Jonathan Cameron
0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2024-02-25 14:33 UTC (permalink / raw)
To: Nuno Sá
Cc: Cosmin Tanislav, Lars-Peter Clausen, Michael Hennerich,
Cosmin Tanislav, linux-iio, linux-kernel
On Sat, 10 Feb 2024 16:57:47 +0000
Jonathan Cameron <jic23@kernel.org> wrote:
> On Wed, 07 Feb 2024 10:08:38 +0100
> Nuno Sá <noname.nuno@gmail.com> wrote:
>
> > On Wed, 2024-02-07 at 05:36 +0200, Cosmin Tanislav wrote:
> > > As specified in the datasheet, the I2C FIFO data register is
> > > 0x18, not 0x42. 0x42 was used by mistake when adapting the
> > > ADXL372 driver.
> For future reference (not worth a v2): You could wrap a little longer - 75
> chars is fine normally for commit messages.
> > >
> > > Fix this mistake.
> > >
> > > Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
> > > ---
> >
> > This needs a Fixes: tag. With that:
> >
> > Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> Fine to just reply to each of these emails with an appropriate
> fixes tag - no need for a v2.
>
Given these were still in my queue waiting for a fixes tag,
I went looking.
Fixes: cbab791c5e2a ("iio: accel: add ADXL367 driver")
Both patches added and both applied to the fixes-togreg branch of iio.git
Thanks
Jonathan
>
> >
> > > drivers/iio/accel/adxl367_i2c.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/iio/accel/adxl367_i2c.c b/drivers/iio/accel/adxl367_i2c.c
> > > index b595fe94f3a3..62c74bdc0d77 100644
> > > --- a/drivers/iio/accel/adxl367_i2c.c
> > > +++ b/drivers/iio/accel/adxl367_i2c.c
> > > @@ -11,7 +11,7 @@
> > >
> > > #include "adxl367.h"
> > >
> > > -#define ADXL367_I2C_FIFO_DATA 0x42
> > > +#define ADXL367_I2C_FIFO_DATA 0x18
> > >
> > > struct adxl367_i2c_state {
> > > struct regmap *regmap;
> >
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-25 14:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 1/2] iio: accel: adxl367: fix DEVID read after reset Nuno Sá
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox