Re: [PATCH RESEND v12 2/3] i2c: ma35d1: Add Nuvoton MA35D1 I2C driver support

From: Andi Shyti

Date: Wed Dec 02 2026 - 10:09:38 EST


Hi Zi-Yu,

...

> + if (!device_property_read_u32(dev, "clock-frequency", &val)) {
> + if (val != 0 && val <= MEGA)
> + busfreq = val;
> + }
> + /* Calculate divider based on the current peripheral clock rate */
> + clkdiv = DIV_ROUND_CLOSEST(clk_get_rate(i2c->clk), busfreq * 4) - 1;

I would use DIV_ROUND_UP() here: rounding the divisor to the
nearest integer can make SCL exceed the requested bus frequency.

Andi

> + if (clkdiv < 0 || clkdiv > 0x3ff)
> + return dev_err_probe(dev, -EINVAL, "invalid clkdiv value: %d\n",
> + clkdiv);