mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 23:09:29 +02:00
iio: core: add IIO_VAL_DECIMAL64_FEMTO format type
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> Signed-off-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
This commit is contained in:
committed by
Jonathan Cameron
parent
7462dce236
commit
1647a1b673
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user