aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c-core.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@infradead.org>2006-01-11 04:50:26 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-23 17:21:49 -0500
commitb3585e4f5b3e4ddb4d82ae50d0b844f619c6d821 (patch)
tree5375363cc6087d74196efc0ded6dae9a8a4c2ad5 /drivers/i2c/i2c-core.c
parent2488a39d233a758d41ab7de70a220bc956f3c96c (diff)
[PATCH] I2C: Convert i2c to mutexes
The patch below converts a few i2c semaphores to mutexes Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r--drivers/i2c/i2c-core.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 1a2c9ab5d9e3..97334433e534 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -31,12 +31,13 @@
31#include <linux/idr.h> 31#include <linux/idr.h>
32#include <linux/seq_file.h> 32#include <linux/seq_file.h>
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/mutex.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35 36
36 37
37static LIST_HEAD(adapters); 38static LIST_HEAD(adapters);
38static LIST_HEAD(drivers); 39static LIST_HEAD(drivers);
39static DECLARE_MUTEX(core_lists); 40static DEFINE_MUTEX(core_lists);
40static DEFINE_IDR(i2c_adapter_idr); 41static DEFINE_IDR(i2c_adapter_idr);
41 42
42/* match always succeeds, as we want the probe() to tell if we really accept this match */ 43/* match always succeeds, as we want the probe() to tell if we really accept this match */
@@ -153,7 +154,7 @@ int i2c_add_adapter(struct i2c_adapter *adap)
153 struct list_head *item; 154 struct list_head *item;
154 struct i2c_driver *driver; 155 struct i2c_driver *driver;
155 156
156 down(&core_lists); 157 mutex_lock(&core_lists);
157 158
158 if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) { 159 if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) {
159 res = -ENOMEM; 160 res = -ENOMEM;
@@ -203,7 +204,7 @@ int i2c_add_adapter(struct i2c_adapter *adap)
203 } 204 }
204 205
205out_unlock: 206out_unlock:
206 up(&core_lists); 207 mutex_unlock(&core_lists);
207 return res; 208 return res;
208} 209}
209 210
@@ -216,7 +217,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
216 struct i2c_client *client; 217 struct i2c_client *client;
217 int res = 0; 218 int res = 0;
218 219
219 down(&core_lists); 220 mutex_lock(&core_lists);
220 221
221 /* First make sure that this adapter was ever added */ 222 /* First make sure that this adapter was ever added */
222 list_for_each_entry(adap_from_list, &adapters, list) { 223 list_for_each_entry(adap_from_list, &adapters, list) {
@@ -272,7 +273,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
272 dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); 273 dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name);
273 274
274 out_unlock: 275 out_unlock:
275 up(&core_lists); 276 mutex_unlock(&core_lists);
276 return res; 277 return res;
277} 278}
278 279
@@ -289,7 +290,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
289 struct i2c_adapter *adapter; 290 struct i2c_adapter *adapter;
290 int res = 0; 291 int res = 0;
291 292
292 down(&core_lists); 293 mutex_lock(&core_lists);
293 294
294 /* add the driver to the list of i2c drivers in the driver core */ 295 /* add the driver to the list of i2c drivers in the driver core */
295 driver->driver.owner = owner; 296 driver->driver.owner = owner;
@@ -311,7 +312,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
311 } 312 }
312 313
313 out_unlock: 314 out_unlock:
314 up(&core_lists); 315 mutex_unlock(&core_lists);
315 return res; 316 return res;
316} 317}
317EXPORT_SYMBOL(i2c_register_driver); 318EXPORT_SYMBOL(i2c_register_driver);
@@ -324,7 +325,7 @@ int i2c_del_driver(struct i2c_driver *driver)
324 325
325 int res = 0; 326 int res = 0;
326 327
327 down(&core_lists); 328 mutex_lock(&core_lists);
328 329
329 /* Have a look at each adapter, if clients of this driver are still 330 /* Have a look at each adapter, if clients of this driver are still
330 * attached. If so, detach them to be able to kill the driver 331 * attached. If so, detach them to be able to kill the driver
@@ -363,7 +364,7 @@ int i2c_del_driver(struct i2c_driver *driver)
363 pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); 364 pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name);
364 365
365 out_unlock: 366 out_unlock:
366 up(&core_lists); 367 mutex_unlock(&core_lists);
367 return 0; 368 return 0;
368} 369}
369 370
@@ -779,12 +780,12 @@ struct i2c_adapter* i2c_get_adapter(int id)
779{ 780{
780 struct i2c_adapter *adapter; 781 struct i2c_adapter *adapter;
781 782
782 down(&core_lists); 783 mutex_lock(&core_lists);
783 adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id); 784 adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id);
784 if (adapter && !try_module_get(adapter->owner)) 785 if (adapter && !try_module_get(adapter->owner))
785 adapter = NULL; 786 adapter = NULL;
786 787
787 up(&core_lists); 788 mutex_unlock(&core_lists);
788 return adapter; 789 return adapter;
789} 790}
790 791