[PATCH] i2c: Optimize core_lists mutex usage
authorJean Delvare <khali@linux-fr.org>
Sun, 5 Feb 2006 22:28:21 +0000 (23:28 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 23 Mar 2006 22:21:53 +0000 (14:21 -0800)
Stop holding the core_lists mutex when we don't actually need it.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/i2c/i2c-core.c

index 975cb64..45e2cdf 100644 (file)
@@ -288,9 +288,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
 {
        struct list_head   *item;
        struct i2c_adapter *adapter;
-       int res = 0;
-
-       mutex_lock(&core_lists);
+       int res;
 
        /* add the driver to the list of i2c drivers in the driver core */
        driver->driver.owner = owner;
@@ -298,8 +296,10 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
 
        res = driver_register(&driver->driver);
        if (res)
-               goto out_unlock;
+               return res;
        
+       mutex_lock(&core_lists);
+
        list_add_tail(&driver->list,&drivers);
        pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name);
 
@@ -311,9 +311,8 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
                }
        }
 
- out_unlock:
        mutex_unlock(&core_lists);
-       return res;
+       return 0;
 }
 EXPORT_SYMBOL(i2c_register_driver);