From b5b7a21bb66da801baa4e00b7db856a9e4febf12 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 9 Aug 2016 13:54:57 -0600 Subject: [PATCH] Make reference count a uin16_t and save a couple of bytes. --- arch/arm/src/stm32/stm32_pwr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm/src/stm32/stm32_pwr.c b/arch/arm/src/stm32/stm32_pwr.c index 8fb749f767a..7973f2494dc 100644 --- a/arch/arm/src/stm32/stm32_pwr.c +++ b/arch/arm/src/stm32/stm32_pwr.c @@ -83,9 +83,9 @@ static inline void stm32_pwr_modifyreg(uint8_t offset, uint16_t clearbits, uint1 * Enables access to the backup domain (RTC registers, RTC backup data registers * and backup SRAM). * - * NOTE: Reference counting is used in order to supported nested calles to this + * NOTE: Reference counting is used in order to supported nested calls to this * function. As a consequence, every call to stm32_pwr_enablebkp(true) must - * be followed by a call to stm32_pwr_enablebkp(false). + * be followed by a matching call to stm32_pwr_enablebkp(false). * * Input Parameters: * writable - True: enable ability to write to backup domain registers @@ -97,7 +97,7 @@ static inline void stm32_pwr_modifyreg(uint8_t offset, uint16_t clearbits, uint1 void stm32_pwr_enablebkp(bool writable) { - static uint32_t writable_counter = 0; + static uint16_t writable_counter = 0; irqstate_t flags; uint16_t regval; bool waswritable; @@ -112,6 +112,7 @@ void stm32_pwr_enablebkp(bool writable) if (writable) { + DEBUGASSERT(writable_counter < UINT16_MAX); writable_counter++; } else if (writable_counter > 0)