From: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <dlechner@baylibre.com>
Cc: Wadim Mueller <wafgo01@gmail.com>,
krzk+dt@kernel.org, robh@kernel.org, conor+dt@kernel.org,
nuno.sa@analog.com, andy@kernel.org, maxwell@maxwelld.cc,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, marcelo.schmitt1@gmail.com,
455.rodrigo.alencar@gmail.com,
Rodrigo Alencar <rodrigo.alencar@analog.com>
Subject: Re: [PATCH v6 3/4] iio: core: add IIO_VAL_DECIMAL64_FEMTO format type
Date: Sun, 2 Aug 2026 18:20:07 +0100 [thread overview]
Message-ID: <20260802182007.7ebc8847@jic23-huawei> (raw)
In-Reply-To: <cfb955b4-0843-48aa-b201-fa60aceb03f9@baylibre.com>
On Sun, 2 Aug 2026 11:01:28 -0500
David Lechner <dlechner@baylibre.com> wrote:
> On 7/28/26 4:49 PM, Wadim Mueller wrote:
> > Extend the IIO_VAL_DECIMAL64_* family with a femto-scaled variant
> > (scale 15), following the existing MILLI/MICRO/NANO/PICO pattern. Both
> > the read formatting path in __iio_format_value() and the write parsing
> > path in iio_write_channel_info() (via kstrtodec64()) already derive
> > their scale from "type - IIO_VAL_DECIMAL64_BASE", so the new type only
> > needs to be added to the respective switch cases.
> >
> > This is needed by drivers reporting very small SI quantities where the
> > existing pico scale loses precision. For example the Sensirion SLF3S
> > liquid flow sensor reports its volume-flow scale in m^3/s, where the
> > SLF3S-0600F scale is ~1.667e-12 m^3/s: at pico scale only a single
> > significant digit survives, whereas femto scale preserves the full
> > sensor resolution.
> >
> > Signed-off-by: Wadim Mueller <wafgo01@gmail.com>
> > Reviewed-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
> > ---
> > drivers/iio/industrialio-core.c | 2 ++
> > include/linux/iio/types.h | 1 +
> > 2 files changed, 3 insertions(+)
> >
> > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> > index 37cf2817b3d0..767a7794624a 100644
> > --- a/drivers/iio/industrialio-core.c
> > +++ b/drivers/iio/industrialio-core.c
> > @@ -715,6 +715,7 @@ static ssize_t __iio_format_value(char *buf, size_t offset, unsigned int type,
> > case IIO_VAL_DECIMAL64_MICRO:
> > case IIO_VAL_DECIMAL64_NANO:
> > case IIO_VAL_DECIMAL64_PICO:
> > + case IIO_VAL_DECIMAL64_FEMTO:
> > {
> > int scale = type - IIO_VAL_DECIMAL64_BASE;
> > s64 frac;
> > @@ -1032,6 +1033,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
> > case IIO_VAL_DECIMAL64_MICRO:
> > case IIO_VAL_DECIMAL64_NANO:
> > case IIO_VAL_DECIMAL64_PICO:
> > + case IIO_VAL_DECIMAL64_FEMTO:
> > dec_scale = type - IIO_VAL_DECIMAL64_BASE;
> > fallthrough;
> > case IIO_VAL_INT_64:
> > diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
> > index 924ac9dc6893..d8944c9e5e90 100644
> > --- a/include/linux/iio/types.h
> > +++ b/include/linux/iio/types.h
> > @@ -42,6 +42,7 @@ enum iio_event_info {
> > #define IIO_VAL_DECIMAL64_MICRO (IIO_VAL_DECIMAL64_BASE + 6)
> > #define IIO_VAL_DECIMAL64_NANO (IIO_VAL_DECIMAL64_BASE + 9)
> > #define IIO_VAL_DECIMAL64_PICO (IIO_VAL_DECIMAL64_BASE + 12)
> > +#define IIO_VAL_DECIMAL64_FEMTO (IIO_VAL_DECIMAL64_BASE + 15)
> >
> > static inline s64 iio_val_s64_compose(s32 val0, s32 val1)
> > {
>
> Would be nice to add this to drivers/iio/test/iio-test-format.c too.
Good point. I somehow keep forgetting we now have tests!
That can be a follow up patch
Jonathan
>
next prev parent reply other threads:[~2026-08-02 17:20 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 21:49 [PATCH v6 0/4] iio: flow: Sensirion SLF3S liquid flow sensor Wadim Mueller
2026-07-28 21:49 ` [PATCH v6 1/4] iio: types: add IIO_VOLUMEFLOW channel type Wadim Mueller
2026-08-03 9:32 ` Joshua Crofts
2026-07-28 21:49 ` [PATCH v6 2/4] dt-bindings: iio: flow: add Sensirion SLF3S liquid flow sensor Wadim Mueller
2026-07-28 21:55 ` sashiko-bot
2026-08-01 23:46 ` Jonathan Cameron
2026-08-04 6:43 ` Krzysztof Kozlowski
2026-07-28 21:49 ` [PATCH v6 3/4] iio: core: add IIO_VAL_DECIMAL64_FEMTO format type Wadim Mueller
2026-08-02 16:01 ` David Lechner
2026-08-02 17:20 ` Jonathan Cameron [this message]
2026-07-28 21:49 ` [PATCH v6 4/4] iio: flow: add Sensirion SLF3S liquid flow sensor driver Wadim Mueller
2026-07-29 12:21 ` Uwe Kleine-König
2026-08-02 0:04 ` Jonathan Cameron
2026-08-02 16:07 ` David Lechner
2026-08-02 17:19 ` Jonathan Cameron
2026-08-01 23:50 ` [PATCH v6 0/4] iio: flow: Sensirion SLF3S liquid flow sensor Jonathan Cameron
2026-08-04 23:04 ` Jonathan Cameron
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=20260802182007.7ebc8847@jic23-huawei \
--to=jic23@kernel.org \
--cc=455.rodrigo.alencar@gmail.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt1@gmail.com \
--cc=maxwell@maxwelld.cc \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=rodrigo.alencar@analog.com \
--cc=wafgo01@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.