Skip to content

Commit 7890fce

Browse files
Wolfram Sangwsakernel
authored andcommitted
i2c: riic: avoid potential division by zero
Value comes from DT, so it could be 0. Unlikely, but could be. 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 3c417c9 commit 7890fce

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/i2c/busses/i2c-riic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
313313
* frequency with only 62 clock ticks max (31 high, 31 low).
314314
* Aim for a duty of 60% LOW, 40% HIGH.
315315
*/
316-
total_ticks = DIV_ROUND_UP(rate, t->bus_freq_hz);
316+
total_ticks = DIV_ROUND_UP(rate, t->bus_freq_hz ?: 1);
317317

318318
for (cks = 0; cks < 7; cks++) {
319319
/*

0 commit comments

Comments
 (0)