Re: [PATCH v5 5/8] iio: test: test gain-time-scale helpers

From: Matti Vaittinen
Date: Fri Mar 24 2023 - 02:29:52 EST


On 3/22/23 11:07, Matti Vaittinen wrote:
Some light sensors can adjust both the HW-gain and integration time.
There are cases where adjusting the integration time has similar impact
to the scale of the reported values as gain setting has.

IIO users do typically expect to handle scale by a single writable 'scale'
entry. Driver should then adjust the gain/time accordingly.

It however is difficult for a driver to know whether it should change
gain or integration time to meet the requested scale. Usually it is
preferred to have longer integration time which usually improves
accuracy, but there may be use-cases where long measurement times can be
an issue. Thus it can be preferable to allow also changing the
integration time - but mitigate the scale impact by also changing the gain
underneath. Eg, if integration time change doubles the measured values,
the driver can reduce the HW-gain to half.

The theory of the computations of gain-time-scale is simple. However,
some people (undersigned) got that implemented wrong for more than once.
Hence some gain-time-scale helpers were introduced.

Add some simple tests to verify the most hairy functions.

Signed-off-by: Matti Vaittinen <mazziesaccount@xxxxxxxxx>

---
Changes:
v4 => v5:
- remove empty lines from Kconfig
- adapt to drop of the non devm iio_init

I think you may want to skip reviewing this specific patch. After having a chat with Greg, David, and Maxime it seems this will be changed quite a bit for v6.

Most notably, I am planning to drop the generic helpers and struct gts_test. I'll also simplify the signatures of __test_init_iio_gain_scale() and test_init_iio_gain_scale().

Yours,
-- Matti

--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~