net/9p: convert to idr_alloc()
Convert to the much saner new idr interface. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Eric Van Hensbergen <ericvh@gmail.com> Cc: Ron Minnich <rminnich@sandia.gov> Cc: Latchesar Ionkov <lucho@ionkov.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
ee94d523bf
commit
19a101a02e
|
@ -87,23 +87,18 @@ EXPORT_SYMBOL(p9_idpool_destroy);
|
||||||
|
|
||||||
int p9_idpool_get(struct p9_idpool *p)
|
int p9_idpool_get(struct p9_idpool *p)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i;
|
||||||
int error;
|
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
retry:
|
idr_preload(GFP_NOFS);
|
||||||
if (idr_pre_get(&p->pool, GFP_NOFS) == 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&p->lock, flags);
|
spin_lock_irqsave(&p->lock, flags);
|
||||||
|
|
||||||
/* no need to store exactly p, we just need something non-null */
|
/* no need to store exactly p, we just need something non-null */
|
||||||
error = idr_get_new(&p->pool, p, &i);
|
i = idr_alloc(&p->pool, p, 0, 0, GFP_NOWAIT);
|
||||||
spin_unlock_irqrestore(&p->lock, flags);
|
|
||||||
|
|
||||||
if (error == -EAGAIN)
|
spin_unlock_irqrestore(&p->lock, flags);
|
||||||
goto retry;
|
idr_preload_end();
|
||||||
else if (error)
|
if (i < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
p9_debug(P9_DEBUG_MUX, " id %d pool %p\n", i, p);
|
p9_debug(P9_DEBUG_MUX, " id %d pool %p\n", i, p);
|
||||||
|
|
Loading…
Reference in New Issue