Re: [PATCH 5/5] i2c: riic: avoid potential division by zero

From: Wolfram Sang
Date: Thu Sep 07 2023 - 12:24:42 EST



> > - total_ticks = DIV_ROUND_UP(rate, t->bus_freq_hz);
> > + total_ticks = DIV_ROUND_UP(rate, t->bus_freq_hz ?: 1);
>
> Not sure clamping function min_t/min(t->bus_freq_hz, 1)
> Or ternary condition is good in this case for avoiding potential division by 0?

Both work. I chose the ternary because I believe it involves less
computation and a tad tighter syntax.

Attachment: signature.asc
Description: PGP signature