From khali@linux-fr.org Sun Feb 5 14:27:37 2006 Date: Sun, 5 Feb 2006 23:28:21 +0100 From: Jean Delvare To: Greg KH Cc: Ingo Molnar Subject: [PATCH 08/11] i2c: Optimize core_lists mutex usage Message-Id: <20060205232821.25bd8615.khali@linux-fr.org> Content-Disposition: inline; filename=i2c-core-optimize-mutex-use.patch Stop holding the core_lists mutex when we don't actually need it. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/i2c-core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) --- gregkh-2.6.orig/drivers/i2c/i2c-core.c +++ gregkh-2.6/drivers/i2c/i2c-core.c @@ -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);