Skip to content

Commit 277fc68

Browse files
Rubuschgregkh
authored andcommitted
iio: accel: adxl367: fix setting odr for activity time update
[ Upstream commit 38f67d0 ] 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. Fixes: cbab791 ("iio: accel: add ADXL367 driver") Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com> Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com> Link: https://patch.msgid.link/20250309193515.2974-1-l.rubusch@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a5f4a38 commit 277fc68

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

drivers/iio/accel/adxl367.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -604,18 +604,14 @@ static int _adxl367_set_odr(struct adxl367_state *st, enum adxl367_odr odr)
604604
if (ret)
605605
return ret;
606606

607+
st->odr = odr;
608+
607609
/* Activity timers depend on ODR */
608610
ret = _adxl367_set_act_time_ms(st, st->act_time_ms);
609611
if (ret)
610612
return ret;
611613

612-
ret = _adxl367_set_inact_time_ms(st, st->inact_time_ms);
613-
if (ret)
614-
return ret;
615-
616-
st->odr = odr;
617-
618-
return 0;
614+
return _adxl367_set_inact_time_ms(st, st->inact_time_ms);
619615
}
620616

621617
static int adxl367_set_odr(struct iio_dev *indio_dev, enum adxl367_odr odr)

0 commit comments

Comments
 (0)