@@ -7,6 +7,7 @@ use crate::helpers::AlignedBuffer;
77use crate :: proto:: unsafe_protocol;
88use crate :: StatusExt ;
99use core:: alloc:: LayoutError ;
10+ use core:: marker:: PhantomData ;
1011use core:: ptr;
1112use uefi_raw:: protocol:: scsi:: {
1213 ExtScsiPassThruMode , ExtScsiPassThruProtocol , SCSI_TARGET_MAX_BYTES ,
@@ -121,8 +122,9 @@ impl ExtScsiPassThru {
121122/// You have to probe for availability before doing anything meaningful with it.
122123#[ derive( Clone , Debug ) ]
123124pub struct ScsiDevice < ' a > {
124- proto : & ' a ExtScsiPassThruProtocol ,
125+ proto : * const ExtScsiPassThruProtocol ,
125126 target_lun : ScsiTargetLun ,
127+ _phantom : PhantomData < & ' a ( ) >
126128}
127129impl ScsiDevice < ' _ > {
128130 /// Returns the SCSI target address of the potential device.
@@ -155,9 +157,9 @@ impl ScsiDevice<'_> {
155157 /// specified by `Target` and `Lun`.
156158 /// - [`Status::TIMEOUT`] A timeout occurred while attempting to reset the SCSI device specified
157159 /// by `Target` and `Lun`.
158- pub fn reset ( & self ) -> crate :: Result < ( ) > {
160+ pub fn reset ( & mut self ) -> crate :: Result < ( ) > {
159161 unsafe {
160- ( self . proto . reset_target_lun ) ( self . proto , self . target_lun . 0 . as_ptr ( ) , self . lun ( ) )
162+ ( ( * self . proto ) . reset_target_lun ) ( self . proto . cast_mut ( ) , self . target_lun . 0 . as_ptr ( ) , self . lun ( ) )
161163 . to_result ( )
162164 }
163165 }
@@ -196,12 +198,12 @@ impl ScsiDevice<'_> {
196198 /// - [`Status::TIMEOUT`] A timeout occurred while executing the SCSI Request Packet. Additional status
197199 /// information is available in `HostAdapterStatus`, `TargetStatus`, `SenseDataLength`, and `SenseData`.
198200 pub fn execute_command < ' req > (
199- & self ,
201+ & mut self ,
200202 mut scsi_req : ScsiRequest < ' req > ,
201203 ) -> crate :: Result < ScsiResponse < ' req > > {
202204 unsafe {
203- ( self . proto . pass_thru ) (
204- self . proto ,
205+ ( ( * self . proto ) . pass_thru ) (
206+ self . proto . cast_mut ( ) ,
205207 self . target_lun . 0 . as_ptr ( ) ,
206208 self . target_lun . 1 ,
207209 & mut scsi_req. packet ,
@@ -236,6 +238,7 @@ impl<'a> Iterator for ScsiTargetLunIterator<'a> {
236238 let scsi_device = ScsiDevice {
237239 proto : self . proto ,
238240 target_lun : self . prev . clone ( ) ,
241+ _phantom : Default :: default ( )
239242 } ;
240243 match result {
241244 Status :: SUCCESS => Some ( scsi_device) ,
0 commit comments