From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Angel Iglesias <ang.iglesiasg@gmail.com>,
Andreas Klinger <ak@it-klinger.de>,
Benjamin Bara <bbara93@gmail.com>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/5] tools: iio: iio_generic_buffer ensure alignment
Date: Wed, 27 Sep 2023 15:32:15 +0300 [thread overview]
Message-ID: <a7096e0c-7132-5511-2fe0-1172caec5a7f@gmail.com> (raw)
In-Reply-To: <ZRQfyNX9WsvmpZ1r@smile.fi.intel.com>
On 9/27/23 15:27, Andy Shevchenko wrote:
> On Wed, Sep 27, 2023 at 11:26:07AM +0300, Matti Vaittinen wrote:
>> The iio_generic_buffer can return garbage values when the total size of
>> scan data is not a multiple of the largest element in the scan. This can be
>> demonstrated by reading a scan, consisting, for example of one 4-byte and
>> one 2-byte element, where the 4-byte element is first in the buffer.
>>
>> The IIO generic buffer code does not take into account the last two
>> padding bytes that are needed to ensure that the 4-byte data for next
>> scan is correctly aligned.
>>
>> Add the padding bytes required to align the next sample with the scan size.
>
> ...
>
>> + /*
>> + * We wan't the data in next sample to also be properly aligned so
>
> Pardon me, won't or want, I didn't get?..
Both :D Well, purpose was to say want, but as I try to explain we get
what we want only in some case - in other cases we won't ;) Anyways,
this is something that should be fixed - thanks :)
>
>> + * we'll add padding at the end if needed.
>> + *
>> + * Please note, this code does ensure alignment to maximum channel
>> + * size. It works only as long as the channel sizes are 1, 2, 4 or 8
>> + * bytes. Also, on 32 bit platforms it might be enough to align also
>
> 32-bit
>
>> + * the 8 byte elements to 4 byte boundary - which this code is not
>
> 8-byte
> 4-byte
>
>> + * doing.
>> + */
>
Thanks!
Yours,
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
next prev parent reply other threads:[~2023-09-27 12:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 8:18 [PATCH v4 0/5] Support ROHM BM1390 pressure sensor Matti Vaittinen
2023-09-27 8:26 ` [PATCH v4 1/5] tools: iio: iio_generic_buffer ensure alignment Matti Vaittinen
2023-09-27 12:27 ` Andy Shevchenko
2023-09-27 12:32 ` Matti Vaittinen [this message]
2023-09-30 16:34 ` Jonathan Cameron
2023-10-02 7:33 ` Matti Vaittinen
2023-09-27 8:27 ` [PATCH v4 2/5] iio: improve doc for available_scan_mask Matti Vaittinen
2023-09-30 16:54 ` Jonathan Cameron
2023-09-27 8:27 ` [PATCH v4 3/5] dt-bindings: Add ROHM BM1390 pressure sensor Matti Vaittinen
2023-09-27 8:28 ` [PATCH v4 4/5] iio: pressure: Support ROHM BU1390 Matti Vaittinen
2023-09-27 8:28 ` [PATCH v4 5/5] MAINTAINERS: Add ROHM BM1390 Matti Vaittinen
2023-09-30 17:01 ` 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=a7096e0c-7132-5511-2fe0-1172caec5a7f@gmail.com \
--to=mazziesaccount@gmail.com \
--cc=ak@it-klinger.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ang.iglesiasg@gmail.com \
--cc=bbara93@gmail.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=robh+dt@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).