aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/device.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-01-13 17:51:39 -0500
committerRoland Dreier <rolandd@cisco.com>2006-01-13 17:51:39 -0500
commit95ed644fd12f53c6fc778f3f246974e5fe3a9468 (patch)
treeedf9f57192ad95f9165b3be5dbf1e8e745249ed1 /drivers/infiniband/core/device.c
parent9eacee2ac624bfa9740d49355dbe6ee88d0cba0a (diff)
IB: convert from semaphores to mutexes
semaphore to mutex conversion by Ingo and Arjan's script. Signed-off-by: Ingo Molnar <mingo@elte.hu> [ Sanity-checked on real IB hardware ] Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/core/device.c')
-rw-r--r--drivers/infiniband/core/device.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index e169e798354b..b2f3cb91d9bc 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -38,8 +38,7 @@
38#include <linux/errno.h> 38#include <linux/errno.h>
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <linux/init.h> 40#include <linux/init.h>
41 41#include <linux/mutex.h>
42#include <asm/semaphore.h>
43 42
44#include "core_priv.h" 43#include "core_priv.h"
45 44
@@ -57,13 +56,13 @@ static LIST_HEAD(device_list);
57static LIST_HEAD(client_list); 56static LIST_HEAD(client_list);
58 57
59/* 58/*
60 * device_sem protects access to both device_list and client_list. 59 * device_mutex protects access to both device_list and client_list.
61 * There's no real point to using multiple locks or something fancier 60 * There's no real point to using multiple locks or something fancier
62 * like an rwsem: we always access both lists, and we're always 61 * like an rwsem: we always access both lists, and we're always
63 * modifying one list or the other list. In any case this is not a 62 * modifying one list or the other list. In any case this is not a
64 * hot path so there's no point in trying to optimize. 63 * hot path so there's no point in trying to optimize.
65 */ 64 */
66static DECLARE_MUTEX(device_sem); 65static DEFINE_MUTEX(device_mutex);
67 66
68static int ib_device_check_mandatory(struct ib_device *device) 67static int ib_device_check_mandatory(struct ib_device *device)
69{ 68{
@@ -221,7 +220,7 @@ int ib_register_device(struct ib_device *device)
221{ 220{
222 int ret; 221 int ret;
223 222
224 down(&device_sem); 223 mutex_lock(&device_mutex);
225 224
226 if (strchr(device->name, '%')) { 225 if (strchr(device->name, '%')) {
227 ret = alloc_name(device->name); 226 ret = alloc_name(device->name);
@@ -259,7 +258,7 @@ int ib_register_device(struct ib_device *device)
259 } 258 }
260 259
261 out: 260 out:
262 up(&device_sem); 261 mutex_unlock(&device_mutex);
263 return ret; 262 return ret;
264} 263}
265EXPORT_SYMBOL(ib_register_device); 264EXPORT_SYMBOL(ib_register_device);
@@ -276,7 +275,7 @@ void ib_unregister_device(struct ib_device *device)
276 struct ib_client_data *context, *tmp; 275 struct ib_client_data *context, *tmp;
277 unsigned long flags; 276 unsigned long flags;
278 277
279 down(&device_sem); 278 mutex_lock(&device_mutex);
280 279
281 list_for_each_entry_reverse(client, &client_list, list) 280 list_for_each_entry_reverse(client, &client_list, list)
282 if (client->remove) 281 if (client->remove)
@@ -284,7 +283,7 @@ void ib_unregister_device(struct ib_device *device)
284 283
285 list_del(&device->core_list); 284 list_del(&device->core_list);
286 285
287 up(&device_sem); 286 mutex_unlock(&device_mutex);
288 287
289 spin_lock_irqsave(&device->client_data_lock, flags); 288 spin_lock_irqsave(&device->client_data_lock, flags);
290 list_for_each_entry_safe(context, tmp, &device->client_data_list, list) 289 list_for_each_entry_safe(context, tmp, &device->client_data_list, list)
@@ -312,14 +311,14 @@ int ib_register_client(struct ib_client *client)
312{ 311{
313 struct ib_device *device; 312 struct ib_device *device;
314 313
315 down(&device_sem); 314 mutex_lock(&device_mutex);
316 315
317 list_add_tail(&client->list, &client_list); 316 list_add_tail(&client->list, &client_list);
318 list_for_each_entry(device, &device_list, core_list) 317 list_for_each_entry(device, &device_list, core_list)
319 if (client->add && !add_client_context(device, client)) 318 if (client->add && !add_client_context(device, client))
320 client->add(device); 319 client->add(device);
321 320
322 up(&device_sem); 321 mutex_unlock(&device_mutex);
323 322
324 return 0; 323 return 0;
325} 324}
@@ -339,7 +338,7 @@ void ib_unregister_client(struct ib_client *client)
339 struct ib_device *device; 338 struct ib_device *device;
340 unsigned long flags; 339 unsigned long flags;
341 340
342 down(&device_sem); 341 mutex_lock(&device_mutex);
343 342
344 list_for_each_entry(device, &device_list, core_list) { 343 list_for_each_entry(device, &device_list, core_list) {
345 if (client->remove) 344 if (client->remove)
@@ -355,7 +354,7 @@ void ib_unregister_client(struct ib_client *client)
355 } 354 }
356 list_del(&client->list); 355 list_del(&client->list);
357 356
358 up(&device_sem); 357 mutex_unlock(&device_mutex);
359} 358}
360EXPORT_SYMBOL(ib_unregister_client); 359EXPORT_SYMBOL(ib_unregister_client);
361 360