@@ -30,11 +30,11 @@ pub enum PdPort {
3030
3131impl PdPort {
3232 /// SMBUS/I2C Address
33- fn i2c_address ( & self ) -> u16 {
33+ fn i2c_address ( & self ) -> EcResult < u16 > {
3434 let config = Config :: get ( ) ;
3535 let platform = & ( * config) . as_ref ( ) . unwrap ( ) . platform ;
3636
37- match ( platform, self ) {
37+ Ok ( match ( platform, self ) {
3838 ( Platform :: GenericFramework ( ( left, _) , _) , PdPort :: Left01 ) => * left,
3939 ( Platform :: GenericFramework ( ( _, right) , _) , PdPort :: Right23 ) => * right,
4040 // Framework AMD Platforms (CCG8)
@@ -52,10 +52,13 @@ impl PdPort {
5252 ) => 0x40 ,
5353 // TODO: It only has a single PD controller
5454 ( Platform :: FrameworkDesktopAmdAiMax300 , _) => 0x08 ,
55+ ( Platform :: UnknownSystem , _) => {
56+ Err ( EcError :: DeviceError ( "Unsupported platform" . to_string ( ) ) ) ?
57+ }
5558 // Framework Intel Platforms (CCG5 and CCG6)
5659 ( _, PdPort :: Left01 ) => 0x08 ,
5760 ( _, PdPort :: Right23 ) => 0x40 ,
58- }
61+ } )
5962 }
6063
6164 /// I2C port on the EC
@@ -87,10 +90,9 @@ impl PdPort {
8790 ) => 2 ,
8891 // TODO: It only has a single PD controller
8992 ( Platform :: FrameworkDesktopAmdAiMax300 , _) => 1 ,
90- // (_, _) => Err(EcError::DeviceError(format!(
91- // "Unsupported platform: {:?} {:?}",
92- // platform, self
93- // )))?,
93+ ( Platform :: UnknownSystem , _) => {
94+ Err ( EcError :: DeviceError ( "Unsupported platform" . to_string ( ) ) ) ?
95+ }
9496 } )
9597 }
9698}
@@ -140,13 +142,13 @@ impl PdController {
140142 fn i2c_read ( & self , addr : u16 , len : u16 ) -> EcResult < EcI2cPassthruResponse > {
141143 trace ! (
142144 "I2C passthrough from I2C Port {} to I2C Addr {}" ,
143- self . port. i2c_port( ) . unwrap ( ) ,
144- self . port. i2c_address( )
145+ self . port. i2c_port( ) ? ,
146+ self . port. i2c_address( ) ?
145147 ) ;
146148 i2c_read (
147149 & self . ec ,
148- self . port . i2c_port ( ) . unwrap ( ) ,
149- self . port . i2c_address ( ) ,
150+ self . port . i2c_port ( ) ? ,
151+ self . port . i2c_address ( ) ? ,
150152 addr,
151153 len,
152154 )
0 commit comments