Skip to content

Commit efd8ee4

Browse files
erwangocarlescufi
authored andcommitted
drivers/clock_control: stm32 common: Remove intermediate hclk variable
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC is the actual hclk freq (ie core clock); Remove use of intermediate new_hclk_freq to fix and simplify code. Signed-off-by: Erwan Gouriou <[email protected]>
1 parent 12a39df commit efd8ee4

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

drivers/clock_control/clock_stm32_ll_common.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -362,27 +362,22 @@ int stm32_clock_control_init(const struct device *dev)
362362

363363
ARG_UNUSED(dev);
364364

365-
366365
/* Some clocks would be activated by default */
367366
config_enable_default_clocks();
368367

369368
#if defined(FLASH_ACR_LATENCY)
370-
uint32_t new_hclk_freq;
371369
uint32_t old_flash_freq;
372370
uint32_t new_flash_freq;
373371

374372
old_flash_freq = RCC_CALC_FLASH_FREQ(HAL_RCC_GetSysClockFreq(),
375373
GET_CURRENT_FLASH_PRESCALER());
376374

377-
new_hclk_freq = get_bus_clock(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC,
378-
STM32_CORE_PRESCALER);
379-
380-
new_flash_freq = RCC_CALC_FLASH_FREQ(new_hclk_freq,
375+
new_flash_freq = RCC_CALC_FLASH_FREQ(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC,
381376
STM32_FLASH_PRESCALER);
382377

383378
/* If freq increases, set flash latency before any clock setting */
384-
if (new_flash_freq > old_flash_freq) {
385-
LL_SetFlashLatency(new_flash_freq);
379+
if (old_flash_freq < CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) {
380+
LL_SetFlashLatency(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC);
386381
}
387382
#endif /* FLASH_ACR_LATENCY */
388383

0 commit comments

Comments
 (0)