diff options
| author | Taniya Das <taniya.das@oss.qualcomm.com> | 2026-01-05 16:09:50 +0530 |
|---|---|---|
| committer | Bjorn Andersson <andersson@kernel.org> | 2026-01-05 09:08:13 -0600 |
| commit | d6205a1878dd4cc9664c4b4829b68a29c0426efc (patch) | |
| tree | 8acb4455a42d3674c3b5117dae7a43de5b219958 /include/linux/i2c/git@git.tavy.me:linux.git | |
| parent | 8c4415fd17cd5979c31a4bf303acc702e9726033 (diff) | |
clk: qcom: rcg2: compute 2d using duty fraction directly
The duty-cycle calculation in clk_rcg2_set_duty_cycle() currently
derives an intermediate percentage `duty_per = (num * 100) / den` and
then computes:
d = DIV_ROUND_CLOSEST(n * duty_per * 2, 100);
This introduces integer truncation at the percentage step (division by
`den`) and a redundant scaling by 100, which can reduce precision for
large `den` and skew the final rounding.
Compute `2d` directly from the duty fraction to preserve precision and
avoid the unnecessary scaling:
d = DIV_ROUND_CLOSEST(n * duty->num * 2, duty->den);
This keeps the intended formula `d ≈ n * 2 * (num/den)` while performing
a single, final rounded division, improving accuracy especially for small
duty cycles or large denominators. It also removes the unused `duty_per`
variable, simplifying the code.
There is no functional changes beyond improved numerical accuracy.
Fixes: 7f891faf596ed ("clk: qcom: clk-rcg2: Add support for duty-cycle for RCG")
Signed-off-by: Taniya Das <taniya.das@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260105-duty_cycle_precision-v2-1-d1d466a6330a@oss.qualcomm.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Diffstat (limited to 'include/linux/i2c/git@git.tavy.me:linux.git')
0 files changed, 0 insertions, 0 deletions
