Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Linus Walleij <linusw@kernel.org>
Cc: "Cong Nguyen" <congnt264@gmail.com>,
	"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: Mon, 3 Aug 2026 00:19:47 +0100	[thread overview]
Message-ID: <20260803001947.4ca48e75@jic23-huawei> (raw)
In-Reply-To: <CAD++jLmdgtA=5z+83jFivgbDNnrh0f5C_YNnHdZw_FmTJc2ZgA@mail.gmail.com>

On Sun, 2 Aug 2026 23:30:31 +0200
Linus Walleij <linusw@kernel.org> wrote:

> On Sun, Aug 2, 2026 at 8:55 AM 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.
> >
> > 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>
Applied to the fixes-togreg branch of iio.git

Note this will probably not go upstream until the merge window.

Thanks,

Jonathan

> 
> Yours,
> Linus Walleij


      reply	other threads:[~2026-08-02 23:19 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
2026-08-02 21:30 ` Linus Walleij
2026-08-02 23:19   ` Jonathan Cameron [this message]

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=20260803001947.4ca48e75@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=congnt264@gmail.com \
    --cc=dlechner@baylibre.com \
    --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