ida: Change ida_get_new_above to return the id

This calling convention makes more sense for the implementation as well
as the callers. It even shaves 32 bytes off the compiled code size.

Signed-off-by: Matthew Wilcox <willy@infradead.org>

Changed files
+12 -18
lib
+12 -18
lib/idr.c
··· 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 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 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) ··· 443 444 radix_tree_iter_replace(root, &iter, slot, bitmap); 444 445 } 445 446 446 - *id = new; 447 - return 0; 447 + return new; 448 448 } 449 449 } 450 450 ··· 532 534 int ida_alloc_range(struct ida *ida, unsigned int min, unsigned int max, 533 535 gfp_t gfp) 534 536 { 535 - int ret, id = 0; 537 + int id = 0; 536 538 unsigned long flags; 537 539 538 540 if ((int)min < 0) ··· 543 545 544 546 again: 545 547 xa_lock_irqsave(&ida->ida_rt, flags); 546 - ret = ida_get_new_above(ida, min, &id); 547 - if (!ret) { 548 - if (id > max) { 549 - ida_remove(ida, id); 550 - ret = -ENOSPC; 551 - } else { 552 - ret = id; 553 - } 548 + id = ida_get_new_above(ida, min); 549 + if (id > (int)max) { 550 + ida_remove(ida, id); 551 + id = -ENOSPC; 554 552 } 555 553 xa_unlock_irqrestore(&ida->ida_rt, flags); 556 554 557 - if (unlikely(ret == -EAGAIN)) { 555 + if (unlikely(id == -EAGAIN)) { 558 556 if (!ida_pre_get(ida, gfp)) 559 557 return -ENOMEM; 560 558 goto again; 561 559 } 562 560 563 - return ret; 561 + return id; 564 562 } 565 563 EXPORT_SYMBOL(ida_alloc_range); 566 564