diff options
Diffstat (limited to 'lib/genalloc.c')
| -rw-r--r-- | lib/genalloc.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/genalloc.c b/lib/genalloc.c index 26cf20be72b7..dda31168844f 100644 --- a/lib/genalloc.c +++ b/lib/genalloc.c | |||
| @@ -313,6 +313,34 @@ retry: | |||
| 313 | EXPORT_SYMBOL(gen_pool_alloc); | 313 | EXPORT_SYMBOL(gen_pool_alloc); |
| 314 | 314 | ||
| 315 | /** | 315 | /** |
| 316 | * gen_pool_dma_alloc - allocate special memory from the pool for DMA usage | ||
| 317 | * @pool: pool to allocate from | ||
| 318 | * @size: number of bytes to allocate from the pool | ||
| 319 | * @dma: dma-view physical address | ||
| 320 | * | ||
| 321 | * Allocate the requested number of bytes from the specified pool. | ||
| 322 | * Uses the pool allocation function (with first-fit algorithm by default). | ||
| 323 | * Can not be used in NMI handler on architectures without | ||
| 324 | * NMI-safe cmpxchg implementation. | ||
| 325 | */ | ||
| 326 | void *gen_pool_dma_alloc(struct gen_pool *pool, size_t size, dma_addr_t *dma) | ||
| 327 | { | ||
| 328 | unsigned long vaddr; | ||
| 329 | |||
| 330 | if (!pool) | ||
| 331 | return NULL; | ||
| 332 | |||
| 333 | vaddr = gen_pool_alloc(pool, size); | ||
| 334 | if (!vaddr) | ||
| 335 | return NULL; | ||
| 336 | |||
| 337 | *dma = gen_pool_virt_to_phys(pool, vaddr); | ||
| 338 | |||
| 339 | return (void *)vaddr; | ||
| 340 | } | ||
| 341 | EXPORT_SYMBOL(gen_pool_dma_alloc); | ||
| 342 | |||
| 343 | /** | ||
| 316 | * gen_pool_free - free allocated special memory back to the pool | 344 | * gen_pool_free - free allocated special memory back to the pool |
| 317 | * @pool: pool to free to | 345 | * @pool: pool to free to |
| 318 | * @addr: starting address of memory to free back to pool | 346 | * @addr: starting address of memory to free back to pool |
