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

[Backport v3.7-branch] drivers/sensor/st: Fix wrong data byte swap for be #77627

Merged
merged 1 commit into from
Aug 31, 2024

Conversation

zephyrbot
Copy link
Collaborator

@zephyrbot zephyrbot commented Aug 27, 2024

Backport 9ea4cb9 from #76557.

Fixes #75758

A 16-bit value built using byte shifts and ORs from a given
couple of lsb and msb bytes will result to be the same on both
little-endian and big-endian architectures, e.g.

    uint8_t lsb, msb;
    int16_t val;

    /* val is the same number on both le and be archs, but has
       different layout in memory */
    val = (msb << 8) | lsb;

All the xyz_raw_get() APIs of stmemsc sensor module build the sensor
data using the above method and DO NOT hence require (it actually leads
to wrong values on big-endian machines) to use any le/be swap routines,
such as sys_le16_to_cpu().

Fix #75758

Signed-off-by: Armando Visconti <[email protected]>
(cherry picked from commit 9ea4cb9)
@avisconti avisconti added the bug The issue is a bug, or the PR is fixing a bug label Aug 27, 2024
@nashif nashif merged commit d800cce into v3.7-branch Aug 31, 2024
29 checks passed
@nashif nashif deleted the backport-76557-to-v3.7-branch branch August 31, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Sensors Sensors Backport Backport PR and backport failure issues bug The issue is a bug, or the PR is fixing a bug
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants