Skip to content

Commit 3c417c9

Browse files
Wolfram Sangwsakernel
authored andcommitted
i2c: rcar: remove open coded DIV_ROUND_CLOSEST
It improves readability if we use the available helper. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent 47280af commit 3c417c9

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

drivers/i2c/busses/i2c-rcar.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,15 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv)
291291
ick = rate / (cdf + 1);
292292

293293
/*
294-
* it is impossible to calculate large scale
295-
* number on u32. separate it
294+
* It is impossible to calculate a large scale number on u32. Separate it.
296295
*
297296
* F[(ticf + tr + intd) * ick] with sum = (ticf + tr + intd)
298297
* = F[sum * ick / 1000000000]
299298
* = F[(ick / 1000000) * sum / 1000]
300299
*/
301300
sum = t.scl_fall_ns + t.scl_rise_ns + t.scl_int_delay_ns;
302-
round = (ick + 500000) / 1000000 * sum;
303-
round = (round + 500) / 1000;
301+
round = DIV_ROUND_CLOSEST(ick, 1000000);
302+
round = DIV_ROUND_CLOSEST(round * sum, 1000);
304303

305304
/*
306305
* SCL = ick / (20 + 8 * SCGD + F[(ticf + tr + intd) * ick])

0 commit comments

Comments
 (0)