@@ -74,8 +74,13 @@ pub trait FlashAlgorithm: Sized + 'static {
7474 /// * `address` - The start address of the flash to verify.
7575 /// * `size` - The length of the data to verify.
7676 /// * `data` - The data to compare with.
77+ ///
78+ /// # Return
79+ ///
80+ /// Return `Ok(())` on success, otherwise the first failing address as an error,
81+ /// which must be less than `address + size`.
7782 #[ cfg( feature = "verify" ) ]
78- fn verify ( & mut self , address : u32 , size : u32 , data : Option < & [ u8 ] > ) -> Result < ( ) , ErrorCode > ;
83+ fn verify ( & mut self , address : u32 , size : u32 , data : Option < & [ u8 ] > ) -> Result < ( ) , u32 > ;
7984
8085 /// Read flash.
8186 ///
@@ -358,15 +363,14 @@ macro_rules! verify {
358363
359364 if data. is_null( ) {
360365 match <$type as $crate:: FlashAlgorithm >:: verify( this, addr, size, None ) {
361- Ok ( ( ) ) => 0 ,
362- Err ( e) => e. get ( ) ,
366+ Ok ( ( ) ) => addr . wrapping_add ( size ) ,
367+ Err ( e) => e,
363368 }
364369 } else {
365370 let data_slice: & [ u8 ] = unsafe { core:: slice:: from_raw_parts( data, size as usize ) } ;
366- match <$type as $crate:: FlashAlgorithm >:: verify( this, addr, size, Some ( data_slice) )
367- {
368- Ok ( ( ) ) => 0 ,
369- Err ( e) => e. get( ) ,
371+ match <$type as $crate:: FlashAlgorithm >:: verify( this, addr, size, Some ( data_slice) ) {
372+ Ok ( ( ) ) => addr. wrapping_add( size) ,
373+ Err ( e) => e,
370374 }
371375 }
372376 }
0 commit comments