From: Nikhil Gautam <nikhilgtr@gmail.com>
To: David Lechner <dlechner@baylibre.com>
Cc: linux-iio@vger.kernel.org, jic23@kernel.org
Subject: Re: [PATCH v5 3/3] iio: dac: mcp4821: add configurable gain support
Date: Tue, 14 Apr 2026 22:14:05 +0530 [thread overview]
Message-ID: <ad5u1Z4pgkjN36sJ@nik> (raw)
In-Reply-To: <dd2c2d45-ea48-4024-8d35-c3f482515fd7@baylibre.com>
On Tue, Apr 14, 2026 at 08:57:35AM -0500, David Lechner wrote:
> On 4/14/26 4:22 AM, Nikhil Gautam wrote:
>
> > + *val = div_s64_rem(tmp, 1000000LL, µ);
> > + *val2 = micro;
>
> Technically, IIO_VAL_FRACTIONAL_LOG2 can print up to 9 digits after
> the decimal, so this would be safer to do nano instead of micro.
>
> For that, we need to also implement a write_raw_get_fmt() callback.
>
Thanks for the suggestion.
Currently the driver uses IIO_VAL_FRACTIONAL_LOG2 for the scale
attribute this format is sufficient for all supported chips
(8, 10 and 12-bit), the resulting scale values
are exact and can be represented without loss of precision.
The write path validates the scale values based on exact matches of the
expected values, so additional precision (e.g. nano) is not required.
Using INT_PLUS_NANO would also require changing the existing format and
implementing write_raw_get_fmt(), which does not seem necessary here.
So keeping IIO_VAL_FRACTIONAL_LOG2 for both read and write paths.
prev parent reply other threads:[~2026-04-14 16:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-14 9:22 [PATCH v5 0/3] iio: dac: mcp4821: add configurable gain support Nikhil Gautam
2026-04-14 9:22 ` [PATCH v5 1/3] iio: dac: mcp4821: fix spelling mistake in enum name Nikhil Gautam
2026-04-14 9:22 ` [PATCH v5 2/3] iio: dac: mcp4821: move state initialization outside switch Nikhil Gautam
2026-04-14 13:33 ` David Lechner
2026-04-14 9:22 ` [PATCH v5 3/3] iio: dac: mcp4821: add configurable gain support Nikhil Gautam
2026-04-14 13:57 ` David Lechner
2026-04-14 16:44 ` Nikhil Gautam [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=ad5u1Z4pgkjN36sJ@nik \
--to=nikhilgtr@gmail.com \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@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