In case we are instantiating a I2C bus driver from device tree let's try to get the bus number from the device tree instead of dynamically assigning a free bus number. Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- drivers/i2c/i2c.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c index 5471519045..4eed7fb5c6 100644 --- a/drivers/i2c/i2c.c +++ b/drivers/i2c/i2c.c @@ -705,6 +705,9 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adapter) struct device *hw_dev; int ret; + if (adapter->nr < 0 && adapter->dev.parent && adapter->dev.parent->of_node) + adapter->nr = of_alias_get_id(adapter->dev.parent->of_node, "i2c"); + if (adapter->nr < 0) { int nr; -- 2.39.5