summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCong Nguyen <congnt264@gmail.com>2026-08-02 13:55:40 +0700
committerJonathan Cameron <jonathan.cameron@oss.qualcomm.com>2026-08-07 23:51:05 +0100
commit06fab97602fe400bea843176f485bbac07a668e2 (patch)
tree35725e22b3a2032d8aa0dcbc4ca4223b851dadc0 /include
parenta40b2e7a17f26e38ab054363c9c7cde149588357 (diff)
iio: gyro: mpu3050: fix sign of raw angular velocity readings
The MPU-3050 gyroscope output registers hold 16-bit two's complement values; the angular velocity channels are declared with .sign = 's'. When mpu3050_read_raw() handles IIO_CHAN_INFO_RAW it reads the register via a big-endian regmap_bulk_read() and assigns it with: *val = be16_to_cpu(raw_val); be16_to_cpu() yields an unsigned 16-bit quantity, so negative rates (bit 15 set) are reported to userspace as large positive integers (e.g. -1 becomes 65535) instead of the correct negative value. Cast to s16 before the assignment, matching the temperature channel a few lines above which already handles the sign correctly. Fixes: 3904b28efb2c ("iio: gyro: Add driver for the MPU-3050 gyroscope") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4 Signed-off-by: Cong Nguyen <congnt264@gmail.com> Reviewed-by: Linus Walleij <linusw@kernel.org> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions