mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
iio: test: test gain-time-scale helpers
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@gmail.com> Link: https://lore.kernel.org/r/0f7505b43f91394dc3bb636369489c897b7e01a7.1705328293.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
committed by
Jonathan Cameron
parent
44b9038345
commit
cf996f0396
@@ -4,6 +4,20 @@
|
||||
#
|
||||
|
||||
# Keep in alphabetical order
|
||||
config IIO_GTS_KUNIT_TEST
|
||||
tristate "Test IIO formatting functions" if !KUNIT_ALL_TESTS
|
||||
depends on KUNIT
|
||||
select IIO_GTS_HELPER
|
||||
select TEST_KUNIT_DEVICE_HELPERS
|
||||
default KUNIT_ALL_TESTS
|
||||
help
|
||||
build unit tests for the IIO light sensor gain-time-scale helpers.
|
||||
|
||||
For more information on KUnit and unit tests in general, please refer
|
||||
to the KUnit documentation in Documentation/dev-tools/kunit/.
|
||||
|
||||
If unsure, say N. Keep in alphabetical order
|
||||
|
||||
config IIO_RESCALE_KUNIT_TEST
|
||||
tristate "Test IIO rescale conversion functions" if !KUNIT_ALL_TESTS
|
||||
depends on KUNIT && IIO_RESCALE
|
||||
|
||||
@@ -6,4 +6,5 @@
|
||||
# Keep in alphabetical order
|
||||
obj-$(CONFIG_IIO_RESCALE_KUNIT_TEST) += iio-test-rescale.o
|
||||
obj-$(CONFIG_IIO_FORMAT_KUNIT_TEST) += iio-test-format.o
|
||||
obj-$(CONFIG_IIO_GTS_KUNIT_TEST) += iio-test-gts.o
|
||||
CFLAGS_iio-test-format.o += $(DISABLE_STRUCTLEAK_PLUGIN)
|
||||
|
||||
513
drivers/iio/test/iio-test-gts.c
Normal file
513
drivers/iio/test/iio-test-gts.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user