Staging: netwave: delete the driver
[linux/fpc-iii.git] / drivers / gpu / drm / ttm / ttm_module.c
blob9a6edbfeaa9e49c7369623dbb542eb61204fe904
1 /**************************************************************************
3 * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
4 * All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 * USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
29 * Jerome Glisse
31 #include <linux/module.h>
32 #include <linux/device.h>
33 #include <linux/sched.h>
34 #include "ttm/ttm_module.h"
35 #include "drm_sysfs.h"
37 static DECLARE_WAIT_QUEUE_HEAD(exit_q);
38 atomic_t device_released;
40 static struct device_type ttm_drm_class_type = {
41 .name = "ttm",
42 /**
43 * Add pm ops here.
47 static void ttm_drm_class_device_release(struct device *dev)
49 atomic_set(&device_released, 1);
50 wake_up_all(&exit_q);
53 static struct device ttm_drm_class_device = {
54 .type = &ttm_drm_class_type,
55 .release = &ttm_drm_class_device_release
58 struct kobject *ttm_get_kobj(void)
60 struct kobject *kobj = &ttm_drm_class_device.kobj;
61 BUG_ON(kobj == NULL);
62 return kobj;
65 static int __init ttm_init(void)
67 int ret;
69 ret = dev_set_name(&ttm_drm_class_device, "ttm");
70 if (unlikely(ret != 0))
71 return ret;
73 ttm_global_init();
75 atomic_set(&device_released, 0);
76 ret = drm_class_device_register(&ttm_drm_class_device);
77 if (unlikely(ret != 0))
78 goto out_no_dev_reg;
80 return 0;
81 out_no_dev_reg:
82 atomic_set(&device_released, 1);
83 wake_up_all(&exit_q);
84 ttm_global_release();
85 return ret;
88 static void __exit ttm_exit(void)
90 drm_class_device_unregister(&ttm_drm_class_device);
92 /**
93 * Refuse to unload until the TTM device is released.
94 * Not sure this is 100% needed.
97 wait_event(exit_q, atomic_read(&device_released) == 1);
98 ttm_global_release();
101 module_init(ttm_init);
102 module_exit(ttm_exit);
104 MODULE_AUTHOR("Thomas Hellstrom, Jerome Glisse");
105 MODULE_DESCRIPTION("TTM memory manager subsystem (for DRM device)");
106 MODULE_LICENSE("GPL and additional rights");