Skip to content

Commit 4e4ec9c

Browse files
ubiedakartben
authored andcommitted
sensor: icm42688: fix One-shot decoder to only return requested fields
Otherwise clients will get the impression there are frames for values that have not been retrieved. Signed-off-by: Luis Ubieda <luisf@croxel.com>
1 parent f850634 commit 4e4ec9c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/sensor/tdk/icm42688/icm42688_decoder.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,21 @@ static int icm42688_decoder_get_frame_count(const uint8_t *buffer,
515515
uint16_t *frame_count)
516516
{
517517
const struct icm42688_fifo_data *data = (const struct icm42688_fifo_data *)buffer;
518+
const struct icm42688_encoded_data *enc_data = (const struct icm42688_encoded_data *)buffer;
518519
const struct icm42688_decoder_header *header = &data->header;
519520

520521
if (chan_spec.chan_idx != 0) {
521522
return -ENOTSUP;
522523
}
523524

525+
uint8_t channel_request = icm42688_encode_channel(chan_spec.chan_type);
526+
527+
528+
if ((!enc_data->header.is_fifo) &&
529+
(enc_data->channels & channel_request) != channel_request) {
530+
return -ENODATA;
531+
}
532+
524533
if (!header->is_fifo) {
525534
switch (chan_spec.chan_type) {
526535
case SENSOR_CHAN_ACCEL_X:

0 commit comments

Comments
 (0)