@@ -363,7 +363,7 @@ EXPORT_SYMBOL(idr_replace);
363
363
364
364
#define IDA_MAX (0x80000000U / IDA_BITMAP_BITS - 1)
365
365
366
- static int ida_get_new_above (struct ida * ida , int start , int * id )
366
+ static int ida_get_new_above (struct ida * ida , int start )
367
367
{
368
368
struct radix_tree_root * root = & ida -> ida_rt ;
369
369
void __rcu * * slot ;
@@ -402,8 +402,8 @@ static int ida_get_new_above(struct ida *ida, int start, int *id)
402
402
if (ebit < BITS_PER_LONG ) {
403
403
tmp |= 1UL << ebit ;
404
404
rcu_assign_pointer (* slot , (void * )tmp );
405
- * id = new + ebit - RADIX_TREE_EXCEPTIONAL_SHIFT ;
406
- return 0 ;
405
+ return new + ebit -
406
+ RADIX_TREE_EXCEPTIONAL_SHIFT ;
407
407
}
408
408
bitmap = this_cpu_xchg (ida_bitmap , NULL );
409
409
if (!bitmap )
@@ -434,8 +434,7 @@ static int ida_get_new_above(struct ida *ida, int start, int *id)
434
434
RADIX_TREE_EXCEPTIONAL_ENTRY );
435
435
radix_tree_iter_replace (root , & iter , slot ,
436
436
bitmap );
437
- * id = new ;
438
- return 0 ;
437
+ return new ;
439
438
}
440
439
bitmap = this_cpu_xchg (ida_bitmap , NULL );
441
440
if (!bitmap )
@@ -444,8 +443,7 @@ static int ida_get_new_above(struct ida *ida, int start, int *id)
444
443
radix_tree_iter_replace (root , & iter , slot , bitmap );
445
444
}
446
445
447
- * id = new ;
448
- return 0 ;
446
+ return new ;
449
447
}
450
448
}
451
449
@@ -534,7 +532,7 @@ EXPORT_SYMBOL(ida_destroy);
534
532
int ida_alloc_range (struct ida * ida , unsigned int min , unsigned int max ,
535
533
gfp_t gfp )
536
534
{
537
- int ret , id = 0 ;
535
+ int id = 0 ;
538
536
unsigned long flags ;
539
537
540
538
if ((int )min < 0 )
@@ -545,24 +543,20 @@ int ida_alloc_range(struct ida *ida, unsigned int min, unsigned int max,
545
543
546
544
again :
547
545
xa_lock_irqsave (& ida -> ida_rt , flags );
548
- ret = ida_get_new_above (ida , min , & id );
549
- if (!ret ) {
550
- if (id > max ) {
551
- ida_remove (ida , id );
552
- ret = - ENOSPC ;
553
- } else {
554
- ret = id ;
555
- }
546
+ id = ida_get_new_above (ida , min );
547
+ if (id > (int )max ) {
548
+ ida_remove (ida , id );
549
+ id = - ENOSPC ;
556
550
}
557
551
xa_unlock_irqrestore (& ida -> ida_rt , flags );
558
552
559
- if (unlikely (ret == - EAGAIN )) {
553
+ if (unlikely (id == - EAGAIN )) {
560
554
if (!ida_pre_get (ida , gfp ))
561
555
return - ENOMEM ;
562
556
goto again ;
563
557
}
564
558
565
- return ret ;
559
+ return id ;
566
560
}
567
561
EXPORT_SYMBOL (ida_alloc_range );
568
562
0 commit comments