mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <dlechner@baylibre.com>
Cc: "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: imu: bno055: fix BNO055_SCAN_CH_COUNT off by one
Date: Sun, 1 Mar 2026 12:27:38 +0000	[thread overview]
Message-ID: <20260301122738.3e4a74a1@jic23-huawei> (raw)
In-Reply-To: <20260214-iio-imu-bno055-count-off-by-one-v1-1-42b2675edc6a@baylibre.com>

On Sat, 14 Feb 2026 16:33:54 -0600
David Lechner <dlechner@baylibre.com> wrote:

> Fix an off-by-one error in the BNO055_SCAN_CH_COUNT macro. The count
> is derived by taking the difference of the last and first register
> addresses, dividing by the size of each channel (2 bytes). It needs to
> also add 1 to account for the fact that the count is inclusive of both
> the first and last channels.
> 
> Thanks to the aligned_s64 timestamp field, there was already extra
> padding in the buffer, so there were no runtime issues caused by this
> bug.
> 
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
> I didn't put a Fixes: tag since this there were no runtime bugs. Didn't
> know if this was worth backporting or not.
I took the view that it isn't obvious that this is not a bug and hence
it might confuse readers in the future.  So I gave it fixes tag.
Still I didn't +CC stable as agree there is no urgency to backport.

Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/bno055/bno055.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/imu/bno055/bno055.c b/drivers/iio/imu/bno055/bno055.c
> index 303bc308f80a..c96fec2ebb3e 100644
> --- a/drivers/iio/imu/bno055/bno055.c
> +++ b/drivers/iio/imu/bno055/bno055.c
> @@ -64,7 +64,7 @@
>  #define BNO055_GRAVITY_DATA_X_LSB_REG	0x2E
>  #define BNO055_GRAVITY_DATA_Y_LSB_REG	0x30
>  #define BNO055_GRAVITY_DATA_Z_LSB_REG	0x32
> -#define BNO055_SCAN_CH_COUNT ((BNO055_GRAVITY_DATA_Z_LSB_REG - BNO055_ACC_DATA_X_LSB_REG) / 2)
> +#define BNO055_SCAN_CH_COUNT ((BNO055_GRAVITY_DATA_Z_LSB_REG - BNO055_ACC_DATA_X_LSB_REG) / 2 + 1)
>  #define BNO055_TEMP_REG			0x34
>  #define BNO055_CALIB_STAT_REG		0x35
>  #define BNO055_CALIB_STAT_MAGN_SHIFT 0
> 
> ---
> base-commit: 0713b26190addfa3a774b386c8658952ef9f7faf
> change-id: 20260214-iio-imu-bno055-count-off-by-one-3b67a0caaaf6
> 
> Best regards,


      reply	other threads:[~2026-03-01 12:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-14 22:33 David Lechner
2026-03-01 12:27 ` 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=20260301122738.3e4a74a1@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --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

all inboxes | Powered by JetHome®