Skip to content

Commit 49ae46d

Browse files
committed
control-plane-agent: error if no persistent slot for host flash
1 parent a054bf6 commit 49ae46d

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

task/control-plane-agent/src/update/host_flash.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use super::{common::CurrentUpdate, ComponentUpdater};
66
use crate::mgs_handler::{BorrowedUpdateBuffer, UpdateBuffer};
77
use core::ops::Range;
88
use drv_hf_api::{
9-
HfDevSelect, HfError, HfPersistentData, HfProtectMode, HostFlash,
10-
PAGE_SIZE_BYTES, SECTOR_SIZE_BYTES,
9+
HfDevSelect, HfError, HfProtectMode, HostFlash, PAGE_SIZE_BYTES,
10+
SECTOR_SIZE_BYTES,
1111
};
1212
use gateway_messages::{
1313
ComponentUpdatePrepare, HfError as GwHfError, SpComponent, SpError,
@@ -82,15 +82,10 @@ impl HostFlashUpdate {
8282
}
8383

8484
pub(crate) fn persistent_slot(&self) -> Result<u16, SpError> {
85-
match self.task.get_persistent_data() {
86-
Ok(HfPersistentData { dev_select }) => {
87-
Ok(Self::dev_to_slot(dev_select))
88-
}
89-
// All boards today will default to slot 0 if no persistent data,
90-
// e.g. on initial power-on.
91-
Err(HfError::NoPersistentData) => Ok(0),
92-
Err(err) => Err(hf_to_gwhf(err)),
93-
}
85+
self.task
86+
.get_persistent_data()
87+
.map(|data| Self::dev_to_slot(data.dev_select))
88+
.map_err(hf_to_gwhf)
9489
}
9590

9691
fn dev_to_slot(dev: HfDevSelect) -> u16 {

0 commit comments

Comments
 (0)