File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,25 @@ impl<T: drm::drv::Driver> Device<T> {
107107 Ok ( drm)
108108 }
109109
110+ /// Create a new `drm::device::Device` for a `drm::drv::Driver`.
111+ pub fn new_no_data ( dev : & device:: Device ) -> Result < ARef < Self > > {
112+ // SAFETY: `dev` is valid by its type invarants; `VTABLE`, as a `const` is pinned to the
113+ // read-only section of the compilation.
114+ let raw_drm = unsafe { bindings:: drm_dev_alloc ( & Self :: VTABLE , dev. as_raw ( ) ) } ;
115+ let raw_drm = NonNull :: new ( from_err_ptr ( raw_drm) ? as * mut _ ) . ok_or ( ENOMEM ) ?;
116+
117+ // SAFETY: The reference count is one, and now we take ownership of that reference as a
118+ // drm::device::Device.
119+ let drm = unsafe { ARef :: < Self > :: from_raw ( raw_drm) } ;
120+
121+ Ok ( drm)
122+ }
123+
124+ pub unsafe fn init_data ( & self , data : T :: Data ) {
125+ let data_ptr = <T :: Data as ForeignOwnable >:: into_foreign ( data) ;
126+ unsafe { self . set_raw_data ( data_ptr) } ;
127+ }
128+
110129 pub ( crate ) fn as_raw ( & self ) -> * mut bindings:: drm_device {
111130 self . 0 . get ( )
112131 }
You can’t perform that action at this time.
0 commit comments