diff --git a/sys/include/riotboot/slot.h b/sys/include/riotboot/slot.h index 93a38b16f0..c08b6e27d4 100644 --- a/sys/include/riotboot/slot.h +++ b/sys/include/riotboot/slot.h @@ -104,6 +104,27 @@ size_t riotboot_slot_offset(unsigned slot); */ void riotboot_slot_dump_addrs(void); +/** + * @brief Get the size of a slot + * + * @param[in] slot slot nr to get the size from + * + * @returns The slot size in bytes + */ +static inline size_t riotboot_slot_size(unsigned slot) +{ + switch(slot) { + case 0: + return SLOT0_LEN; +#if NUM_SLOTS==2 + case 1: + return SLOT1_LEN; +#endif + default: + return 0; + } +} + /** * @brief Number of configured firmware slots (incl. bootloader slot) */ diff --git a/sys/riotboot/flashwrite.c b/sys/riotboot/flashwrite.c index f3f26b5b9f..e51cb341b8 100644 --- a/sys/riotboot/flashwrite.c +++ b/sys/riotboot/flashwrite.c @@ -34,15 +34,10 @@ static inline size_t min(size_t a, size_t b) return a <= b ? a : b; } -size_t riotboot_flashwrite_slotsize(const riotboot_flashwrite_t *state) +size_t riotboot_flashwrite_slotsize( + const riotboot_flashwrite_t *state) { - switch (state->target_slot) { - case 0: return SLOT0_LEN; -#if NUM_SLOTS==2 - case 1: return SLOT1_LEN; -#endif - default: return 0; - } + return riotboot_slot_size(state->target_slot); } int riotboot_flashwrite_init_raw(riotboot_flashwrite_t *state, int target_slot,