From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Muchamad Coirul Anwar <muchamadcoirulanwar@gmail.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Igor Korotin" <igor.korotin@linux.dev>,
"Danilo Krummrich" <dakr@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Andi Shyti" <andi.shyti@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Mark Brown" <broonie@kernel.org>,
"Joshua Crofts" <crofts@kernel.org>,
"Markus Probst" <markus.probst@posteo.de>,
"Shuai Liu" <847807867@qq.com>,
linux-iio@vger.kernel.org, linux-i2c@vger.kernel.org,
rust-for-linux@vger.kernel.org, driver-core@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v8 3/4] rust: add minimal IIO subsystem abstractions
Date: Thu, 3 Dec 2026 12:53:33 +0200 [thread overview]
Message-ID: <axFKLYzOloxb9FOO@ashevche-desk.local> (raw)
In-Reply-To: <20261201165508.39336-4-muchamadcoirulanwar@gmail.com>
On Tue, Dec 01, 2026 at 11:55:07PM +0700, Muchamad Coirul Anwar wrote:
> Add minimal Rust abstractions needed to register direct-mode IIO
> devices exposing read_raw channel information.
>
> Provide a type-safe IioChanInfo selector, IioVal return types, and an
> IioDriver trait. Add a C callback trampoline that validates the channel
> information selector, invokes the Rust driver, and converts IioVal into
> the representation expected by the IIO core.
>
> Use typestate to distinguish unregistered and registered devices.
> Registration is unsafe because callers must not leak the returned device
> (e.g. via mem::forget). It returns an owned registered device bound to
> the parent lifetime, whose destructor unregisters it before destroying
> its Rust private data and releasing the allocation reference.
>
> Allow private data to borrow resources tied to the bound parent
> lifetime. This lets drivers capture bus-specific resources during probe
> and use them directly from subsystem callbacks without recovering them
> from a generic parent device.
>
> Accept only INDIO_DIRECT_MODE. Other modes require additional state and
> teardown handling not provided by this initial abstraction.
>
> The initial abstraction intentionally supports read_raw only. It does
> not expose write_raw, buffers, triggers, events, extended attributes, or
> available-value attributes.
...
> --- a/rust/bindings/bindings_helper.h
> +++ b/rust/bindings/bindings_helper.h
> @@ -64,6 +64,8 @@
> #include <linux/fwctl.h>
> #include <linux/fs.h>
> #include <linux/i2c.h>
> +#include <linux/iio/iio.h>
> +#include <linux/iio/types.h>
No need, this is separated header, but it's rarely needed standalone. iio.h
guarantees that it will provide necessary types.
> #include <linux/interrupt.h>
> #include <linux/io-pgtable.h>
> #include <linux/ioport.h>
I would like somebody to revisit this rather cumbersome list of headers here
and try to balance them for not including implied ones (yes, this is more
a guesswork, but feel free to Cc Joshua Crofts and me on the discussion mail
you can start with this matter).
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-12-03 10:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 16:55 [RFC PATCH v8 0/4] iio: position: add Rust driver for ams AS5600 Muchamad Coirul Anwar
2026-12-01 16:55 ` [RFC PATCH v8 1/4] rust: io: add FallibleIoCapable Muchamad Coirul Anwar
2026-12-01 17:40 ` Markus Probst
2026-12-03 10:49 ` Andy Shevchenko
2026-12-03 11:23 ` Miguel Ojeda
2026-12-01 16:55 ` [RFC PATCH v8 2/4] i2c: rust: implement SMBus access via IoBackend Muchamad Coirul Anwar
2026-12-01 17:41 ` Markus Probst
2026-12-01 16:55 ` [RFC PATCH v8 3/4] rust: add minimal IIO subsystem abstractions Muchamad Coirul Anwar
2026-12-03 10:53 ` Andy Shevchenko [this message]
2026-12-01 16:55 ` [RFC PATCH v8 4/4] iio: position: add Rust driver for ams AS5600 Muchamad Coirul Anwar
2026-12-03 11:02 ` 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=axFKLYzOloxb9FOO@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=847807867@qq.com \
--cc=aliceryhl@google.com \
--cc=andi.shyti@kernel.org \
--cc=andy@kernel.org \
--cc=broonie@kernel.org \
--cc=crofts@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dlechner@baylibre.com \
--cc=driver-core@lists.linux.dev \
--cc=igor.korotin@linux.dev \
--cc=jic23@kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=markus.probst@posteo.de \
--cc=muchamadcoirulanwar@gmail.com \
--cc=nuno.sa@analog.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.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