]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
i2c-convert-to-idr_alloc-fix
authorTejun Heo <tj@kernel.org>
Wed, 20 Feb 2013 02:16:16 +0000 (13:16 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 20 Feb 2013 05:53:46 +0000 (16:53 +1100)
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 <tj@kernel.org>
Reported-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Wolfram Sang <wolfram@the-dreams.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/i2c/i2c-core.c

index 795c916cf42add9ac58075892c95cb409af5329a..0b599f25c17de6ea33250307d40da1489a3cb3c1 100644 (file)
@@ -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);