Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

driver: sensor: adxl372: Bug fix for status2 reg #79105

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion drivers/sensor/adi/adxl372/adxl372.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,16 @@ int adxl372_get_status(const struct device *dev,
}

if (fifo_entries) {
length += 2U;
if (status2) {
length += 2U;
} else {
/* Registers STATUS1, STATUS2, FIFO_ENTRIES2 and FIFO_ENTRIES1
* are one after the other. If user wants fifo_entries and
* not status2, to get the correct values, STATUS2 register
* also must be read but read value will be ignored.
*/
length += 3U;
}
Comment on lines -367 to +376
Copy link
Member

@ubieda ubieda Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand the rationale for having a variable-length transfer here (I know it was in-tree in the first place; I'm suggesting to simplify it since it had a bug).

Wouldn't it be just easier to always pull the 4-bytes and depending on whether the pointer is valid: pass that config over?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My rationale was that I wanted to reduce SPI overhead and not read registers that are not necessary (FIFO ENTRIES1/2).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok - I personally find it harder to maintain this way vs the overhead of 1 or 2 extra bytes. It's a subjective thought though. Approving.

}

ret = data->hw_tf->read_reg_multiple(dev, ADXL372_STATUS_1, buf, length);
Expand Down
Loading