Version:  2.0.40 2.2.26 2.4.37 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.16

Linux/drivers/staging/android/ion/tegra/tegra_ion.c

  1 /*
  2  * drivers/gpu/tegra/tegra_ion.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/platform_device.h>
 19 #include <linux/slab.h>
 20 #include "../ion.h"
 21 #include "../ion_priv.h"
 22 
 23 static struct ion_device *idev;
 24 static int num_heaps;
 25 static struct ion_heap **heaps;
 26 
 27 static int tegra_ion_probe(struct platform_device *pdev)
 28 {
 29         struct ion_platform_data *pdata = pdev->dev.platform_data;
 30         int err;
 31         int i;
 32 
 33         num_heaps = pdata->nr;
 34 
 35         heaps = devm_kzalloc(&pdev->dev,
 36                              sizeof(struct ion_heap *) * pdata->nr,
 37                              GFP_KERNEL);
 38 
 39         idev = ion_device_create(NULL);
 40         if (IS_ERR_OR_NULL(idev))
 41                 return PTR_ERR(idev);
 42 
 43         /* create the heaps as specified in the board file */
 44         for (i = 0; i < num_heaps; i++) {
 45                 struct ion_platform_heap *heap_data = &pdata->heaps[i];
 46 
 47                 heaps[i] = ion_heap_create(heap_data);
 48                 if (IS_ERR_OR_NULL(heaps[i])) {
 49                         err = PTR_ERR(heaps[i]);
 50                         goto err;
 51                 }
 52                 ion_device_add_heap(idev, heaps[i]);
 53         }
 54         platform_set_drvdata(pdev, idev);
 55         return 0;
 56 err:
 57         for (i = 0; i < num_heaps; i++) {
 58                 if (heaps[i])
 59                         ion_heap_destroy(heaps[i]);
 60         }
 61         return err;
 62 }
 63 
 64 static int tegra_ion_remove(struct platform_device *pdev)
 65 {
 66         struct ion_device *idev = platform_get_drvdata(pdev);
 67         int i;
 68 
 69         ion_device_destroy(idev);
 70         for (i = 0; i < num_heaps; i++)
 71                 ion_heap_destroy(heaps[i]);
 72         return 0;
 73 }
 74 
 75 static struct platform_driver ion_driver = {
 76         .probe = tegra_ion_probe,
 77         .remove = tegra_ion_remove,
 78         .driver = { .name = "ion-tegra" }
 79 };
 80 
 81 module_platform_driver(ion_driver);
 82 
 83 

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us