clk: renesas: rcar-gen3: Improve arithmetic divisions

- Use div64_ul() instead of div_u64() if the divisor is unsigned long,
    to avoid truncation to 32-bit on 64-bit platforms,
  - Use div_u64() for 64-by-32 divisions.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/20190830134515.11925-3-geert+renesas@glider.be
This commit is contained in:
Geert Uytterhoeven 2019-08-30 15:45:09 +02:00
parent 3e8c1d4cce
commit b5dea62d34
1 changed files with 2 additions and 2 deletions

View File

@ -122,10 +122,10 @@ static long cpg_z_clk_round_rate(struct clk_hw *hw, unsigned long rate,
unsigned int mult;
prate = *parent_rate / zclk->fixed_div;
mult = div_u64(rate * 32ULL, prate);
mult = div64_ul(rate * 32ULL, prate);
mult = clamp(mult, 1U, 32U);
return (u64)prate * mult / 32;
return div_u64((u64)prate * mult, 32);
}
static int cpg_z_clk_set_rate(struct clk_hw *hw, unsigned long rate,