Skip to content

Commit

Permalink
drivers: stm32_iwdg: enable state helper functions
Browse files Browse the repository at this point in the history
Add iwdg_wdt_set_enabled() to register the watchdog is activated
and rename is_enable() to iwdg_wdt_is_enabled() for consistency.

Acked-by: Jerome Forissier <[email protected]>
Reviewed-by: Gatien Chevallier <[email protected]>
Signed-off-by: Etienne Carriere <[email protected]>
  • Loading branch information
etienne-lms committed Dec 21, 2023
1 parent 44ed75e commit 6caafe0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/drivers/stm32_iwdg.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ static bool is_assigned_to_nsec(struct stm32_iwdg_device *iwdg)
return iwdg->flags & IWDG_FLAGS_NON_SECURE;
}

static bool is_enable(struct stm32_iwdg_device *iwdg)
static void iwdg_wdt_set_enabled(struct stm32_iwdg_device *iwdg)
{
iwdg->flags |= IWDG_FLAGS_ENABLED;
}

static bool iwdg_wdt_is_enabled(struct stm32_iwdg_device *iwdg)
{
return iwdg->flags & IWDG_FLAGS_ENABLED;
}
Expand Down Expand Up @@ -144,7 +149,7 @@ static TEE_Result configure_timeout(struct stm32_iwdg_device *iwdg)
vaddr_t iwdg_base = get_base(iwdg);
uint32_t rlr_value = 0;

assert(is_enable(iwdg));
assert(iwdg_wdt_is_enabled(iwdg));

rlr_value = iwdg_timeout_cnt(iwdg, iwdg->timeout);
if (!rlr_value)
Expand All @@ -164,7 +169,7 @@ static void iwdg_start(struct stm32_iwdg_device *iwdg)
{
io_write32(get_base(iwdg) + IWDG_KR_OFFSET, IWDG_KR_START_KEY);

iwdg->flags |= IWDG_FLAGS_ENABLED;
iwdg_wdt_set_enabled(iwdg);
}

static void iwdg_refresh(struct stm32_iwdg_device *iwdg)
Expand Down Expand Up @@ -222,7 +227,7 @@ static TEE_Result iwdg_wdt_set_timeout(struct wdt_chip *chip,

iwdg->timeout = timeout;

if (is_enable(iwdg)) {
if (iwdg_wdt_is_enabled(iwdg)) {
TEE_Result res = TEE_ERROR_GENERIC;

res = configure_timeout(iwdg);
Expand Down

0 comments on commit 6caafe0

Please sign in to comment.