Skip to content

Commit e79e9da

Browse files
committed
Change verify() return type to match CMSIS
1 parent 3236188 commit e79e9da

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/lib.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,12 @@ 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+
/// Returns `address + size` on success, otherwise the first failing address.
7781
#[cfg(feature = "verify")]
78-
fn verify(&mut self, address: u32, size: u32, data: Option<&[u8]>) -> Result<(), ErrorCode>;
82+
fn verify(&mut self, address: u32, size: u32, data: Option<&[u8]>) -> u32;
7983

8084
/// Read flash.
8185
///
@@ -357,17 +361,10 @@ macro_rules! verify {
357361
};
358362

359363
if data.is_null() {
360-
match <$type as $crate::FlashAlgorithm>::verify(this, addr, size, None) {
361-
Ok(()) => 0,
362-
Err(e) => e.get(),
363-
}
364+
<$type as $crate::FlashAlgorithm>::verify(this, addr, size, None)
364365
} else {
365366
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(),
370-
}
367+
<$type as $crate::FlashAlgorithm>::verify(this, addr, size, Some(data_slice))
371368
}
372369
}
373370
};

0 commit comments

Comments
 (0)