123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #include <linux/module.h>
- #include <linux/device.h>
- #include <linux/sched.h>
- #include <drm/ttm/ttm_module.h>
- #include <drm/drm_sysfs.h>
- static DECLARE_WAIT_QUEUE_HEAD(exit_q);
- static atomic_t device_released;
- static struct device_type ttm_drm_class_type = {
- .name = "ttm",
-
- };
- static void ttm_drm_class_device_release(struct device *dev)
- {
- atomic_set(&device_released, 1);
- wake_up_all(&exit_q);
- }
- static struct device ttm_drm_class_device = {
- .type = &ttm_drm_class_type,
- .release = &ttm_drm_class_device_release
- };
- struct kobject *ttm_get_kobj(void)
- {
- struct kobject *kobj = &ttm_drm_class_device.kobj;
- BUG_ON(kobj == NULL);
- return kobj;
- }
- static int __init ttm_init(void)
- {
- int ret;
- ret = dev_set_name(&ttm_drm_class_device, "ttm");
- if (unlikely(ret != 0))
- return ret;
- atomic_set(&device_released, 0);
- ret = drm_class_device_register(&ttm_drm_class_device);
- if (unlikely(ret != 0))
- goto out_no_dev_reg;
- return 0;
- out_no_dev_reg:
- atomic_set(&device_released, 1);
- wake_up_all(&exit_q);
- return ret;
- }
- static void __exit ttm_exit(void)
- {
- drm_class_device_unregister(&ttm_drm_class_device);
-
- wait_event(exit_q, atomic_read(&device_released) == 1);
- }
- module_init(ttm_init);
- module_exit(ttm_exit);
- MODULE_AUTHOR("Thomas Hellstrom, Jerome Glisse");
- MODULE_DESCRIPTION("TTM memory manager subsystem (for DRM device)");
- MODULE_LICENSE("GPL and additional rights");
|