[PATCH v5 1/5] i2c: core: add callback to change bus frequency
Andy Shevchenko
andriy.shevchenko at intel.com
Fri Feb 13 03:14:04 PST 2026
On Fri, Feb 13, 2026 at 12:06:50PM +0100, Marcus Folkesson wrote:
> All devices on the same I2C bus share the same clock line and the bus
> frequency has therefor be chosen so that all attached devices are able
> to tolarate that clock rate. IOW, the bus speed must be set for the
> slowest attached device.
>
> With I2C multiplexers/switches on the other hand, it would be possible
> to have different "domains" that runs with different speeds.
>
> Prepare for such a feature by provide an optional callback function to
> change bus frequency.
...
> struct i2c_adapter {
> + int clock_hz;
Why signed? Even inconsistent with the parameter of the below.
> + int (*set_clk_freq)(struct i2c_adapter *adap, u32 clock_hz); /* Optional */
It's already a huge struct, can we make this compile-time chosen
(when I²C muxes are not required, for example)?
...
> +static inline int
> +i2c_adapter_set_clk_freq(struct i2c_adapter *adapter, u32 clock_hz)
> +{
> + int ret = -EOPNOTSUPP;
> +
> + if (adapter->set_clk_freq)
> + ret = adapter->set_clk_freq(adapter, clock_hz);
> +
> + return ret;
The 'ret' is redundant and can be dropped completely. This makes the function
2LoCs shorter.
> +}
--
With Best Regards,
Andy Shevchenko
More information about the linux-arm-kernel
mailing list