Skip to content

Commit fe5bfc9

Browse files
vladislav-pejicaescolar
authored andcommitted
driver: sensor: adxl372: Bug fix for status2 reg
This is a bug fix for adxl372_get_status function. This function is used to get STATUS1, STATUS2, FIFO_ENTRIES2 and FIFO_ENTRIES1 registers (they are continuously present in the memory in this order). User can choose if it wants STATUS2 and/or FIFO registers by passing pointers where to store received values. Bug was when user doesn't want STATUS2 and want FIFO regs. In that case calculated length would be 3 which will result in reading of STATUS1, STATUS2 and FIFO_ENTRIES2 regs and not expected STATUS1, FIFO_ENTRIES2 and FIFO_ENTRIES1. Signed-off-by: Vladislav Pejic <[email protected]>
1 parent 4ce3a7b commit fe5bfc9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/sensor/adi/adxl372/adxl372.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,16 @@ int adxl372_get_status(const struct device *dev,
364364
}
365365

366366
if (fifo_entries) {
367-
length += 2U;
367+
if (status2) {
368+
length += 2U;
369+
} else {
370+
/* Registers STATUS1, STATUS2, FIFO_ENTRIES2 and FIFO_ENTRIES1
371+
* are one after the other. If user wants fifo_entries and
372+
* not status2, to get the correct values, STATUS2 register
373+
* also must be read but read value will be ignored.
374+
*/
375+
length += 3U;
376+
}
368377
}
369378

370379
ret = data->hw_tf->read_reg_multiple(dev, ADXL372_STATUS_1, buf, length);

0 commit comments

Comments
 (0)