From 48e5872368b1ada27804e5c4c15fbeea9eb3c284 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 18 Oct 2004 18:15:27 -0700 Subject: [PATCH] [PATCH] Simplify last lib/idr.c change The last change to alloc_layer in lib/idr.c unnecessarily complicates the code and depending on the definition of spin_unlock will cause worse code to be generated than necessary. The following patch should improve the situation. Signed-off-by: Ulrich Drepper Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- lib/idr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/idr.c b/lib/idr.c index 972eefcce2b3a..7d92cfc23ac26 100644 --- a/lib/idr.c +++ b/lib/idr.c @@ -39,13 +39,11 @@ static struct idr_layer *alloc_layer(struct idr *idp) struct idr_layer *p; spin_lock(&idp->lock); - if (!(p = idp->id_free)) { - spin_unlock(&idp->lock); - return NULL; + if ((p = idp->id_free)) { + idp->id_free = p->ary[0]; + idp->id_free_cnt--; + p->ary[0] = NULL; } - idp->id_free = p->ary[0]; - idp->id_free_cnt--; - p->ary[0] = NULL; spin_unlock(&idp->lock); return(p); } -- 2.53.0