aboutsummaryrefslogtreecommitdiffstats
path: root/lib/genalloc.c
diff options
context:
space:
mode:
authorMichal Marek <mmarek@suse.cz>2014-01-02 08:02:06 -0500
committerMichal Marek <mmarek@suse.cz>2014-01-02 08:02:06 -0500
commit37e2c2a775fc887acd1432908478dfd532f7f00f (patch)
treee51ebc699d8e262fd47e0913be6a711cb1a7b565 /lib/genalloc.c
parent1c8ddae09f4c102b97c9086cc70347e89468a547 (diff)
parent6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae (diff)
Merge commit v3.13-rc1 into kbuild/misc
Diffstat (limited to 'lib/genalloc.c')
-rw-r--r--lib/genalloc.c28
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:
313EXPORT_SYMBOL(gen_pool_alloc); 313EXPORT_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 */
326void *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}
341EXPORT_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