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

Andi Shyti andi.shyti at kernel.org
Wed Dec 2 07:09:25 PST 2026


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);



More information about the linux-arm-kernel mailing list