diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 22:47:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 22:47:50 -0400 |
commit | 56847d857cb0c3ee78c22ce776a26f88d9ffd4d4 (patch) | |
tree | a85bcf204a53e45d26f6a3984f16ddd525eef3e7 /lib/idr.c | |
parent | 191a712090bb8a10e6f129360eeed2d68f3d4c9a (diff) | |
parent | 8d564368a9a3197f43e56dadf4a18c5738849f94 (diff) |
Merge branch 'akpm' (incoming from Andrew)
Merge second batch of fixes from Andrew Morton:
- various misc bits
- some printk updates
- a new "SRAM" driver.
- MAINTAINERS updates
- the backlight driver queue
- checkpatch updates
- a few init/ changes
- a huge number of drivers/rtc changes
- fatfs updates
- some lib/idr.c work
- some renaming of the random driver interfaces
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (285 commits)
net: rename random32 to prandom
net/core: remove duplicate statements by do-while loop
net/core: rename random32() to prandom_u32()
net/netfilter: rename random32() to prandom_u32()
net/sched: rename random32() to prandom_u32()
net/sunrpc: rename random32() to prandom_u32()
scsi: rename random32() to prandom_u32()
lguest: rename random32() to prandom_u32()
uwb: rename random32() to prandom_u32()
video/uvesafb: rename random32() to prandom_u32()
mmc: rename random32() to prandom_u32()
drbd: rename random32() to prandom_u32()
kernel/: rename random32() to prandom_u32()
mm/: rename random32() to prandom_u32()
lib/: rename random32() to prandom_u32()
x86: rename random32() to prandom_u32()
x86: pageattr-test: remove srandom32 call
uuid: use prandom_bytes()
raid6test: use prandom_bytes()
sctp: convert sctp_assoc_set_id() to use idr_alloc_cyclic()
...
Diffstat (limited to 'lib/idr.c')
-rw-r--r-- | lib/idr.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -495,6 +495,33 @@ int idr_alloc(struct idr *idr, void *ptr, int start, int end, gfp_t gfp_mask) | |||
495 | } | 495 | } |
496 | EXPORT_SYMBOL_GPL(idr_alloc); | 496 | EXPORT_SYMBOL_GPL(idr_alloc); |
497 | 497 | ||
498 | /** | ||
499 | * idr_alloc_cyclic - allocate new idr entry in a cyclical fashion | ||
500 | * @idr: the (initialized) idr | ||
501 | * @ptr: pointer to be associated with the new id | ||
502 | * @start: the minimum id (inclusive) | ||
503 | * @end: the maximum id (exclusive, <= 0 for max) | ||
504 | * @gfp_mask: memory allocation flags | ||
505 | * | ||
506 | * Essentially the same as idr_alloc, but prefers to allocate progressively | ||
507 | * higher ids if it can. If the "cur" counter wraps, then it will start again | ||
508 | * at the "start" end of the range and allocate one that has already been used. | ||
509 | */ | ||
510 | int idr_alloc_cyclic(struct idr *idr, void *ptr, int start, int end, | ||
511 | gfp_t gfp_mask) | ||
512 | { | ||
513 | int id; | ||
514 | |||
515 | id = idr_alloc(idr, ptr, max(start, idr->cur), end, gfp_mask); | ||
516 | if (id == -ENOSPC) | ||
517 | id = idr_alloc(idr, ptr, start, end, gfp_mask); | ||
518 | |||
519 | if (likely(id >= 0)) | ||
520 | idr->cur = id + 1; | ||
521 | return id; | ||
522 | } | ||
523 | EXPORT_SYMBOL(idr_alloc_cyclic); | ||
524 | |||
498 | static void idr_remove_warning(int id) | 525 | static void idr_remove_warning(int id) |
499 | { | 526 | { |
500 | printk(KERN_WARNING | 527 | printk(KERN_WARNING |