Re: [RFC PATCH v5 3/3] iio: position: add Rust driver for ams AS5600

Jonathan Cameron <[email protected]>
Newsgroups org.kernel.vger.rust-for-linux,org.kernel.vger.linux-i2c,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <20260824011749.62322d99@jic23-huawei>
On Sat, 22 Aug 2026 14:26:58 +0800
Muchamad Coirul Anwar <[email protected]> wrote:

> Add a Rust driver for the ams AS5600 12-bit magnetic rotary position
> sensor. The driver exposes in_angl_raw and in_angl_scale via the IIO
> sysfs interface.
> 
> Features:
> - ARef<I2cClient<Bound>> for safe refcounted I2C client access
> - Mutex-serialized status + angle read sequence
> - Static channel spec (module-level const)
> - No magnet validation at probe (deferred to read_raw per IIO convention)
> - Error propagation via ? operator (no recovery state machine)
> - Type-safe IioChanInfo enum dispatch in read_raw
> 
> The AS5600 stores the 12-bit raw angle big-endian across registers
> 0x0C-0x0D. smbus_read_word_swapped() handles the byte swap: SMBus
> always transmits the low byte first (little-endian wire), so an
> unconditional byte swap recovers the correct value regardless of CPU
> endianness. The long-term solution is regmap-rs where endianness is
> configured once at the transport level.
> 
> This driver uses INDIO_DIRECT_MODE without buffer or trigger support.

I'd only talk about what you do support.  There are always many things
that aren't in an initial driver so listing that bit doesn't provide much
value.

> All userspace access is through sysfs attributes, which ensures safe
> cleanup via kernfs_drain() synchronization in the IIO abstraction's
> PinnedDrop. See the module-level doc comment for details.


> 
> Tested on BeagleBone Black (AM335x) with AS5600 on i2c-2 (0x36).

Generally put things like testing info in the cover letter or below
the ---

> 
> Signed-off-by: Muchamad Coirul Anwar <[email protected]>


The code itself looks fine to me - but as with earlier I'm looking
for rust expert review.

Thanks

Jonathan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.