File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -200,7 +200,10 @@ impl Device {
200200 /// `dev` must be an `Aref<device::Device>` whose underlying `bindings::device` is a member of a
201201 /// `bindings::platform_device`.
202202 unsafe fn from_dev ( dev : ARef < device:: Device > ) -> Self {
203- Self ( dev, 0 )
203+ Self {
204+ dev,
205+ used_resource : 0 ,
206+ }
204207 }
205208
206209 fn as_dev ( & self ) -> & device:: Device {
@@ -216,7 +219,7 @@ impl Device {
216219 /// Gets a system resources of a platform device.
217220 pub fn get_resource ( & mut self , rtype : IoResource , num : usize ) -> Result < Resource > {
218221 // SAFETY: `self.ptr` is valid by the type invariant.
219- let res = unsafe { bindings:: platform_get_resource ( self . ptr , rtype as _ , num as _ ) } ;
222+ let res = unsafe { bindings:: platform_get_resource ( self . as_raw ( ) , rtype as _ , num as _ ) } ;
220223 if res. is_null ( ) {
221224 return Err ( EINVAL ) ;
222225 }
@@ -226,7 +229,7 @@ impl Device {
226229 // - `self.ptr` is valid by the type invariant.
227230 // - `res` is a displaced pointer to one of the array's elements,
228231 // and `resource` is its base pointer.
229- let index = unsafe { res. offset_from ( ( * self . ptr ) . resource ) } as usize ;
232+ let index = unsafe { res. offset_from ( ( * self . as_raw ( ) ) . resource ) } as usize ;
230233
231234 // Make sure that the index does not exceed the 64-bit mask.
232235 assert ! ( index < 64 ) ;
You can’t perform that action at this time.
0 commit comments