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 26cf20be72b..bdb9a456bcb 100644 --- a/lib/genalloc.c +++ b/lib/genalloc.c @@ -313,6 +313,35 @@ retry:  EXPORT_SYMBOL(gen_pool_alloc);  /** + * gen_pool_dma_alloc - allocate special memory from the pool for DMA usage + * @pool: pool to allocate from + * @size: number of bytes to allocate from the pool + * @dma: dma-view physical address return value.  Use NULL if unneeded. + * + * Allocate the requested number of bytes from the specified pool. + * Uses the pool allocation function (with first-fit algorithm by default). + * Can not be used in NMI handler on architectures without + * NMI-safe cmpxchg implementation. + */ +void *gen_pool_dma_alloc(struct gen_pool *pool, size_t size, dma_addr_t *dma) +{ +	unsigned long vaddr; + +	if (!pool) +		return NULL; + +	vaddr = gen_pool_alloc(pool, size); +	if (!vaddr) +		return NULL; + +	if (dma) +		*dma = gen_pool_virt_to_phys(pool, vaddr); + +	return (void *)vaddr; +} +EXPORT_SYMBOL(gen_pool_dma_alloc); + +/**   * gen_pool_free - free allocated special memory back to the pool   * @pool: pool to free to   * @addr: starting address of memory to free back to pool  | 
