Skip to content
Snippets Groups Projects
Commit e8791c9e authored by Gianfranco Mariotti's avatar Gianfranco Mariotti Committed by OpenEmbedded
Browse files
parent 5bef095a
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
* @heap_devt heap device node * @heap_devt heap device node
* @list list head connecting to list of heaps * @list list head connecting to list of heaps
* @heap_cdev heap char device * @heap_cdev heap char device
* @heap_dev heap device struct
* *
* Represents a heap of memory from which buffers can be made. * Represents a heap of memory from which buffers can be made.
*/ */
...@@ -42,6 +43,7 @@ struct dma_heap { ...@@ -42,6 +43,7 @@ struct dma_heap {
struct cdev heap_cdev; struct cdev heap_cdev;
int minor; int minor;
struct kref refcount; struct kref refcount;
struct device *heap_dev;
}; };
static LIST_HEAD(heap_list); static LIST_HEAD(heap_list);
...@@ -243,10 +245,21 @@ void dma_heap_put(struct dma_heap *h) ...@@ -243,10 +245,21 @@ void dma_heap_put(struct dma_heap *h)
mutex_unlock(&heap_list_lock); mutex_unlock(&heap_list_lock);
} }
/**
* dma_heap_get_dev() - get device struct for the heap
* @heap: DMA-Heap to retrieve device struct from
*
* Returns:
* The device struct for the heap.
*/
struct device *dma_heap_get_dev(struct dma_heap *heap)
{
return heap->heap_dev;
}
struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info) struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
{ {
struct dma_heap *heap, *h, *err_ret; struct dma_heap *heap, *h, *err_ret;
struct device *dev_ret;
int ret; int ret;
if (!exp_info->name || !strcmp(exp_info->name, "")) { if (!exp_info->name || !strcmp(exp_info->name, "")) {
...@@ -300,16 +313,20 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info) ...@@ -300,16 +313,20 @@ struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
goto err1; goto err1;
} }
dev_ret = device_create(dma_heap_class, heap->heap_dev = device_create(dma_heap_class,
NULL, NULL,
heap->heap_devt, heap->heap_devt,
NULL, NULL,
heap->name); heap->name);
if (IS_ERR(dev_ret)) { if (IS_ERR(heap->heap_dev)) {
pr_err("dma_heap: Unable to create device\n"); pr_err("dma_heap: Unable to create device\n");
err_ret = ERR_CAST(dev_ret); err_ret = ERR_CAST(heap->heap_dev);
goto err2; goto err2;
} }
/* Make sure it doesn't disappear on us */
heap->heap_dev = get_device(heap->heap_dev);
/* Add heap to the list */ /* Add heap to the list */
mutex_lock(&heap_list_lock); mutex_lock(&heap_list_lock);
list_add(&heap->list, &heap_list); list_add(&heap->list, &heap_list);
......
...@@ -50,6 +50,15 @@ struct dma_heap_export_info { ...@@ -50,6 +50,15 @@ struct dma_heap_export_info {
*/ */
void *dma_heap_get_drvdata(struct dma_heap *heap); void *dma_heap_get_drvdata(struct dma_heap *heap);
/**
* dma_heap_get_dev() - get device struct for the heap
* @heap: DMA-Heap to retrieve device struct from
*
* Returns:
* The device struct for the heap.
*/
struct device *dma_heap_get_dev(struct dma_heap *heap);
/** /**
* dma_heap_add - adds a heap to dmabuf heaps * dma_heap_add - adds a heap to dmabuf heaps
* @exp_info: information needed to register this heap * @exp_info: information needed to register this heap
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment