aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2009-08-18 04:27:57 -0400
committerDave Airlie <airlied@linux.ie>2009-08-19 02:09:04 -0400
commite9840be8c23601285a70520b4898818f28ce8c2b (patch)
tree083a776b7c8b7517a22c2ab3682acaf7f91c9a11
parent327c225bd548bf7871f116a0baa5ebdac884e452 (diff)
drm/ttm: Add a virtual ttm sysfs device.
The device directory will be the base directory of the sysfs representation of other ttm subsystems. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Dave Airlie <airlied@linux.ie>
-rw-r--r--drivers/gpu/drm/ttm/ttm_module.c58
1 files changed, 57 insertions, 1 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_module.c b/drivers/gpu/drm/ttm/ttm_module.c
index 59ce8191d584..9a6edbfeaa9e 100644
--- a/drivers/gpu/drm/ttm/ttm_module.c
+++ b/drivers/gpu/drm/ttm/ttm_module.c
@@ -29,16 +29,72 @@
29 * Jerome Glisse 29 * Jerome Glisse
30 */ 30 */
31#include <linux/module.h> 31#include <linux/module.h>
32#include <ttm/ttm_module.h> 32#include <linux/device.h>
33#include <linux/sched.h>
34#include "ttm/ttm_module.h"
35#include "drm_sysfs.h"
36
37static DECLARE_WAIT_QUEUE_HEAD(exit_q);
38atomic_t device_released;
39
40static struct device_type ttm_drm_class_type = {
41 .name = "ttm",
42 /**
43 * Add pm ops here.
44 */
45};
46
47static void ttm_drm_class_device_release(struct device *dev)
48{
49 atomic_set(&device_released, 1);
50 wake_up_all(&exit_q);
51}
52
53static struct device ttm_drm_class_device = {
54 .type = &ttm_drm_class_type,
55 .release = &ttm_drm_class_device_release
56};
57
58struct kobject *ttm_get_kobj(void)
59{
60 struct kobject *kobj = &ttm_drm_class_device.kobj;
61 BUG_ON(kobj == NULL);
62 return kobj;
63}
33 64
34static int __init ttm_init(void) 65static int __init ttm_init(void)
35{ 66{
67 int ret;
68
69 ret = dev_set_name(&ttm_drm_class_device, "ttm");
70 if (unlikely(ret != 0))
71 return ret;
72
36 ttm_global_init(); 73 ttm_global_init();
74
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;
79
37 return 0; 80 return 0;
81out_no_dev_reg:
82 atomic_set(&device_released, 1);
83 wake_up_all(&exit_q);
84 ttm_global_release();
85 return ret;
38} 86}
39 87
40static void __exit ttm_exit(void) 88static void __exit ttm_exit(void)
41{ 89{
90 drm_class_device_unregister(&ttm_drm_class_device);
91
92 /**
93 * Refuse to unload until the TTM device is released.
94 * Not sure this is 100% needed.
95 */
96
97 wait_event(exit_q, atomic_read(&device_released) == 1);
42 ttm_global_release(); 98 ttm_global_release();
43} 99}
44 100