From: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <dlechner@baylibre.com>
Cc: "Andy Shevchenko" <andriy.shevchenko@intel.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"shuaijie wang" <wangshuaijie@awinic.com>,
"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: proximity: aw96103: fix firmware read on big-endian
Date: Sat, 21 Mar 2026 20:14:12 +0000 [thread overview]
Message-ID: <20260321201412.16d86fe1@jic23-huawei> (raw)
In-Reply-To: <60aea3c6-52db-42a5-b1b5-b0af50e3342b@baylibre.com>
On Mon, 16 Mar 2026 09:36:33 -0500
David Lechner <dlechner@baylibre.com> wrote:
> On 3/16/26 5:22 AM, Andy Shevchenko wrote:
> > On Sat, Mar 14, 2026 at 06:20:12PM -0500, David Lechner wrote:
> >> Use get_unaligned_le32() instead of casting to int * to make sure that
> >> reading a 32-bit int value from the firmware binary works correctly on
> >> big-endian architectures.
> >
> > ...
> >
> >> bin->valid_data_addr = AW96103_BIN_VALID_DATA_OFFSET;
> >> bin->valid_data_len =
> >> - *(unsigned int *)(bin->data + AW96103_BIN_DATA_LEN_OFFSET) -
> >> + get_unaligned_le32(bin->data + AW96103_BIN_DATA_LEN_OFFSET) -
> >> AW96103_BIN_DATA_REG_NUM_SIZE;
> >> memcpy(bin->chip_type, bin->data + AW96103_BIN_CHIP_TYPE_OFFSET,
> >> AW96103_BIN_CHIP_TYPE_SIZE);
> >
> > I gave you a tag, but I have a question here:
> > Hmm... memcpy() happens to work probably due to keeping LE as LE and chip_type
> > being a byte stream itself, if AW96103_BIN_CHIP_TYPE_SIZE is bigger than a
> > byte. Otherwise it may suffer from the same issue, no?
> >
>
> I checked how bin->chip_type is used and it is a string, so not affected.
I'll give this one a bit longer so Shuaijie can hopefully take a look.
prev parent reply other threads:[~2026-03-21 20:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-14 23:20 David Lechner
2026-03-16 10:16 ` Andy Shevchenko
2026-03-16 10:22 ` Andy Shevchenko
2026-03-16 14:36 ` David Lechner
2026-03-21 20:14 ` 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=20260321201412.16d86fe1@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=andriy.shevchenko@intel.com \
--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 \
--cc=wangshuaijie@awinic.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®