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.
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/gcd.hlinux/overflow.hlinux/iio/afe/rescale.hlinux/iio/iio.hkunit/test.h
Detected Declarations
struct rescale_tc_datafunction case_to_descfunction iio_str_to_nanofunction iio_test_relative_error_ppmfunction iio_rescale_test_scalefunction iio_rescale_test_offset
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
- Immediate include surface: `linux/gcd.h`, `linux/overflow.h`, `linux/iio/afe/rescale.h`, `linux/iio/iio.h`, `kunit/test.h`.
- Detected declarations: `struct rescale_tc_data`, `function case_to_desc`, `function iio_str_to_nano`, `function iio_test_relative_error_ppm`, `function iio_rescale_test_scale`, `function iio_rescale_test_offset`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.