Signed-off-by: Sascha Hauer <s.ha...@pengutronix.de> --- drivers/i2c/i2c.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c index 53a11fe..ddf0082 100644 --- a/drivers/i2c/i2c.c +++ b/drivers/i2c/i2c.c @@ -384,8 +384,17 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adapter) { int ret; - if (i2c_get_adapter(adapter->nr)) - return -EBUSY; + if (adapter->nr < 0) { + int nr; + + for (nr = 0;; nr++) + if (!i2c_get_adapter(nr)) + break; + adapter->nr = nr; + } else { + if (i2c_get_adapter(adapter->nr)) + return -EBUSY; + } adapter->dev.id = adapter->nr; strcpy(adapter->dev.name, "i2c"); -- 1.8.2.rc2 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox