summaryrefslogtreecommitdiffstats
path: root/drivers/staging/android/ion/ion_system_heap.c
diff options
context:
space:
mode:
authorLaura Abbott <labbott@redhat.com>2017-04-18 11:27:10 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-04-18 20:43:14 +0200
commit2f87f50b234038ff91f67b4a98f2289ff630563a (patch)
tree82d312ca71d3b6a7bd0dc5e2864e64547f3a455b /drivers/staging/android/ion/ion_system_heap.c
parenteb9751dbe6aaff217769d6bf2adc8eea684714a1 (diff)
staging: android: ion: Rework heap registration/enumeration
The current model of Ion heap registration is based on the outdated model of board files. The replacement for board files (devicetree) isn't a good replacement for what Ion wants to do. In actuality, Ion wants to show what memory is available in the system for something else to figure out what to use. Switch to a model where Ion creates its device unconditionally and heaps are registed as available regions. Currently, only system and CMA heaps are converted over to the new model. Carveout and chunk heaps can be converted over when someone wants to figure out how. Signed-off-by: Laura Abbott <labbott@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/android/ion/ion_system_heap.c')
-rw-r--r--drivers/staging/android/ion/ion_system_heap.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c
index 4e6fe371bc0e..c50f2d9fc58c 100644
--- a/drivers/staging/android/ion/ion_system_heap.c
+++ b/drivers/staging/android/ion/ion_system_heap.c
@@ -320,7 +320,7 @@ err_create_pool:
return -ENOMEM;
}
-struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused)
+static struct ion_heap *__ion_system_heap_create(void)
{
struct ion_system_heap *heap;
@@ -348,19 +348,19 @@ free_heap:
return ERR_PTR(-ENOMEM);
}
-void ion_system_heap_destroy(struct ion_heap *heap)
+static int ion_system_heap_create(void)
{
- struct ion_system_heap *sys_heap = container_of(heap,
- struct ion_system_heap,
- heap);
- int i;
+ struct ion_heap *heap;
- for (i = 0; i < NUM_ORDERS; i++) {
- ion_page_pool_destroy(sys_heap->uncached_pools[i]);
- ion_page_pool_destroy(sys_heap->cached_pools[i]);
- }
- kfree(sys_heap);
+ heap = __ion_system_heap_create();
+ if (IS_ERR(heap))
+ return PTR_ERR(heap);
+ heap->name = "ion_system_heap";
+
+ ion_device_add_heap(heap);
+ return 0;
}
+device_initcall(ion_system_heap_create);
static int ion_system_contig_heap_allocate(struct ion_heap *heap,
struct ion_buffer *buffer,
@@ -429,7 +429,7 @@ static struct ion_heap_ops kmalloc_ops = {
.map_user = ion_heap_map_user,
};
-struct ion_heap *ion_system_contig_heap_create(struct ion_platform_heap *unused)
+static struct ion_heap *__ion_system_contig_heap_create(void)
{
struct ion_heap *heap;
@@ -438,10 +438,20 @@ struct ion_heap *ion_system_contig_heap_create(struct ion_platform_heap *unused)
return ERR_PTR(-ENOMEM);
heap->ops = &kmalloc_ops;
heap->type = ION_HEAP_TYPE_SYSTEM_CONTIG;
+ heap->name = "ion_system_contig_heap";
return heap;
}
-void ion_system_contig_heap_destroy(struct ion_heap *heap)
+static int ion_system_contig_heap_create(void)
{
- kfree(heap);
+ struct ion_heap *heap;
+
+ heap = __ion_system_contig_heap_create();
+ if (IS_ERR(heap))
+ return PTR_ERR(heap);
+
+ ion_device_add_heap(heap);
+ return 0;
}
+device_initcall(ion_system_contig_heap_create);
+