Linux IIO development
 help / color / mirror / Atom feed
From: Joshua Crofts <joshua.crofts1@gmail.com>
To: Cong Nguyen <congnt264@gmail.com>
Cc: "Linus Walleij" <linusw@kernel.org>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: gyro: mpu3050: fix sign of raw angular velocity readings
Date: Sun, 2 Aug 2026 17:55:47 +0200	[thread overview]
Message-ID: <20260802175517.288bd5a9@systembl0wer> (raw)
In-Reply-To: <20260802065540.8120-1-congnt264@gmail.com>

On Sun,  2 Aug 2026 13:55:40 +0700
Cong Nguyen <congnt264@gmail.com> wrote:

> 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.
> 

LGTM.

Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>

-- 
Kind regards,
Joshua Crofts

  parent reply	other threads:[~2026-08-02 15:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-02  6:55 [PATCH] iio: gyro: mpu3050: fix sign of raw angular velocity readings Cong Nguyen
2026-08-02 15:54 ` David Lechner
2026-08-02 15:55 ` Joshua Crofts [this message]
2026-08-02 21:30 ` Linus Walleij
2026-08-02 23:19   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260802175517.288bd5a9@systembl0wer \
    --to=joshua.crofts1@gmail.com \
    --cc=andy@kernel.org \
    --cc=congnt264@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox