[PATCH v5 3/5] iio: core: add iio_fill_val_int_64() helper

From: Ariana Lazar

Date: Tue Nov 03 2026 - 09:44:32 EST


Add iio_fill_val_int_64() to populate the val and val2 output parameters
with the lower and upper 32 bits of a 64-bit value, as used for
IIO_VAL_INT_64. The helper wraps lower_32_bits() and upper_32_bits() in
order to split the value with a single call.

The pac1711 driver will be the first user of this function.

Signed-off-by: Ariana Lazar <ariana.lazar@xxxxxxxxxxxxx>
---
include/linux/iio/iio.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 711c00f67371356c913ef0dbf2325e3f4d35266d..d8fd300a125d676bf60e0b59f84a69f99ff23c89 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -1099,6 +1099,21 @@ ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals);
int iio_str_to_fixpoint(const char *str, int fract_mult, int *integer,
int *fract);

+/**
+ * iio_fill_val_int_64() - Fill the value fields used to represent a 64-bit integer
+ * @value: The 64-bit value to be represented
+ * @val: the lower 32 bits of @value
+ * @val2: the upper 32 bits of @value
+ *
+ * Populate @val and @val2 with the lower and upper halves of @value, as
+ * expected by IIO_VAL_INT_64.
+ */
+static inline void iio_fill_val_int_64(s64 value, int *val, int *val2)
+{
+ *val = lower_32_bits(value);
+ *val2 = upper_32_bits(value);
+}
+
/**
* IIO_DEGREE_TO_RAD() - Convert degree to rad
* @deg: A value in degree

--
2.43.0