mgmt/MCUmgr/grp/img: Simplify img_mgmt_get_unused_slot_area_id
Simplified and made CONFIG_MCUMGR_GRP_IMG_UPDATABLE_IMAGE_NUMBER independent. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
This commit is contained in:
parent
58b22bc4a9
commit
fe08ed65c0
1 changed files with 8 additions and 6 deletions
|
@ -238,13 +238,15 @@ static int img_mgmt_get_unused_slot_area_id(int slot)
|
|||
static int img_mgmt_get_unused_slot_area_id(int image)
|
||||
{
|
||||
int area_id = -1;
|
||||
int slot = 0;
|
||||
|
||||
if (image == 0 || image == -1) {
|
||||
if (img_mgmt_slot_in_use(1) == 0) {
|
||||
area_id = img_mgmt_flash_area_id(1);
|
||||
}
|
||||
} else if (image == 1) {
|
||||
area_id = img_mgmt_flash_area_id(3);
|
||||
if (image == -1) {
|
||||
image = 0;
|
||||
}
|
||||
slot = img_mgmt_get_opposite_slot(img_mgmt_active_slot(image));
|
||||
|
||||
if (!img_mgmt_slot_in_use(slot)) {
|
||||
area_id = img_mgmt_flash_area_id(slot);
|
||||
}
|
||||
|
||||
return area_id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue