From: Jonathan Cameron <jic23@kernel.org>
To: Muchamad Coirul Anwar <muchamadcoirulanwar@gmail.com>
Cc: Miguel Ojeda <ojeda@kernel.org>,
Igor Korotin <igor.korotin@linux.dev>,
Danilo Krummrich <dakr@kernel.org>,
David Lechner <dlechner@baylibre.com>,
Alice Ryhl <aliceryhl@google.com>,
Daniel Almeida <daniel.almeida@collabora.com>,
Mark Brown <broonie@kernel.org>,
Andi Shyti <andi.shyti@kernel.org>, 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 v7 0/4] iio: position: add Rust driver for ams AS5600
Date: Sat, 28 Nov 2026 23:58:58 +0000 [thread overview]
Message-ID: <20261128235858.39e8e5f6@jic23-hlaptop> (raw)
In-Reply-To: <20261109155743.83740-1-muchamadcoirulanwar@gmail.com>
On Mon, 9 Nov 2026 22:57:39 +0700
Muchamad Coirul Anwar <muchamadcoirulanwar@gmail.com> wrote:
> This series adds a Rust driver for the ams AS5600 12-bit magnetic rotary
> position sensor. It also adds fallible I/O, SMBus access, and the IIO
> abstractions needed by the driver. The driver exposes raw angle and scale
> through IIO sysfs.
>
> Feedback on the I2C and IIO lifetimes, locking, and device teardown would
> be appreciated.
>
> The Region-based view models byte-addressed registers and is not a
> general model for command-indexed 16-bit registers. The standalone
> word-read helpers accept any SMBus command byte.
>
> The current interface is intentionally limited while a Rust regmap
> abstraction is unavailable. Feedback on whether this is an appropriate
> interim approach, or whether the work should wait for regmap, would be
> appreciated.
Do we have any like timescale on regmap support?
Long term I think things should go that way simply to avoid duplication.
Given the rust bindings we have here are very strongly assuming a register
interface regmap should in most cases probably replaces these.
The irony is that I'd be much happier seeing an i2c only binding if it
was for the many i2c devices that don't present a simple register interface.
Note though that this stuff is effectively internal to the kernel so
I wouldn't mind going forward with I2C register interface now and
then flipping over to regmap and deprecating the I2C register interface
later.
Jonathan
>
> Based on Linux v7.3.
>
> Thanks to Igor Korotin for the device ownership and bound-client lifetime
> rework used in patches 3 and 4:
> https://lore.kernel.org/all/179286358623.55649.5397316745104390556@linux.dev/
>
> Thanks to Shuai Liu for reviewing v6. This version addresses the Clippy
> warnings, replaces the ignored SMBus doctest, and moves repeated unsafe
> SMBus calls into safe helpers:
> https://lore.kernel.org/all/tencent_173B7731E90B9624F9F82613DC3031B70907@qq.com/
>
> ---
>
> Previous versions:
>
> v6: https://lore.kernel.org/linux-iio/20261004130303.65432-1-muchamadcoirulanwar@gmail.com/
>
> Changes since RFC v6:
>
> - Rebase on top of Linux 7.3.0.
> - Make register() return Device<T, Registered>, stored in the driver
> data, so the IIO device is unregistered before its private data is freed.
> - Remove the bound parent parameter from IioDriver::read_raw(); the driver
> now stores its bound I2C client reference directly.
> - Drop the parent lifetime parameter from UnregisteredDevice.
> - Use pin_init::raw_try_init() in Device::build_device().
> - Document sign conventions for IioVal::IntPlusMicro and
> IioVal::IntPlusNano.
> - Add IIO=y and I2C=y dependencies to CONFIG_AS5600.
> - Use typed pointer casts and lossless integer conversion to fix Clippy
> diagnostics reported by Shuai Liu.
> - Replace the ignored AS5600 doctest with a generic no_run example.
> - Move raw SMBus FFI calls and errno conversion into safe bound-client
> methods, as suggested by Shuai Liu.
>
> Testing:
>
> Clippy and debug builds completed for ARM with Rust enabled, I2C built
> in, and AS5600 built as a module.
>
> Runtime testing was performed on a BeagleBone Black with an AS5600 on
> i2c-2 at 0x36. Raw angle and scale reads worked with the magnet detected,
> and reads returned ENODATA when the magnet-detected bit was clear.
>
> I2C errors were propagated when the bus was disconnected, and reads
> recovered after reconnection. Concurrent reads were tested with 10
> readers, including during 20 unbind/rebind cycles.
>
> Lifecycle testing covered 50 unbind/rebind cycles, 50 module load/unload
> cycles, module removal during active reads, module removal with an open
> sysfs file descriptor, and module removal while the I2C bus was in an
> error state.
>
> KFENCE, UBSAN, lockdep, and kmemleak reported no issues. KASAN was not
> enabled because 32-bit ARM selects HAVE_RUST only when KASAN is disabled.
>
> Muchamad Coirul Anwar (4):
> rust: io: add FallibleIoCapable
> i2c: rust: implement SMBus access via IoBackend
> rust: add minimal IIO subsystem abstractions
> iio: position: add Rust driver for ams AS5600
>
> drivers/iio/position/Kconfig | 11 +
> drivers/iio/position/Makefile | 1 +
> drivers/iio/position/as5600.rs | 186 +++++++++++++
> include/linux/iio/iio.h | 6 +-
> rust/bindings/bindings_helper.h | 2 +
> rust/kernel/bits.rs | 29 ++
> rust/kernel/i2c.rs | 235 ++++++++++++++++
> rust/kernel/iio.rs | 463 ++++++++++++++++++++++++++++++++
> rust/kernel/io.rs | 62 +++--
> rust/kernel/lib.rs | 2 +
> 10 files changed, 978 insertions(+), 19 deletions(-)
> create mode 100644 drivers/iio/position/as5600.rs
> create mode 100644 rust/kernel/iio.rs
>
next prev parent reply other threads:[~2026-11-28 23:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 15:57 Muchamad Coirul Anwar
2026-11-09 15:57 ` [RFC PATCH v7 1/4] rust: io: add FallibleIoCapable Muchamad Coirul Anwar
2026-11-09 15:57 ` [RFC PATCH v7 2/4] i2c: rust: implement SMBus access via IoBackend Muchamad Coirul Anwar
2026-11-22 13:34 ` Markus Probst
2026-11-25 2:32 ` Muchamad Coirul Anwar
2026-11-22 21:22 ` Igor Korotin
2026-11-09 15:57 ` [RFC PATCH v7 3/4] rust: add minimal IIO subsystem abstractions Muchamad Coirul Anwar
2026-11-22 21:26 ` Igor Korotin
2026-11-25 2:24 ` Muchamad Coirul Anwar
2026-11-09 15:57 ` [RFC PATCH v7 4/4] iio: position: add Rust driver for ams AS5600 Muchamad Coirul Anwar
2026-11-28 23:58 ` Jonathan Cameron [this message]
2026-11-29 15:40 ` [RFC PATCH v7 0/4] " Muchamad Coirul Anwar
2026-11-30 11:42 ` Joshua Crofts
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=20261128235858.39e8e5f6@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=847807867@qq.com \
--cc=aliceryhl@google.com \
--cc=andi.shyti@kernel.org \
--cc=broonie@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=linux-i2c@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=muchamadcoirulanwar@gmail.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
all inboxes | Powered by JetHome®