diff options
Diffstat (limited to 'lib/genalloc.c')
-rw-r--r-- | lib/genalloc.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/genalloc.c b/lib/genalloc.c index 166f17b9f169..cce4dd68c40d 100644 --- a/lib/genalloc.c +++ b/lib/genalloc.c | |||
@@ -403,6 +403,35 @@ void gen_pool_for_each_chunk(struct gen_pool *pool, | |||
403 | EXPORT_SYMBOL(gen_pool_for_each_chunk); | 403 | EXPORT_SYMBOL(gen_pool_for_each_chunk); |
404 | 404 | ||
405 | /** | 405 | /** |
406 | * addr_in_gen_pool - checks if an address falls within the range of a pool | ||
407 | * @pool: the generic memory pool | ||
408 | * @start: start address | ||
409 | * @size: size of the region | ||
410 | * | ||
411 | * Check if the range of addresses falls within the specified pool. Returns | ||
412 | * true if the entire range is contained in the pool and false otherwise. | ||
413 | */ | ||
414 | bool addr_in_gen_pool(struct gen_pool *pool, unsigned long start, | ||
415 | size_t size) | ||
416 | { | ||
417 | bool found = false; | ||
418 | unsigned long end = start + size; | ||
419 | struct gen_pool_chunk *chunk; | ||
420 | |||
421 | rcu_read_lock(); | ||
422 | list_for_each_entry_rcu(chunk, &(pool)->chunks, next_chunk) { | ||
423 | if (start >= chunk->start_addr && start <= chunk->end_addr) { | ||
424 | if (end <= chunk->end_addr) { | ||
425 | found = true; | ||
426 | break; | ||
427 | } | ||
428 | } | ||
429 | } | ||
430 | rcu_read_unlock(); | ||
431 | return found; | ||
432 | } | ||
433 | |||
434 | /** | ||
406 | * gen_pool_avail - get available free space of the pool | 435 | * gen_pool_avail - get available free space of the pool |
407 | * @pool: pool to get available free space | 436 | * @pool: pool to get available free space |
408 | * | 437 | * |