File tree 1 file changed +3
-3
lines changed
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -301,15 +301,15 @@ impl<'a> I2CTransfer<'a> for LinuxI2CDevice {
301
301
/// Issue the provided sequence of I2C transactions
302
302
fn transfer ( & mut self , messages : & ' a mut [ Self :: Message ] ) -> Result < u32 , LinuxI2CError > {
303
303
let msg_type = |flag : u16 | flag & I2CMessageFlags :: READ . bits ( ) ;
304
- let mut prev_msg_type = ! msg_type ( messages [ 0 ] . flags ) ;
304
+ let mut prev_msg_type = messages . first ( ) . map ( |m| msg_type ( m . flags ) ) ;
305
305
for msg in messages. iter_mut ( ) {
306
306
msg. addr = self . slave_address ;
307
307
308
308
let cur_msg_type = msg_type ( msg. flags ) ;
309
- if prev_msg_type == cur_msg_type {
309
+ if prev_msg_type. is_some_and ( |prev| prev == cur_msg_type) {
310
310
msg. flags |= I2CMessageFlags :: NO_START . bits ( ) ;
311
311
} else {
312
- prev_msg_type = cur_msg_type;
312
+ prev_msg_type = Some ( cur_msg_type) ;
313
313
}
314
314
}
315
315
ffi:: i2c_rdwr ( self . as_raw_fd ( ) , messages) . map_err ( From :: from)
You can’t perform that action at this time.
0 commit comments