From 02d86ef9d719411e93dd2f14624043430406d1e5 Mon Sep 17 00:00:00 2001 From: Olav Haugan Date: Mon, 19 Dec 2011 17:53:38 -0800 Subject: [PATCH] gpu: ion: Refactor platform data Refactor platform data to allow for better expansion in the future. Add void * for elements unique to each heap type. Change-Id: I435679819c67ce917b5798009eff7e71047fd2ea Signed-off-by: Olav Haugan [sboyd: drop board file changes] Signed-off-by: Stephen Boyd --- drivers/gpu/ion/ion_carveout_heap.c | 19 +++++++++++++------ drivers/gpu/ion/ion_cp_heap.c | 19 +++++++++++-------- include/linux/ion.h | 10 ++++++++++ 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/ion/ion_carveout_heap.c b/drivers/gpu/ion/ion_carveout_heap.c index 85f765eeae5..72ba4edd656 100644 --- a/drivers/gpu/ion/ion_carveout_heap.c +++ b/drivers/gpu/ion/ion_carveout_heap.c @@ -417,13 +417,20 @@ struct ion_heap *ion_carveout_heap_create(struct ion_platform_heap *heap_data) carveout_heap->heap.type = ION_HEAP_TYPE_CARVEOUT; carveout_heap->allocated_bytes = 0; carveout_heap->total_size = heap_data->size; - if (heap_data->setup_region) - carveout_heap->bus_id = heap_data->setup_region(); - if (heap_data->request_region) - carveout_heap->request_region = heap_data->request_region; - if (heap_data->release_region) - carveout_heap->release_region = heap_data->release_region; + if (heap_data->extra_data) { + struct ion_co_heap_pdata *extra_data = + heap_data->extra_data; + + if (extra_data->setup_region) + carveout_heap->bus_id = extra_data->setup_region(); + if (extra_data->request_region) + carveout_heap->request_region = + extra_data->request_region; + if (extra_data->release_region) + carveout_heap->release_region = + extra_data->release_region; + } return &carveout_heap->heap; } diff --git a/drivers/gpu/ion/ion_cp_heap.c b/drivers/gpu/ion/ion_cp_heap.c index 2e0a0889184..5c0e5e3f378 100644 --- a/drivers/gpu/ion/ion_cp_heap.c +++ b/drivers/gpu/ion/ion_cp_heap.c @@ -623,7 +623,6 @@ struct ion_heap *ion_cp_heap_create(struct ion_platform_heap *heap_data) if (ret < 0) goto destroy_pool; - cp_heap->permission_type = heap_data->permission_type; cp_heap->allocated_bytes = 0; cp_heap->alloc_count = 0; cp_heap->umap_count = 0; @@ -632,13 +631,17 @@ struct ion_heap *ion_cp_heap_create(struct ion_platform_heap *heap_data) cp_heap->heap.ops = &cp_heap_ops; cp_heap->heap.type = ION_HEAP_TYPE_CP; cp_heap->heap_secured = NON_SECURED_HEAP; - if (heap_data->setup_region) - cp_heap->bus_id = heap_data->setup_region(); - if (heap_data->request_region) - cp_heap->request_region = heap_data->request_region; - if (heap_data->release_region) - cp_heap->release_region = heap_data->release_region; - + if (heap_data->extra_data) { + struct ion_cp_heap_pdata *extra_data = + heap_data->extra_data; + cp_heap->permission_type = extra_data->permission_type; + if (extra_data->setup_region) + cp_heap->bus_id = extra_data->setup_region(); + if (extra_data->request_region) + cp_heap->request_region = extra_data->request_region; + if (extra_data->release_region) + cp_heap->release_region = extra_data->release_region; + } return &cp_heap->heap; destroy_pool: diff --git a/include/linux/ion.h b/include/linux/ion.h index afd081d904b..b95887b8929 100644 --- a/include/linux/ion.h +++ b/include/linux/ion.h @@ -143,12 +143,22 @@ struct ion_platform_heap { ion_phys_addr_t base; size_t size; enum ion_memory_types memory_type; + void *extra_data; +}; + +struct ion_cp_heap_pdata { enum ion_permission_type permission_type; int (*request_region)(void *); int (*release_region)(void *); void *(*setup_region)(void); }; +struct ion_co_heap_pdata { + int (*request_region)(void *); + int (*release_region)(void *); + void *(*setup_region)(void); +}; + /** * struct ion_platform_data - array of platform heaps passed from board file * @nr: number of structures in the array