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

zychen zychennvt at gmail.com
Wed Dec 2 16:48:48 PST 2026



Andi Shyti 於 2026/12/2 下午 11:09 寫道:
> 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
> 
Agreed. DIV_ROUND_UP() is more appropriate here.

Thanks,
Zi-Yu

>> +	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