Skip to content

Commit

Permalink
IB/cm: Convert to using idr_alloc_cyclic()
Browse files Browse the repository at this point in the history
Commit 3e6628c ("idr: introduce idr_alloc_cyclic()") adds a new
idr_alloc_cyclic() routine and converts several of these users to it.
This is just a missed one - add it.

Signed-off-by: Zhao Hongjiang <zhaohongjiang@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Roland Dreier <roland@purestorage.com>
  • Loading branch information
Zhao Hongjiang authored and Roland Dreier committed Nov 16, 2013
1 parent 1c636f8 commit ab626d1
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions drivers/infiniband/core/cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,11 @@ static int cm_alloc_id(struct cm_id_private *cm_id_priv)
{
unsigned long flags;
int id;
static int next_id;

idr_preload(GFP_KERNEL);
spin_lock_irqsave(&cm.lock, flags);

id = idr_alloc(&cm.local_id_table, cm_id_priv, next_id, 0, GFP_NOWAIT);
if (id >= 0)
next_id = max(id + 1, 0);
id = idr_alloc_cyclic(&cm.local_id_table, cm_id_priv, 0, 0, GFP_NOWAIT);

spin_unlock_irqrestore(&cm.lock, flags);
idr_preload_end();
Expand Down

0 comments on commit ab626d1

Please sign in to comment.