diff mbox

[v9,2/3] gpu: ion: add private field in ion_heap and ion_platform_heap structure

Message ID 1363800815-2955-3-git-send-email-benjamin.gaignard@linaro.org
State Superseded
Headers show

Commit Message

Benjamin Gaignard March 20, 2013, 5:33 p.m. UTC
copy private field from platform configuration to internal heap structure.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
---
 drivers/gpu/ion/ion_heap.c |    1 +
 drivers/gpu/ion/ion_priv.h |    2 ++
 2 files changed, 3 insertions(+)

Comments

Rebecca Schultz Zavin March 21, 2013, 10:59 p.m. UTC | #1
Rather than coping the private data into the heap, in several other heaps
that have required private information, I've put the ion_heap struct inside
another structure that also contained the private fields.  So you would
have:

struct ion_cma_heap {
        struct ion_heap *heap;
        struct device *dev;
        .... other private data ...
};

Then you can retrieve the private data using container_of on the heap.
 It's a little more verbose, but I think a lot more flexible.

Rebecca

On Wed, Mar 20, 2013 at 10:33 AM, Benjamin Gaignard <
benjamin.gaignard@linaro.org> wrote:

> copy private field from platform configuration to internal heap structure.
>
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> ---
>  drivers/gpu/ion/ion_heap.c |    1 +
>  drivers/gpu/ion/ion_priv.h |    2 ++
>  2 files changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/ion/ion_heap.c b/drivers/gpu/ion/ion_heap.c
> index 225ef94..3ec6357 100644
> --- a/drivers/gpu/ion/ion_heap.c
> +++ b/drivers/gpu/ion/ion_heap.c
> @@ -162,6 +162,7 @@ struct ion_heap *ion_heap_create(struct
> ion_platform_heap *heap_data)
>
>         heap->name = heap_data->name;
>         heap->id = heap_data->id;
> +       heap->priv = heap_data->priv;
>         return heap;
>  }
>
> diff --git a/drivers/gpu/ion/ion_priv.h b/drivers/gpu/ion/ion_priv.h
> index 50568147..c79a942 100644
> --- a/drivers/gpu/ion/ion_priv.h
> +++ b/drivers/gpu/ion/ion_priv.h
> @@ -132,6 +132,7 @@ struct ion_heap_ops {
>   * @task:              task struct of deferred free thread
>   * @debug_show:                called when heap debug file is read to add
> any
>   *                     heap specific debug info to output
> + * @priv:              heap private data
>   *
>   * Represents a pool of memory from which buffers can be made.  In some
>   * systems the only heap is regular system memory allocated via vmalloc.
> @@ -151,6 +152,7 @@ struct ion_heap {
>         wait_queue_head_t waitqueue;
>         struct task_struct *task;
>         int (*debug_show)(struct ion_heap *heap, struct seq_file *, void
> *);
> +       void *priv;
>  };
>
>  /**
> --
> 1.7.10
>
>
Rebecca Schultz Zavin March 22, 2013, 3:08 a.m. UTC | #2
As one of my coworkers pointed out I meant for that to be:

struct ion_cma_heap {
        struct ion heap heap;
        struct device *dev;
}

So containerof actually works...

Rebecca
On Mar 21, 2013 3:59 PM, "Rebecca Schultz Zavin" <rebecca@android.com>
wrote:

> Rather than coping the private data into the heap, in several other heaps
> that have required private information, I've put the ion_heap struct inside
> another structure that also contained the private fields.  So you would
> have:
>
> struct ion_cma_heap {
>         struct ion_heap *heap;
>         struct device *dev;
>         .... other private data ...
> };
>
> Then you can retrieve the private data using container_of on the heap.
>  It's a little more verbose, but I think a lot more flexible.
>
> Rebecca
>
> On Wed, Mar 20, 2013 at 10:33 AM, Benjamin Gaignard <
> benjamin.gaignard@linaro.org> wrote:
>
>> copy private field from platform configuration to internal heap structure.
>>
>> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org>
>> ---
>>  drivers/gpu/ion/ion_heap.c |    1 +
>>  drivers/gpu/ion/ion_priv.h |    2 ++
>>  2 files changed, 3 insertions(+)
>>
>> diff --git a/drivers/gpu/ion/ion_heap.c b/drivers/gpu/ion/ion_heap.c
>> index 225ef94..3ec6357 100644
>> --- a/drivers/gpu/ion/ion_heap.c
>> +++ b/drivers/gpu/ion/ion_heap.c
>> @@ -162,6 +162,7 @@ struct ion_heap *ion_heap_create(struct
>> ion_platform_heap *heap_data)
>>
>>         heap->name = heap_data->name;
>>         heap->id = heap_data->id;
>> +       heap->priv = heap_data->priv;
>>         return heap;
>>  }
>>
>> diff --git a/drivers/gpu/ion/ion_priv.h b/drivers/gpu/ion/ion_priv.h
>> index 50568147..c79a942 100644
>> --- a/drivers/gpu/ion/ion_priv.h
>> +++ b/drivers/gpu/ion/ion_priv.h
>> @@ -132,6 +132,7 @@ struct ion_heap_ops {
>>   * @task:              task struct of deferred free thread
>>   * @debug_show:                called when heap debug file is read to
>> add any
>>   *                     heap specific debug info to output
>> + * @priv:              heap private data
>>   *
>>   * Represents a pool of memory from which buffers can be made.  In some
>>   * systems the only heap is regular system memory allocated via vmalloc.
>> @@ -151,6 +152,7 @@ struct ion_heap {
>>         wait_queue_head_t waitqueue;
>>         struct task_struct *task;
>>         int (*debug_show)(struct ion_heap *heap, struct seq_file *, void
>> *);
>> +       void *priv;
>>  };
>>
>>  /**
>> --
>> 1.7.10
>>
>>
>
diff mbox

Patch

diff --git a/drivers/gpu/ion/ion_heap.c b/drivers/gpu/ion/ion_heap.c
index 225ef94..3ec6357 100644
--- a/drivers/gpu/ion/ion_heap.c
+++ b/drivers/gpu/ion/ion_heap.c
@@ -162,6 +162,7 @@  struct ion_heap *ion_heap_create(struct ion_platform_heap *heap_data)
 
 	heap->name = heap_data->name;
 	heap->id = heap_data->id;
+	heap->priv = heap_data->priv;
 	return heap;
 }
 
diff --git a/drivers/gpu/ion/ion_priv.h b/drivers/gpu/ion/ion_priv.h
index 50568147..c79a942 100644
--- a/drivers/gpu/ion/ion_priv.h
+++ b/drivers/gpu/ion/ion_priv.h
@@ -132,6 +132,7 @@  struct ion_heap_ops {
  * @task:		task struct of deferred free thread
  * @debug_show:		called when heap debug file is read to add any
  *			heap specific debug info to output
+ * @priv:		heap private data
  *
  * Represents a pool of memory from which buffers can be made.  In some
  * systems the only heap is regular system memory allocated via vmalloc.
@@ -151,6 +152,7 @@  struct ion_heap {
 	wait_queue_head_t waitqueue;
 	struct task_struct *task;
 	int (*debug_show)(struct ion_heap *heap, struct seq_file *, void *);
+	void *priv;
 };
 
 /**