From: sashiko-bot@kernel.org
To: "Jinseob Kim" <kimjinseob88@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH RFC v2 4/7] iio: osf: add stream parser
Date: Sun, 24 May 2026 09:41:56 +0000 [thread overview]
Message-ID: <20260524094156.D7B1E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260524085312.15369-5-kimjinseob88@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] The 'partial_frames' statistic is incremented erroneously during normal chunked data reception, making the metric artificially spammed and useless.
- [Low] The frame is successfully parsed into a stack variable, but the populated structure is ignored and completely unused.
--
commit f278438df751263938f58f94af6a218883f9f11f
Author: Jinseob Kim <kimjinseob88@gmail.com>
iio: osf: add stream parser
This commit introduces byte stream assembly and frame synchronization
capabilities for OSF0 frames. It handles buffering, magic sequence matching,
and payload validation before passing frames to the core.
> diff --git a/drivers/iio/opensensorfusion/osf_stream.c b/drivers/iio/opensensorfusion/osf_stream.c
> --- /dev/null
> +++ b/drivers/iio/opensensorfusion/osf_stream.c
[ ... ]
> +static int osf_stream_process(struct osf_stream *stream)
> +{
> + struct osf_frame frame;
> + size_t decoded_len;
> + size_t discarded;
> + size_t frame_len;
> + u32 payload_len;
> + int first_err = 0;
> + int ret;
> +
> + while (stream->len) {
> + discarded = osf_stream_discard_to_magic(stream);
[ ... ]
> + if (!stream->len)
> + break;
> +
> + if (stream->len < OSF_FRAME_HEADER_LEN) {
> + stream->stats.partial_frames++;
[Severity: Medium]
Is it intentional to increment this statistic during normal chunked data
reception?
Since stream data often arrives in partial fragments, breaking here is expected
behavior while waiting for the rest of the stream. Incrementing an error
counter on every normal yield might spam the metric and make it less useful
for debugging actual issues.
> + break;
> + }
> +
> + if (get_unaligned_le16(stream->buf + 6) !=
[ ... ]
> + frame_len = OSF_FRAME_HEADER_LEN + payload_len + OSF_FRAME_CRC_LEN;
> + if (stream->len < frame_len) {
> + stream->stats.partial_frames++;
[Severity: Medium]
Similarly, does this falsely increment the partial_frames statistic while
simply waiting for the rest of a valid payload to arrive?
> + break;
> + }
> +
> + ret = osf_protocol_decode_frame(stream->buf, frame_len, &frame,
> + &decoded_len);
[ ... ]
> + if (decoded_len != frame_len) {
> + stream->stats.dropped_bytes++;
> + osf_stream_drop_invalid_head(stream);
> + if (!first_err)
> + first_err = -EMSGSIZE;
> + continue;
> + }
> +
> + ret = osf_core_receive_frame(stream->osf, stream->buf, frame_len);
[Severity: Low]
Does this code need to pass the raw buffer to osf_core_receive_frame()
instead of the parsed struct osf_frame?
The earlier call to osf_protocol_decode_frame() successfully parses the frame
into the stack variable frame, but it appears to go unused. Passing the
already-parsed structure to the core might avoid redundant decoding
inefficiency.
> + if (ret) {
> + osf_stream_discard(stream, frame_len);
> + if (!first_err)
> + first_err = ret;
> + continue;
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260524085312.15369-1-kimjinseob88@gmail.com?part=4
next prev parent reply other threads:[~2026-05-24 9:41 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-24 8:53 [PATCH RFC v2 0/7] iio: add Open Sensor Fusion UART driver Jinseob Kim
2026-05-24 8:53 ` [PATCH RFC v2 1/7] dt-bindings: iio: add Open Sensor Fusion UART device Jinseob Kim
2026-05-24 9:03 ` sashiko-bot
2026-05-24 18:59 ` Krzysztof Kozlowski
2026-05-24 19:34 ` Conor Dooley
2026-05-25 2:06 ` Kim Jinseob
2026-05-24 8:53 ` [PATCH RFC v2 2/7] Documentation: iio: add Open Sensor Fusion protocol v0 reference Jinseob Kim
2026-05-28 13:28 ` Jonathan Cameron
[not found] ` <CALMSew+3RVXxLJYtr3HkV7UeAf6Mqx6PpA2CehChoVaMFddpJw@mail.gmail.com>
2026-05-29 12:52 ` Kim Jinseob
2026-05-24 8:53 ` [PATCH RFC v2 3/7] iio: osf: add protocol v0 decoding Jinseob Kim
2026-05-24 9:16 ` sashiko-bot
2026-05-28 13:48 ` Jonathan Cameron
[not found] ` <CALMSew+wUH1H-2MTtexCFgyD4Y+upFuSfFzTWBn3VGN6CWYFNQ@mail.gmail.com>
2026-05-29 12:53 ` Kim Jinseob
2026-05-24 8:53 ` [PATCH RFC v2 4/7] iio: osf: add stream parser Jinseob Kim
2026-05-24 9:41 ` sashiko-bot [this message]
2026-05-28 13:58 ` Jonathan Cameron
2026-05-29 12:44 ` Kim Jinseob
2026-05-24 8:53 ` [PATCH RFC v2 5/7] iio: osf: add UART serdev transport Jinseob Kim
2026-05-28 14:06 ` Jonathan Cameron
2026-05-29 12:47 ` Kim Jinseob
2026-05-24 8:53 ` [PATCH RFC v2 6/7] iio: osf: register IIO devices from capabilities Jinseob Kim
2026-05-24 10:57 ` sashiko-bot
2026-05-28 14:30 ` Jonathan Cameron
2026-05-29 12:49 ` Kim Jinseob
2026-05-24 8:53 ` [PATCH RFC v2 7/7] MAINTAINERS: add Open Sensor Fusion IIO driver Jinseob Kim
2026-05-25 12:11 ` Krzysztof Kozlowski
2026-05-28 14:31 ` Jonathan Cameron
2026-05-29 12:51 ` Kim Jinseob
2026-05-29 13:07 ` Jonathan Cameron
2026-06-02 23:59 ` [PATCH RFC v2 0/7] iio: add Open Sensor Fusion UART driver Andy Shevchenko
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=20260524094156.D7B1E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kimjinseob88@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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