File tree Expand file tree Collapse file tree 2 files changed +49
-3
lines changed
Expand file tree Collapse file tree 2 files changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -130,11 +130,15 @@ impl TwoWirePort {
130130 mvpdfreq : nvme:: mi:: SmbusFrequency :: FreqNotSupported ,
131131 cmeaddr : 0x1d ,
132132 i3csprt : false ,
133- msmbfreq : nvme:: mi:: SmbusFrequency :: Freq400Khz ,
133+ msmbfreq : nvme:: mi:: SmbusFrequency :: Freq100Khz ,
134134 nvmebms : false ,
135135 smbfreq : nvme:: mi:: SmbusFrequency :: Freq100Khz ,
136136 }
137137 }
138+
139+ pub fn builder ( ) -> TwoWirePortBuilder {
140+ Default :: default ( )
141+ }
138142}
139143
140144impl Default for TwoWirePort {
@@ -143,6 +147,36 @@ impl Default for TwoWirePort {
143147 }
144148}
145149
150+ pub struct TwoWirePortBuilder {
151+ msmbfreq : nvme:: mi:: SmbusFrequency ,
152+ }
153+
154+ impl TwoWirePortBuilder {
155+ pub fn new ( ) -> Self {
156+ Self {
157+ msmbfreq : nvme:: mi:: SmbusFrequency :: Freq100Khz ,
158+ }
159+ }
160+
161+ pub fn msmbfreq ( & mut self , freq : nvme:: mi:: SmbusFrequency ) -> & mut Self {
162+ self . msmbfreq = freq;
163+ self
164+ }
165+
166+ pub fn build ( & self ) -> TwoWirePort {
167+ TwoWirePort {
168+ msmbfreq : self . msmbfreq ,
169+ ..Default :: default ( )
170+ }
171+ }
172+ }
173+
174+ impl Default for TwoWirePortBuilder {
175+ fn default ( ) -> Self {
176+ Self :: new ( )
177+ }
178+ }
179+
146180#[ derive( Debug , PartialEq , Eq ) ]
147181#[ repr( u8 ) ]
148182pub enum PortType {
Original file line number Diff line number Diff line change @@ -221,7 +221,13 @@ mod read_nvme_mi_data_structure {
221221 fn port_information_twowire ( ) {
222222 setup ( ) ;
223223
224- let ( mut mep, mut subsys) = new_device ( DeviceType :: P1p1tC1iN0a0a ) ;
224+ let mut subsys = Subsystem :: new ( SubsystemInfo :: invalid ( ) ) ;
225+ let _ = subsys. add_port ( PortType :: Pcie ( PciePort :: new ( ) ) ) . unwrap ( ) ;
226+ let twp = TwoWirePort :: builder ( )
227+ . msmbfreq ( nvme_mi_dev:: nvme:: mi:: SmbusFrequency :: Freq400Khz )
228+ . build ( ) ;
229+ let twpid = subsys. add_port ( PortType :: TwoWire ( twp) ) . unwrap ( ) ;
230+ let mut mep = ManagementEndpoint :: new ( twpid) ;
225231
226232 #[ rustfmt:: skip]
227233 const REQ : [ u8 ; 19 ] = [
@@ -1272,7 +1278,13 @@ mod configuration_set {
12721278 fn smbus_i2c_frequency_supported ( ) {
12731279 setup ( ) ;
12741280
1275- let ( mut mep, mut subsys) = new_device ( DeviceType :: P1p1tC1iN0a0a ) ;
1281+ let mut subsys = Subsystem :: new ( SubsystemInfo :: invalid ( ) ) ;
1282+ let _ = subsys. add_port ( PortType :: Pcie ( PciePort :: new ( ) ) ) . unwrap ( ) ;
1283+ let twp = TwoWirePort :: builder ( )
1284+ . msmbfreq ( nvme_mi_dev:: nvme:: mi:: SmbusFrequency :: Freq400Khz )
1285+ . build ( ) ;
1286+ let twpid = subsys. add_port ( PortType :: TwoWire ( twp) ) . unwrap ( ) ;
1287+ let mut mep = ManagementEndpoint :: new ( twpid) ;
12761288
12771289 #[ rustfmt:: skip]
12781290 const REQ_GET_INIT : [ u8 ; 19 ] = [
You can’t perform that action at this time.
0 commit comments