Devicetree
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Jinseob Kim <kimjinseob88@gmail.com>
Cc: linux-iio@vger.kernel.org, dlechner@baylibre.com,
	nuno.sa@analog.com, andy@kernel.org,
	linux-kernel@vger.kernel.org, rdunlap@infradead.org,
	joshua.crofts1@gmail.com, u.kleine-koenig@baylibre.com,
	julianbraha@gmail.com, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, grondon@gmail.com,
	devicetree@vger.kernel.org, corbet@lwn.net,
	skhan@linuxfoundation.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH v8 5/5] iio: osf: add UART IIO driver
Date: Fri, 21 Aug 2026 04:03:24 +0100	[thread overview]
Message-ID: <20260821040324.14cbac9a@jic23-huawei> (raw)
In-Reply-To: <20260820050608.5440-6-kimjinseob88@gmail.com>

On Thu, 20 Aug 2026 14:06:08 +0900
Jinseob Kim <kimjinseob88@gmail.com> wrote:

> Add the Open Sensor Fusion serdev transport, driver core, and IIO
> registration path as one complete driver patch.
> 
> The driver enables the required vcc regulator, receives OSF frames over
> UART, registers IIO devices from capability reports, supports direct raw
> reads from the latest sample cache, and pushes buffered samples into
> software kfifo buffers.

Too much info.  We definitely don't need mention it turns on the power
or that the data goes standard paths.

> 
> Wire the stream parser frame callback to the OSF core, use final Kconfig
> and Makefile contents from the start, check iio_buffer_enabled() before
> pushing samples, and use zero-initialized scan storage with explicit
> timestamp alignment.
> 
> Classify authenticated application outcomes as handled, ignored, or
> rejected so the parser consumes every CRC-valid frame in full. Decode
> capability entries structurally, skip unsupported entries individually,
> and register the supported entries from the same report. Allocate latest
> sample cache slots only for sensors with registered IIO devices.
> 
> Deliver sensor samples to IIO before committing the latest-sample
> cache, so a frame rejected by the registered channel layout or buffer
> path cannot change direct-read state or the last accepted sequence.
> Add focused KUnit coverage for rejected, valid, ignored, and malformed
> sample paths and cache-slot exhaustion.
> 
> Signed-off-by: Jinseob Kim <kimjinseob88@gmail.com>

A couple of minor things inline. 

Thanks,

Jonathan

> diff --git a/drivers/iio/opensensorfusion/osf_iio.c b/drivers/iio/opensensorfusion/osf_iio.c
> new file mode 100644
> index 000000000000..56030b4d6a9f
> --- /dev/null
> +++ b/drivers/iio/opensensorfusion/osf_iio.c
> @@ -0,0 +1,304 @@

...

> +
> +#define OSF_MOD_CHAN(_type, _mod, _idx)                         \
> +	{                                                               \
> +		.type = (_type),                                           \
> +		.modified = 1,                                             \
> +		.channel2 = (_mod),                                        \
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),              \
> +		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),      \
> +		.scan_index = (_idx),                                      \
> +		.scan_type = {                                             \
> +			.sign = 's',                                         \
> +			.realbits = 32,                                      \
> +			.storagebits = 32,                                   \
> +			.endianness = IIO_CPU,                               \
> +		},                                                        \
> +	}
> +
> +#define OSF_CHAN(_type, _idx)                                     \
> +	{                                                               \
> +		.type = (_type),                                           \
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),              \
> +		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),      \
> +		.scan_index = (_idx),                                      \
> +		.scan_type = {                                             \
> +			.sign = 's',                                         \
> +			.realbits = 32,                                      \
> +			.storagebits = 32,                                   \
> +			.endianness = IIO_CPU,                               \
> +		},                                                        \
> +	}

Tidy up the \ as there doesn't seem to be any standard arrangement going on here.

> +int osf_iio_push_sample(struct iio_dev *indio_dev, const s32 *values,
> +			u16 channel_count)
> +{
> +	struct osf_iio_state *state = iio_priv(indio_dev);
> +	s64 timestamp;
> +
> +	if (channel_count != state->spec->channel_count)
> +		return -EPROTO;
> +
> +	if (!iio_buffer_enabled(indio_dev))
> +		return 0;
> +
> +	timestamp = iio_get_time_ns(indio_dev);
> +
> +	switch (channel_count) {
> +	case 1: {
> +		struct osf_iio_scan_1axis scan = { };

Similar to below - you might as well initialize the one value.

> +
> +		scan.value = values[0];
> +		return iio_push_to_buffers_with_ts(indio_dev, &scan,
> +						       sizeof(scan), timestamp);

Check for bits of alignment of code that have become wrong over time.

> +	}
> +	case 3: {
> +		struct osf_iio_scan_3axis scan = { };
> +
> +		scan.values[0] = values[0];
> +		scan.values[1] = values[1];
> +		scan.values[2] = values[2];

Might as well do
		struct osf_iio_scan_3axis scan = {
			.values[0] = values[0],
			.values[1] = values[1],
			.values[2] = values[2],
		};
Similar for other cases.

> +		return iio_push_to_buffers_with_ts(indio_dev, &scan,
> +						       sizeof(scan), timestamp);
> +	}
> +	default:
> +		return -EPROTO;
> +	}
> +}

  parent reply	other threads:[~2026-08-21  3:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20  5:06 [PATCH v8 0/5] iio: add Open Sensor Fusion IIO driver Jinseob Kim
2026-08-20  5:06 ` [PATCH v8 1/5] dt-bindings: iio: add Open Sensor Fusion device Jinseob Kim
2026-08-20  5:06 ` [PATCH v8 2/5] Documentation: iio: add Open Sensor Fusion driver overview Jinseob Kim
2026-08-20  5:06 ` [PATCH v8 3/5] iio: osf: add protocol decoding Jinseob Kim
2026-08-20  5:06 ` [PATCH v8 4/5] iio: osf: add authenticated stream parser Jinseob Kim
2026-08-21  2:47   ` Jonathan Cameron
2026-08-20  5:06 ` [PATCH v8 5/5] iio: osf: add UART IIO driver Jinseob Kim
2026-08-20  5:27   ` sashiko-bot
2026-08-21  3:03   ` Jonathan Cameron [this message]
2026-08-21  2:33 ` [PATCH v8 0/5] iio: add Open Sensor Fusion " 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=20260821040324.14cbac9a@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=grondon@gmail.com \
    --cc=joshua.crofts1@gmail.com \
    --cc=julianbraha@gmail.com \
    --cc=kimjinseob88@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=rdunlap@infradead.org \
    --cc=robh@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=u.kleine-koenig@baylibre.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