1
0
mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2026-01-12 09:32:12 +00:00
Hans de Goede cec1aec9c4 iio: consumers: Add an iio_multiply_value() helper function
The channel-scale handling in iio_convert_raw_to_processed() in essence
does the following:

processed  = raw * caller-provided-scale * channel-scale

Which can also be written as:

multiplier = raw * caller-provided-scale
iio-value  = channel-scale
processed  = multiplier * iio-value

Where iio-value is a set of IIO_VAL_* type + val + val2 integers, being
able to handle multiplication of iio-values like this is something
which is useful to have in general and, as previous bugfixes to
iio_convert_raw_to_processed() have shown, also tricky to implement.

Split the iio-value multiplication code from iio_convert_raw_to_processed()
out into a new iio_multiply_value() helper. This serves multiple purposes:

1. Having this split out allows writing a KUnit test for this.
2. Having this split out allows re-use to get better precision
   when scaling values in iio_read_channel_processed_scale().

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Hans de Goede <hansg@kernel.org>
Link: https://patch.msgid.link/20250831104825.15097-4-hansg@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-09-10 19:47:04 +01:00
..
2025-07-29 11:42:31 -07:00
2025-07-31 11:50:25 -07:00
2025-07-23 01:38:56 -04:00
2025-07-31 13:43:02 -07:00
2025-07-31 16:29:46 -07:00
2025-08-02 12:07:09 -07:00
2025-07-31 13:43:02 -07:00
2025-08-09 07:20:44 +03:00
2025-07-31 13:16:09 -07:00
2025-07-29 20:21:54 -07:00
2025-07-21 18:18:51 +01:00
2025-07-31 11:28:03 -04:00
2025-07-28 16:43:54 -07:00
2025-07-31 18:23:53 -07:00
2025-08-01 15:47:06 -07:00
2025-07-29 17:42:52 -07:00
2025-08-01 13:59:07 -07:00
2025-07-31 16:52:32 -07:00
2025-07-19 18:59:57 -07:00
2025-07-29 12:15:39 -07:00
2025-08-09 18:10:01 +03:00
2025-07-22 15:57:02 +00:00
2025-07-30 09:58:50 -07:00
2025-08-04 16:27:21 -07:00
2025-07-16 14:28:21 +02:00
2025-07-19 18:59:51 -07:00
2025-07-24 19:12:32 -07:00
2025-07-28 16:30:12 -07:00
2025-08-02 12:06:10 -07:00
2025-07-31 12:43:08 -07:00
2025-07-30 17:14:01 -07:00
2025-07-17 06:01:16 -06:00
2025-07-13 16:38:24 -07:00
2025-07-09 22:41:56 -07:00
2025-08-06 07:32:52 +03:00
2025-08-06 07:32:52 +03:00
2025-07-30 17:14:01 -07:00
2025-08-01 15:47:06 -07:00
2025-07-28 11:22:56 -07:00
2025-07-14 15:20:02 -07:00
2025-07-14 15:20:02 -07:00
2025-07-08 19:11:57 -04:00
2025-07-30 16:23:12 -07:00
2025-07-31 16:11:43 -05:00
2025-07-09 19:32:30 -07:00
2025-07-29 11:42:31 -07:00
2025-07-22 18:07:11 +02:00
2025-07-10 09:39:18 +02:00
2025-08-03 15:03:04 -07:00
2025-08-01 09:46:24 -07:00
2025-07-28 18:20:32 -07:00
2025-07-29 13:00:20 -07:00
2025-08-04 10:54:36 -07:00
2025-07-19 10:17:56 +05:30
2025-07-30 19:26:49 -07:00
2025-07-23 11:56:02 +02:00
2025-07-21 17:48:32 -07:00
Hi,
2025-07-28 18:18:16 -07:00
2025-08-01 14:17:48 -07:00
2025-07-17 11:26:56 +02:00
2025-08-02 12:01:37 -07:00