drivers/iio/test/iio-test-rescale.c

Source file repositories/reference/linux-study-clean/drivers/iio/test/iio-test-rescale.c

File Facts

System
Linux kernel
Corpus path
drivers/iio/test/iio-test-rescale.c
Extension
.c
Size
18014 bytes
Lines
720
Domain
Driver Families
Bucket
drivers/iio
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct rescale_tc_data {
	const char *name;

	const s32 numerator;
	const s32 denominator;
	const s32 offset;

	const int schan_val;
	const int schan_val2;
	const int schan_off;
	const int schan_scale_type;

	const char *expected;
	const char *expected_off;
};

static const struct rescale_tc_data scale_cases[] = {
	/*
	 * Typical use cases
	 */
	{
		.name = "typical IIO_VAL_INT, positive",
		.numerator = 1000000,
		.denominator = 8060,
		.schan_scale_type = IIO_VAL_INT,
		.schan_val = 42,
		.expected = "5210.918114143",
	},
	{
		.name = "typical IIO_VAL_INT, negative",
		.numerator = -1000000,
		.denominator = 8060,
		.schan_scale_type = IIO_VAL_INT,
		.schan_val = 42,
		.expected = "-5210.918114143",
	},
	{
		.name = "typical IIO_VAL_FRACTIONAL, positive",
		.numerator = 1000000,
		.denominator = 8060,
		.schan_scale_type = IIO_VAL_FRACTIONAL,
		.schan_val = 42,
		.schan_val2 = 20,
		.expected = "260.545905707",
	},
	{
		.name = "typical IIO_VAL_FRACTIONAL, negative",
		.numerator = -1000000,
		.denominator = 8060,
		.schan_scale_type = IIO_VAL_FRACTIONAL,
		.schan_val = 42,
		.schan_val2 = 20,
		.expected = "-260.545905707",
	},
	{
		.name = "typical IIO_VAL_FRACTIONAL_LOG2, positive",
		.numerator = 42,
		.denominator = 53,
		.schan_scale_type = IIO_VAL_FRACTIONAL_LOG2,
		.schan_val = 4096,
		.schan_val2 = 16,
		.expected = "0.049528301",
	},
	{
		.name = "typical IIO_VAL_FRACTIONAL_LOG2, negative",
		.numerator = -42,
		.denominator = 53,
		.schan_scale_type = IIO_VAL_FRACTIONAL_LOG2,
		.schan_val = 4096,
		.schan_val2 = 16,
		.expected = "-0.049528301",
	},
	{
		.name = "typical IIO_VAL_INT_PLUS_NANO, positive",
		.numerator = 1000000,
		.denominator = 8060,
		.schan_scale_type = IIO_VAL_INT_PLUS_NANO,
		.schan_val = 10,
		.schan_val2 = 123456,
		.expected = "1240.710106203",
	},
	{
		.name = "typical IIO_VAL_INT_PLUS_NANO, negative",
		.numerator = -1000000,
		.denominator = 8060,
		.schan_scale_type = IIO_VAL_INT_PLUS_NANO,
		.schan_val = 10,
		.schan_val2 = 123456,
		.expected = "-1240.710106203",
	},

Annotation

Implementation Notes