From ad260cb023ab434911613f4c6d1652417702b6c4 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Wed, 20 Feb 2013 13:16:16 +1100 Subject: [PATCH] i2c-convert-to-idr_alloc-fix v2: The original conversion accidentally dropped a call to i2c_register_adapter() in i2c_add_numbered_adapter() leaving @adap uninitialized and unregistered. Reported by Mark Brown. Fix it. Signed-off-by: Tejun Heo Reported-by: Mark Brown Cc: Jean Delvare Cc: Wolfram Sang Signed-off-by: Andrew Morton --- drivers/i2c/i2c-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 795c916cf42a..0b599f25c17d 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -978,6 +978,8 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adap) if (adap->nr == -1) /* -1 means dynamically assign bus id */ return i2c_add_adapter(adap); + if (adap->nr & ~MAX_IDR_MASK) + return -EINVAL; mutex_lock(&core_lock); id = idr_alloc(&i2c_adapter_idr, adap, adap->nr, adap->nr + 1, @@ -985,7 +987,7 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adap) mutex_unlock(&core_lock); if (id < 0) return id == -ENOSPC ? -EBUSY : id; - return 0; + return i2c_register_adapter(adap); } EXPORT_SYMBOL_GPL(i2c_add_numbered_adapter); -- 2.39.5