Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iio: adc: ad400x: Simplify period calculation
Instead of assigning the value `ref_clk_period_ps * target` assign `DIV_ROUND_CLOSEST_ULL(1000000000000, freq)` which apart from rounding loss is the same value: ref_clk_period_ps * target = DIV_ROUND_CLOSEST_ULL(1000000000000, st->ref_clk_rate) * DIV_ROUND_CLOSEST_ULL(st->ref_clk_rate, freq) ≅ 1000000000000 / st->ref_clk_rate * st->ref_clk_rate / freq = 1000000000000 / freq With freq = 1800000 and st->ref_clk_rate = 166666665 (which I think are reasonable assumptions) the exact result is 555555.5555555555. The previous calculation yielded 558000, while now it gives 555556. Signed-off-by: Uwe Kleine-König <[email protected]>
- Loading branch information