Skip to contentSkip to conversation

i2c: Optimize core_lists mutex usage

PATCH New Greg KH 1 participant 1 message Mar 23, 2006 I2C

lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 26/36 i2c: Optimize core_lists mutex usage

Stop holding the core_lists mutex when we don't actually need it.

Signed-off-by Jean Delvare <khali at linux-fr.org>
Signed-off-by Greg Kroah-Hartman <gregkh at suse.de>

---

 drivers/i2c/i2c-core.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

7eebcb7c0f4d45168265bdca79cc3e609d68d436

drivers/i2c/i2c-core.c +5 -6
index 975cb64..45e2cdf 100644
@@ -288,9 +288,7 @@ int i2c_register_driver(struct module *o
 {
 	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 *o
 
 	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 *o
 		}
 	}
 
- out_unlock:
 	mutex_unlock(&core_lists);
-	return res;
+	return 0;
 }
 EXPORT_SYMBOL(i2c_register_driver);
 
Signature · 1 line
1.2.4