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 4/4] iio: position: add Rust driver for ams AS5600
Date: Thu, 3 Dec 2026 13:02:38 +0200 [thread overview]
Message-ID: <axFMTvsIz1CbQJuF@ashevche-desk.local> (raw)
In-Reply-To: <20261201165508.39336-5-muchamadcoirulanwar@gmail.com>
On Tue, Dec 01, 2026 at 11:55:08PM +0700, Muchamad Coirul Anwar wrote:
> Add a Rust driver for the ams AS5600 12-bit magnetic rotary position
> sensor.
>
> Expose the raw angle and scale through the IIO sysfs interface in direct
> mode. Read the status register before each angle sample and return
> ENODATA when the magnet-detected bit is clear. Serialize the status and
> angle transaction sequence with a mutex and propagate I2C transport
> errors directly to userspace.
>
> Capture a bound I2C client reference during probe and store it in the
> IIO private data. The registered IIO device carries the same bound
> lifetime, keeping the client valid throughout read_raw callbacks.
>
> The AS5600 stores the raw angle with the high byte at register 0x0c.
> Use the byte-swapped SMBus word helper and mask the result to 12 bits.
>
> Add usize bit and mask helpers for constructing the IIO channel
> information mask.
> Suggested-by: Shuai Liu <847807867@qq.com>
> Link: https://lore.kernel.org/all/tencent_173B7731E90B9624F9F82613DC3031B70907@qq.com/
> Link: https://lore.kernel.org/all/179286358623.55649.5397316745104390556@linux.dev/
Again, do not put unreferred Link tags.
...
> + tristate "ams AS5600 magnetic rotary position sensor"
Make this line to be the same or very similar to the top comment in the file.
(or other way around)
> +//! Driver for ams AS5600 12-bit magnetic rotary position sensor.
> + description: "I2C Driver for ams OSRAM AS5600 Magnetic Rotary Position Sensor",
Same for these.
...
> + depends on IIO=y && I2C=y && RUST
Huh?!
...
> + help
> + Support for the ams OSRAM AS5600 12-bit magnetic rotary
> + position sensor. Provides in_angl_raw (0-4095) and
> + in_angl_scale (radians per LSB) via sysfs.
Unneeded details, what we need is something like top level parameters (12-bit,
for example, that's already mentioned). Sysfs and related Linux kernel pieces
are usually not being interested to the users here.
> + To compile this driver as a module, choose M here: the
> + module will be called as5600.
...
> + // Scale factor: radians per LSB = 2*pi / 4096 ~= 0.001533981
> + IioChanInfo::Scale => Ok(IioVal::IntPlusNano(0, 1533981)),
Please try to provide calculations based on the proper constants,
use PI constant (for now open coded) with desired precision and
shift it right by log2(2048). I believe you want 9-sign (yes,
9 in the fraction part) PI == 3141592654 (or ...53 if mentioned
in the datasheet).
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-12-03 11:02 UTC|newest]
Thread overview: 13+ 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-03 11:38 ` Andy Shevchenko
2026-12-03 12:01 ` 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
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 [this message]
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=axFMTvsIz1CbQJuF@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