diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /drivers/gpu/ion/ion_heap.c | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'drivers/gpu/ion/ion_heap.c')
-rw-r--r-- | drivers/gpu/ion/ion_heap.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/drivers/gpu/ion/ion_heap.c b/drivers/gpu/ion/ion_heap.c new file mode 100644 index 00000000000..6d09778745c --- /dev/null +++ b/drivers/gpu/ion/ion_heap.c | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | * drivers/gpu/ion/ion_heap.c | ||
3 | * | ||
4 | * Copyright (C) 2011 Google, Inc. | ||
5 | * | ||
6 | * This software is licensed under the terms of the GNU General Public | ||
7 | * License version 2, as published by the Free Software Foundation, and | ||
8 | * may be copied, distributed, and modified under those terms. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #include <linux/err.h> | ||
18 | #include <linux/ion.h> | ||
19 | #include "ion_priv.h" | ||
20 | |||
21 | struct ion_heap *ion_heap_create(struct ion_platform_heap *heap_data) | ||
22 | { | ||
23 | struct ion_heap *heap = NULL; | ||
24 | |||
25 | switch (heap_data->type) { | ||
26 | case ION_HEAP_TYPE_SYSTEM_CONTIG: | ||
27 | heap = ion_system_contig_heap_create(heap_data); | ||
28 | break; | ||
29 | case ION_HEAP_TYPE_SYSTEM: | ||
30 | heap = ion_system_heap_create(heap_data); | ||
31 | break; | ||
32 | case ION_HEAP_TYPE_CARVEOUT: | ||
33 | heap = ion_carveout_heap_create(heap_data); | ||
34 | break; | ||
35 | case ION_HEAP_TYPE_IOMMU: | ||
36 | heap = ion_iommu_heap_create(heap_data); | ||
37 | break; | ||
38 | default: | ||
39 | pr_err("%s: Invalid heap type %d\n", __func__, | ||
40 | heap_data->type); | ||
41 | return ERR_PTR(-EINVAL); | ||
42 | } | ||
43 | |||
44 | if (IS_ERR_OR_NULL(heap)) { | ||
45 | pr_err("%s: error creating heap %s type %d base %lu size %u\n", | ||
46 | __func__, heap_data->name, heap_data->type, | ||
47 | heap_data->base, heap_data->size); | ||
48 | return ERR_PTR(-EINVAL); | ||
49 | } | ||
50 | |||
51 | heap->name = heap_data->name; | ||
52 | heap->id = heap_data->id; | ||
53 | return heap; | ||
54 | } | ||
55 | |||
56 | void ion_heap_destroy(struct ion_heap *heap) | ||
57 | { | ||
58 | if (!heap) | ||
59 | return; | ||
60 | |||
61 | switch (heap->type) { | ||
62 | case ION_HEAP_TYPE_SYSTEM_CONTIG: | ||
63 | ion_system_contig_heap_destroy(heap); | ||
64 | break; | ||
65 | case ION_HEAP_TYPE_SYSTEM: | ||
66 | ion_system_heap_destroy(heap); | ||
67 | break; | ||
68 | case ION_HEAP_TYPE_CARVEOUT: | ||
69 | ion_carveout_heap_destroy(heap); | ||
70 | break; | ||
71 | case ION_HEAP_TYPE_IOMMU: | ||
72 | ion_iommu_heap_destroy(heap); | ||
73 | break; | ||
74 | default: | ||
75 | pr_err("%s: Invalid heap type %d\n", __func__, | ||
76 | heap->type); | ||
77 | } | ||
78 | } | ||