This source file includes following definitions.
- ttm_drm_class_device_release
- ttm_get_kobj
- ttm_init
- ttm_exit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 #include <linux/module.h>
33 #include <linux/device.h>
34 #include <linux/sched.h>
35 #include <drm/ttm/ttm_module.h>
36 #include <drm/drm_sysfs.h>
37
38 static DECLARE_WAIT_QUEUE_HEAD(exit_q);
39 static atomic_t device_released;
40
41 static struct device_type ttm_drm_class_type = {
42 .name = "ttm",
43
44
45
46 };
47
48 static void ttm_drm_class_device_release(struct device *dev)
49 {
50 atomic_set(&device_released, 1);
51 wake_up_all(&exit_q);
52 }
53
54 static struct device ttm_drm_class_device = {
55 .type = &ttm_drm_class_type,
56 .release = &ttm_drm_class_device_release
57 };
58
59 struct kobject *ttm_get_kobj(void)
60 {
61 struct kobject *kobj = &ttm_drm_class_device.kobj;
62 BUG_ON(kobj == NULL);
63 return kobj;
64 }
65
66 static int __init ttm_init(void)
67 {
68 int ret;
69
70 ret = dev_set_name(&ttm_drm_class_device, "ttm");
71 if (unlikely(ret != 0))
72 return ret;
73
74 atomic_set(&device_released, 0);
75 ret = drm_class_device_register(&ttm_drm_class_device);
76 if (unlikely(ret != 0))
77 goto out_no_dev_reg;
78
79 return 0;
80 out_no_dev_reg:
81 atomic_set(&device_released, 1);
82 wake_up_all(&exit_q);
83 return ret;
84 }
85
86 static void __exit ttm_exit(void)
87 {
88 drm_class_device_unregister(&ttm_drm_class_device);
89
90
91
92
93
94
95 wait_event(exit_q, atomic_read(&device_released) == 1);
96 }
97
98 module_init(ttm_init);
99 module_exit(ttm_exit);
100
101 MODULE_AUTHOR("Thomas Hellstrom, Jerome Glisse");
102 MODULE_DESCRIPTION("TTM memory manager subsystem (for DRM device)");
103 MODULE_LICENSE("GPL and additional rights");