Skip to content
Commit 331e049d authored by Jitao Shi's avatar Jitao Shi Committed by Thierry Reding
Browse files

pwm: mtk-disp: Fix overflow in period and duty calculation



Current calculation for period and high_width may have 64-bit overflow.
state->period and rate are u64. rate * state->period will overflow.

clk_div = div_u64(rate * state->period, NSEC_PER_SEC)
period = div64_u64(rate * state->period, div);
high_width = div64_u64(rate * state->duty_cycle, div);

This patch is to resolve it by using mul_u64_u64_div_u64().

Signed-off-by: default avatarJitao Shi <jitao.shi@mediatek.com>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent 888a623d
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment