@@ -25,7 +25,6 @@ pub use sysfs_gpio;
2525#[ cfg( feature = "gpio_cdev" ) ]
2626pub use gpio_cdev;
2727
28-
2928use core:: convert:: Infallible ;
3029use std:: io:: { self , Write } ;
3130use std:: path:: { Path , PathBuf } ;
@@ -202,19 +201,19 @@ impl embedded_hal::blocking::i2c::WriteRead for I2cdev {
202201 buffer : & mut [ u8 ] ,
203202 ) -> Result < ( ) , Self :: Error > {
204203 self . set_address ( address) ?;
205- let mut messages = [
206- LinuxI2CMessage :: write ( bytes) ,
207- LinuxI2CMessage :: read ( buffer) ,
208- ] ;
204+ let mut messages = [ LinuxI2CMessage :: write ( bytes) , LinuxI2CMessage :: read ( buffer) ] ;
209205 self . inner . transfer ( & mut messages) . map ( drop)
210206 }
211207}
212208
213209impl embedded_hal:: blocking:: i2c:: Transactional for I2cdev {
214210 type Error = i2cdev:: linux:: LinuxI2CError ;
215211
216- fn try_exec ( & mut self , address : u8 , operations : & mut [ I2cOperation ] ) -> Result < ( ) , Self :: Error >
217- {
212+ fn try_exec (
213+ & mut self ,
214+ address : u8 ,
215+ operations : & mut [ I2cOperation ] ,
216+ ) -> Result < ( ) , Self :: Error > {
218217 // Map operations from generic to linux objects
219218 let mut messages: Vec < _ > = operations
220219 . as_mut ( )
@@ -280,30 +279,32 @@ impl embedded_hal::blocking::spi::Write<u8> for Spidev {
280279 }
281280}
282281
283- pub use embedded_hal:: blocking:: spi:: { Operation as SpiOperation } ;
282+ pub use embedded_hal:: blocking:: spi:: Operation as SpiOperation ;
284283
285284/// Transactional implementation batches SPI operations into a single transaction
286285impl embedded_hal:: blocking:: spi:: Transactional < u8 > for Spidev {
287286 type Error = io:: Error ;
288287
289288 fn try_exec < ' a > ( & mut self , operations : & mut [ SpiOperation < ' a , u8 > ] ) -> Result < ( ) , Self :: Error > {
290-
291289 // Map types from generic to linux objects
292- let mut messages: Vec < _ > = operations. iter_mut ( ) . map ( |a| {
293- match a {
294- SpiOperation :: Write ( w) => SpidevTransfer :: write ( w) ,
295- SpiOperation :: Transfer ( r) => {
296- // Clone read to write pointer
297- // SPIdev is okay with having w == r but this is tricky to achieve in safe rust
298- let w = unsafe {
299- let p = r. as_ptr ( ) ;
300- std:: slice:: from_raw_parts ( p, r. len ( ) )
301- } ;
302-
303- SpidevTransfer :: read_write ( w, r)
304- } ,
305- }
306- } ) . collect ( ) ;
290+ let mut messages: Vec < _ > = operations
291+ . iter_mut ( )
292+ . map ( |a| {
293+ match a {
294+ SpiOperation :: Write ( w) => SpidevTransfer :: write ( w) ,
295+ SpiOperation :: Transfer ( r) => {
296+ // Clone read to write pointer
297+ // SPIdev is okay with having w == r but this is tricky to achieve in safe rust
298+ let w = unsafe {
299+ let p = r. as_ptr ( ) ;
300+ std:: slice:: from_raw_parts ( p, r. len ( ) )
301+ } ;
302+
303+ SpidevTransfer :: read_write ( w, r)
304+ }
305+ }
306+ } )
307+ . collect ( ) ;
307308
308309 // Execute transfer
309310 self . 0 . transfer_multiple ( & mut messages)
0 commit comments