2 * drivers/gpu/ion/ion_dummy_driver.c
4 * Copyright (C) 2013 Linaro, Inc
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.
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.
17 #include <linux/err.h>
18 #include <linux/platform_device.h>
19 #include <linux/slab.h>
20 #include <linux/bootmem.h>
21 #include <linux/memblock.h>
22 #include <linux/sizes.h>
26 struct ion_device *idev;
27 struct ion_heap **heaps;
29 struct ion_platform_heap dummy_heaps[] = {
31 .id = ION_HEAP_TYPE_SYSTEM,
32 .type = ION_HEAP_TYPE_SYSTEM,
36 .id = ION_HEAP_TYPE_SYSTEM_CONTIG,
37 .type = ION_HEAP_TYPE_SYSTEM_CONTIG,
38 .name = "system contig",
42 struct ion_platform_data dummy_ion_pdata = {
47 static int __init ion_dummy_init(void)
51 idev = ion_device_create(NULL);
52 heaps = kzalloc(sizeof(struct ion_heap *) * dummy_ion_pdata.nr,
55 return PTR_ERR(heaps);
57 for (i = 0; i < dummy_ion_pdata.nr; i++) {
58 struct ion_platform_heap *heap_data = &dummy_ion_pdata.heaps[i];
60 heaps[i] = ion_heap_create(heap_data);
61 if (IS_ERR_OR_NULL(heaps[i])) {
62 err = PTR_ERR(heaps[i]);
65 ion_device_add_heap(idev, heaps[i]);
69 for (i = 0; i < dummy_ion_pdata.nr; i++) {
71 ion_heap_destroy(heaps[i]);
78 static void __exit ion_dummy_exit(void)
82 ion_device_destroy(idev);
84 for (i = 0; i < dummy_ion_pdata.nr; i++)
85 ion_heap_destroy(heaps[i]);
91 module_init(ion_dummy_init);
92 module_exit(ion_dummy_exit);