diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c index bfc8a7b32486..de191855b70f 100644 --- a/drivers/dma-buf/dma-heap.c +++ b/drivers/dma-buf/dma-heap.c @@ -50,7 +50,7 @@ static dev_t dma_heap_devt; static struct class *dma_heap_class; static DEFINE_XARRAY_ALLOC(dma_heap_minors); -static struct dma_heap *dma_heap_find(const char *name) +struct dma_heap *dma_heap_find(const char *name) { struct dma_heap *h; @@ -65,11 +65,14 @@ static struct dma_heap *dma_heap_find(const char *name) mutex_unlock(&heap_list_lock); return NULL; } +EXPORT_SYMBOL_GPL(dma_heap_find); + void dma_heap_buffer_free(struct dma_buf *dmabuf) { dma_buf_put(dmabuf); } +EXPORT_SYMBOL_GPL(dma_heap_buffer_free); struct dma_buf *dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, unsigned int fd_flags, @@ -90,6 +93,7 @@ struct dma_buf *dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, return heap->ops->allocate(heap, len, fd_flags, heap_flags); } +EXPORT_SYMBOL_GPL(dma_heap_buffer_alloc); int dma_heap_bufferfd_alloc(struct dma_heap *heap, size_t len, unsigned int fd_flags, @@ -111,6 +115,7 @@ int dma_heap_bufferfd_alloc(struct dma_heap *heap, size_t len, return fd; } +EXPORT_SYMBOL_GPL(dma_heap_bufferfd_alloc); static int dma_heap_open(struct inode *inode, struct file *file) { diff --git a/include/linux/dma-heap.h b/include/linux/dma-heap.h index 838e37736ae7..35dbdd8c28cc 100644 --- a/include/linux/dma-heap.h +++ b/include/linux/dma-heap.h @@ -62,4 +62,43 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info); */ void dma_heap_put(struct dma_heap *heap); +/** + * dma_heap_find - Returns the registered dma_heap with the specified name + * @name: Name of the heap to find + * + * NOTE: dma_heaps returned from this function MUST be released + * using dma_heap_put() when the user is done. + */ +struct dma_heap *dma_heap_find(const char *name); + +/** + * dma_heap_buffer_alloc - Allocate dma-buf from a dma_heap + * @heap: dma_heap to allocate from + * @len: size to allocate + * @fd_flags: flags to set on returned dma-buf fd + * @heap_flags: flags to pass to the dma heap + * + * This is for internal dma-buf allocations only. + */ +struct dma_buf *dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, + unsigned int fd_flags, + unsigned int heap_flags); + +/** dma_heap_buffer_free - Free dma_buf allocated by dma_heap_buffer_alloc + * @dma_buf: dma_buf to free + * + * This is really only a simple wrapper to dma_buf_put() + */ +void dma_heap_buffer_free(struct dma_buf *); + +/** + * dma_heap_bufferfd_alloc - Allocate dma-buf fd from a dma_heap + * @heap: dma_heap to allocate from + * @len: size to allocate + * @fd_flags: flags to set on returned dma-buf fd + * @heap_flags: flags to pass to the dma heap + */ +int dma_heap_bufferfd_alloc(struct dma_heap *heap, size_t len, + unsigned int fd_flags, + unsigned int heap_flags); #endif /* _DMA_HEAPS_H */