mirror-linux/include/linux/iio
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
..
accel
adc iio: adc: ad_sigma_delta: add SPI offload support 2025-07-13 15:36:25 +01:00
afe
common iio: cros_ec_sensors: add cros_ec_activity driver 2025-06-26 19:32:51 +01:00
dac
frequency
gyro
imu iio: imu: adis: Add DIAG_STAT register 2025-02-22 12:23:49 +00:00
timer iio: trigger: stm32-lptimer: add support for stm32mp25 2025-04-22 19:09:54 +01:00
adc-helpers.h iio: adc: add helpers for parsing ADC nodes 2025-04-22 19:09:52 +01:00
backend.h iio: backend: update iio_backend_oversampling_ratio_set 2025-06-26 19:32:51 +01:00
buffer-dma.h
buffer-dmaengine.h
buffer.h iio: introduced iio_push_to_buffers_with_ts() that takes a data_total_len argument. 2025-05-21 14:20:25 +01:00
buffer_impl.h
configfs.h
consumer.h iio: consumers: Add an iio_multiply_value() helper function 2025-09-10 19:47:04 +01:00
driver.h
events.h
hw-consumer.h
iio-gts-helper.h
iio-opaque.h
iio.h iio: core: switch info_mask fields to unsigned long to match find_bit helpers 2025-08-25 11:07:17 +01:00
kfifo_buf.h
machine.h
sw_device.h
sw_trigger.h
sysfs.h
trigger.h
trigger_consumer.h
triggered_buffer.h
triggered_event.h
types.h iio: core: add ADC delay calibration definition 2025-06-09 07:45:37 +01:00