* [PATCH v1 1/1] iio: accel: adxl367: fix setting odr for activity time update
@ 2025-02-21 20:33 Lothar Rubusch
2025-02-22 15:03 ` Jonathan Cameron
0 siblings, 1 reply; 5+ messages in thread
From: Lothar Rubusch @ 2025-02-21 20:33 UTC (permalink / raw)
To: lars, Michael.Hennerich, cosmin.tanislav, jic23
Cc: linux-iio, linux-kernel, l.rubusch
Fix setting the odr value to update activity time based on frequency
derrived by recent odr, and not by obsolete odr value.
The [small] bug: When _adxl367_set_odr() is called with a new odr value,
it first writes the new odr value to the hardware register
ADXL367_REG_FILTER_CTL.
Second, it calls _adxl367_set_act_time_ms(), which calls
adxl367_time_ms_to_samples(). Here st->odr still holds the old odr value.
This st->odr member is used to derrive a frequency value, which is
applied to update ADXL367_REG_TIME_ACT. Hence, the idea is to update
activity time, based on possibilities and power consumption by the
current ODR rate.
Finally, when the function calls return, again in _adxl367_set_odr() the
new ODR is assigned to st->odr.
The fix: When setting a new ODR value is set to ADXL367_REG_FILTER_CTL,
also ADXL367_REG_TIME_ACT should probably be updated with a frequency
based on the recent ODR value and not the old one. Changing the location
of the assignment to st->odr fixes this.
Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
---
drivers/iio/accel/adxl367.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/iio/accel/adxl367.c b/drivers/iio/accel/adxl367.c
index add4053e7a02..0c04b2bb7efb 100644
--- a/drivers/iio/accel/adxl367.c
+++ b/drivers/iio/accel/adxl367.c
@@ -601,18 +601,14 @@ static int _adxl367_set_odr(struct adxl367_state *st, enum adxl367_odr odr)
if (ret)
return ret;
+ st->odr = odr;
+
/* Activity timers depend on ODR */
ret = _adxl367_set_act_time_ms(st, st->act_time_ms);
if (ret)
return ret;
- ret = _adxl367_set_inact_time_ms(st, st->inact_time_ms);
- if (ret)
- return ret;
-
- st->odr = odr;
-
- return 0;
+ return _adxl367_set_inact_time_ms(st, st->inact_time_ms);
}
static int adxl367_set_odr(struct iio_dev *indio_dev, enum adxl367_odr odr)
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] iio: accel: adxl367: fix setting odr for activity time update
2025-02-21 20:33 [PATCH v1 1/1] iio: accel: adxl367: fix setting odr for activity time update Lothar Rubusch
@ 2025-02-22 15:03 ` Jonathan Cameron
2025-03-08 21:26 ` Lothar Rubusch
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2025-02-22 15:03 UTC (permalink / raw)
To: Lothar Rubusch
Cc: lars, Michael.Hennerich, cosmin.tanislav, linux-iio, linux-kernel
On Fri, 21 Feb 2025 20:33:52 +0000
Lothar Rubusch <l.rubusch@gmail.com> wrote:
> Fix setting the odr value to update activity time based on frequency
> derrived by recent odr, and not by obsolete odr value.
>
> The [small] bug: When _adxl367_set_odr() is called with a new odr value,
> it first writes the new odr value to the hardware register
> ADXL367_REG_FILTER_CTL.
> Second, it calls _adxl367_set_act_time_ms(), which calls
> adxl367_time_ms_to_samples(). Here st->odr still holds the old odr value.
> This st->odr member is used to derrive a frequency value, which is
> applied to update ADXL367_REG_TIME_ACT. Hence, the idea is to update
> activity time, based on possibilities and power consumption by the
> current ODR rate.
> Finally, when the function calls return, again in _adxl367_set_odr() the
> new ODR is assigned to st->odr.
>
> The fix: When setting a new ODR value is set to ADXL367_REG_FILTER_CTL,
> also ADXL367_REG_TIME_ACT should probably be updated with a frequency
> based on the recent ODR value and not the old one. Changing the location
> of the assignment to st->odr fixes this.
>
> Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Fixes tag?
Otherwise looks good to me.
> ---
> drivers/iio/accel/adxl367.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/iio/accel/adxl367.c b/drivers/iio/accel/adxl367.c
> index add4053e7a02..0c04b2bb7efb 100644
> --- a/drivers/iio/accel/adxl367.c
> +++ b/drivers/iio/accel/adxl367.c
> @@ -601,18 +601,14 @@ static int _adxl367_set_odr(struct adxl367_state *st, enum adxl367_odr odr)
> if (ret)
> return ret;
>
> + st->odr = odr;
> +
> /* Activity timers depend on ODR */
> ret = _adxl367_set_act_time_ms(st, st->act_time_ms);
> if (ret)
> return ret;
>
> - ret = _adxl367_set_inact_time_ms(st, st->inact_time_ms);
> - if (ret)
> - return ret;
> -
> - st->odr = odr;
> -
> - return 0;
> + return _adxl367_set_inact_time_ms(st, st->inact_time_ms);
> }
>
> static int adxl367_set_odr(struct iio_dev *indio_dev, enum adxl367_odr odr)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] iio: accel: adxl367: fix setting odr for activity time update
2025-02-22 15:03 ` Jonathan Cameron
@ 2025-03-08 21:26 ` Lothar Rubusch
2025-03-09 14:25 ` Marcelo Schmitt
2025-03-09 16:14 ` Jonathan Cameron
0 siblings, 2 replies; 5+ messages in thread
From: Lothar Rubusch @ 2025-03-08 21:26 UTC (permalink / raw)
To: Jonathan Cameron
Cc: lars, Michael.Hennerich, cosmin.tanislav, linux-iio, linux-kernel
On Sat, Feb 22, 2025 at 4:03 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Fri, 21 Feb 2025 20:33:52 +0000
> Lothar Rubusch <l.rubusch@gmail.com> wrote:
>
> > Fix setting the odr value to update activity time based on frequency
> > derrived by recent odr, and not by obsolete odr value.
> >
> > The [small] bug: When _adxl367_set_odr() is called with a new odr value,
> > it first writes the new odr value to the hardware register
> > ADXL367_REG_FILTER_CTL.
> > Second, it calls _adxl367_set_act_time_ms(), which calls
> > adxl367_time_ms_to_samples(). Here st->odr still holds the old odr value.
> > This st->odr member is used to derrive a frequency value, which is
> > applied to update ADXL367_REG_TIME_ACT. Hence, the idea is to update
> > activity time, based on possibilities and power consumption by the
> > current ODR rate.
> > Finally, when the function calls return, again in _adxl367_set_odr() the
> > new ODR is assigned to st->odr.
> >
> > The fix: When setting a new ODR value is set to ADXL367_REG_FILTER_CTL,
> > also ADXL367_REG_TIME_ACT should probably be updated with a frequency
> > based on the recent ODR value and not the old one. Changing the location
> > of the assignment to st->odr fixes this.
> >
> > Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
> Fixes tag?
>
Hi IIO ML readers - Hi Jonathan,
AFAIK there is no tracked bug which I could refer to. Alternatively, I
could refer to
the commit hash of the original commit which introduced the code this
patch is supposed
to fix. Is this ok? Could you please help me here with the process?
> Otherwise looks good to me.
>
> > ---
> > drivers/iio/accel/adxl367.c | 10 +++-------
> > 1 file changed, 3 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/iio/accel/adxl367.c b/drivers/iio/accel/adxl367.c
> > index add4053e7a02..0c04b2bb7efb 100644
> > --- a/drivers/iio/accel/adxl367.c
> > +++ b/drivers/iio/accel/adxl367.c
> > @@ -601,18 +601,14 @@ static int _adxl367_set_odr(struct adxl367_state *st, enum adxl367_odr odr)
> > if (ret)
> > return ret;
> >
> > + st->odr = odr;
> > +
> > /* Activity timers depend on ODR */
> > ret = _adxl367_set_act_time_ms(st, st->act_time_ms);
> > if (ret)
> > return ret;
> >
> > - ret = _adxl367_set_inact_time_ms(st, st->inact_time_ms);
> > - if (ret)
> > - return ret;
> > -
> > - st->odr = odr;
> > -
> > - return 0;
> > + return _adxl367_set_inact_time_ms(st, st->inact_time_ms);
> > }
> >
> > static int adxl367_set_odr(struct iio_dev *indio_dev, enum adxl367_odr odr)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/1] iio: accel: adxl367: fix setting odr for activity time update
2025-03-08 21:26 ` Lothar Rubusch
@ 2025-03-09 14:25 ` Marcelo Schmitt
2025-03-09 16:14 ` Jonathan Cameron
1 sibling, 0 replies; 5+ messages in thread
From: Marcelo Schmitt @ 2025-03-09 14:25 UTC (permalink / raw)
To: Lothar Rubusch
Cc: Jonathan Cameron, lars, Michael.Hennerich, cosmin.tanislav,
linux-iio, linux-kernel
Hi Lothar,
On 03/08, Lothar Rubusch wrote:
> On Sat, Feb 22, 2025 at 4:03 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > On Fri, 21 Feb 2025 20:33:52 +0000
> > Lothar Rubusch <l.rubusch@gmail.com> wrote:
> >
> > > Fix setting the odr value to update activity time based on frequency
> > > derrived by recent odr, and not by obsolete odr value.
> > >
...
> > >
> > > Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
...
>
> Hi IIO ML readers - Hi Jonathan,
> AFAIK there is no tracked bug which I could refer to. Alternatively, I
> could refer to
> the commit hash of the original commit which introduced the code this
> patch is supposed
> to fix. Is this ok? Could you please help me here with the process?
Yes, the fixes tag should point to the commit that introduced the code that is
being fixed. So, this this patch should carry the following tag
Fixes: cbab791c5e2a ("iio: accel: add ADXL367 driver")
Also,
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v1 1/1] iio: accel: adxl367: fix setting odr for activity time update
2025-03-08 21:26 ` Lothar Rubusch
2025-03-09 14:25 ` Marcelo Schmitt
@ 2025-03-09 16:14 ` Jonathan Cameron
1 sibling, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2025-03-09 16:14 UTC (permalink / raw)
To: Lothar Rubusch
Cc: lars, Michael.Hennerich, cosmin.tanislav, linux-iio, linux-kernel
On Sat, 8 Mar 2025 22:26:36 +0100
Lothar Rubusch <l.rubusch@gmail.com> wrote:
> On Sat, Feb 22, 2025 at 4:03 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > On Fri, 21 Feb 2025 20:33:52 +0000
> > Lothar Rubusch <l.rubusch@gmail.com> wrote:
> >
> > > Fix setting the odr value to update activity time based on frequency
> > > derrived by recent odr, and not by obsolete odr value.
> > >
> > > The [small] bug: When _adxl367_set_odr() is called with a new odr value,
> > > it first writes the new odr value to the hardware register
> > > ADXL367_REG_FILTER_CTL.
> > > Second, it calls _adxl367_set_act_time_ms(), which calls
> > > adxl367_time_ms_to_samples(). Here st->odr still holds the old odr value.
> > > This st->odr member is used to derrive a frequency value, which is
> > > applied to update ADXL367_REG_TIME_ACT. Hence, the idea is to update
> > > activity time, based on possibilities and power consumption by the
> > > current ODR rate.
> > > Finally, when the function calls return, again in _adxl367_set_odr() the
> > > new ODR is assigned to st->odr.
> > >
> > > The fix: When setting a new ODR value is set to ADXL367_REG_FILTER_CTL,
> > > also ADXL367_REG_TIME_ACT should probably be updated with a frequency
> > > based on the recent ODR value and not the old one. Changing the location
> > > of the assignment to st->odr fixes this.
> > >
> > > Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
> > Fixes tag?
> >
>
> Hi IIO ML readers - Hi Jonathan,
> AFAIK there is no tracked bug which I could refer to. Alternatively, I
> could refer to
> the commit hash of the original commit which introduced the code this
> patch is supposed
> to fix. Is this ok? Could you please help me here with the process?
Follow description in the submitting-patches documentation.
https://elixir.bootlin.com/linux/v6.14-rc5/source/Documentation/process/submitting-patches.rst
Here the commit hash + description is what I am after in the appropriate
format as described in that doc.
I don't really care about patch trackers as most bug fixes are never in
them as they come from people noticing issues whilst reading or testing
the code during other development.
Jonathan
>
> > Otherwise looks good to me.
> >
> > > ---
> > > drivers/iio/accel/adxl367.c | 10 +++-------
> > > 1 file changed, 3 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/drivers/iio/accel/adxl367.c b/drivers/iio/accel/adxl367.c
> > > index add4053e7a02..0c04b2bb7efb 100644
> > > --- a/drivers/iio/accel/adxl367.c
> > > +++ b/drivers/iio/accel/adxl367.c
> > > @@ -601,18 +601,14 @@ static int _adxl367_set_odr(struct adxl367_state *st, enum adxl367_odr odr)
> > > if (ret)
> > > return ret;
> > >
> > > + st->odr = odr;
> > > +
> > > /* Activity timers depend on ODR */
> > > ret = _adxl367_set_act_time_ms(st, st->act_time_ms);
> > > if (ret)
> > > return ret;
> > >
> > > - ret = _adxl367_set_inact_time_ms(st, st->inact_time_ms);
> > > - if (ret)
> > > - return ret;
> > > -
> > > - st->odr = odr;
> > > -
> > > - return 0;
> > > + return _adxl367_set_inact_time_ms(st, st->inact_time_ms);
> > > }
> > >
> > > static int adxl367_set_odr(struct iio_dev *indio_dev, enum adxl367_odr odr)
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-03-09 16:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-21 20:33 [PATCH v1 1/1] iio: accel: adxl367: fix setting odr for activity time update Lothar Rubusch
2025-02-22 15:03 ` Jonathan Cameron
2025-03-08 21:26 ` Lothar Rubusch
2025-03-09 14:25 ` Marcelo Schmitt
2025-03-09 16:14 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox