From 92a741c2ae2f200880a20e371916ca7146fc6b41 Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Fri, 25 Mar 2022 12:05:08 +0100 Subject: [PATCH] drivers/clock_control: stm32: style edits on set_up_fixed_clock_sources() Review code style in set_up_fixed_clock_sources() for better readability. Use of 'if (IS_ENABLED(STM32_MSI_ENABLED))' inside '#if STM32_MSI_ENABLED' is redundant but intentional as it is in line with remaining part of the function (HSE/HSI cases). Signed-off-by: Erwan Gouriou --- drivers/clock_control/clock_stm32_ll_common.c | 84 ++++++++++--------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/drivers/clock_control/clock_stm32_ll_common.c b/drivers/clock_control/clock_stm32_ll_common.c index c5cb568072c..f16322bde62 100644 --- a/drivers/clock_control/clock_stm32_ll_common.c +++ b/drivers/clock_control/clock_stm32_ll_common.c @@ -386,64 +386,66 @@ static int set_up_plls(void) static void set_up_fixed_clock_sources(void) { -#if STM32_HSE_ENABLED -#ifdef CONFIG_SOC_SERIES_STM32WLX - if (IS_ENABLED(STM32_HSE_TCXO)) { + if (IS_ENABLED(STM32_HSE_ENABLED)) { +#if defined(STM32_HSE_BYPASS) + /* Check if need to enable HSE bypass feature or not */ + if (IS_ENABLED(STM32_HSE_BYPASS)) { + LL_RCC_HSE_EnableBypass(); + } else { + LL_RCC_HSE_DisableBypass(); + } +#endif +#if STM32_HSE_TCXO LL_RCC_HSE_EnableTcxo(); - } -#elif !defined(CONFIG_SOC_SERIES_STM32WBX) - /* Check if need to enable HSE bypass feature or not */ - if (IS_ENABLED(STM32_HSE_BYPASS)) { - LL_RCC_HSE_EnableBypass(); - } else { - LL_RCC_HSE_DisableBypass(); - } #endif #if STM32_HSE_DIV2 - LL_RCC_HSE_EnableDiv2(); + LL_RCC_HSE_EnableDiv2(); #endif - /* Enable HSE */ - LL_RCC_HSE_Enable(); - while (LL_RCC_HSE_IsReady() != 1) { - /* Wait for HSE ready */ - } -#endif /* STM32_HSE_ENABLED */ - -#if STM32_HSI_ENABLED - /* Enable HSI if not enabled */ - if (LL_RCC_HSI_IsReady() != 1) { - /* Enable HSI */ - LL_RCC_HSI_Enable(); - while (LL_RCC_HSI_IsReady() != 1) { - /* Wait for HSI ready */ + /* Enable HSE */ + LL_RCC_HSE_Enable(); + while (LL_RCC_HSE_IsReady() != 1) { + /* Wait for HSE ready */ } } -#endif /* STM32_HSI_ENABLED */ -#if STM32_MSI_ENABLED - /* Set MSI Range */ + if (IS_ENABLED(STM32_HSI_ENABLED)) { + /* Enable HSI if not enabled */ + if (LL_RCC_HSI_IsReady() != 1) { + /* Enable HSI */ + LL_RCC_HSI_Enable(); + while (LL_RCC_HSI_IsReady() != 1) { + /* Wait for HSI ready */ + } + } + } + +#if defined(STM32_MSI_ENABLED) + if (IS_ENABLED(STM32_MSI_ENABLED)) { + /* Set MSI Range */ #if defined(RCC_CR_MSIRGSEL) - LL_RCC_MSI_EnableRangeSelection(); + LL_RCC_MSI_EnableRangeSelection(); #endif /* RCC_CR_MSIRGSEL */ #if defined(CONFIG_SOC_SERIES_STM32L0X) || defined(CONFIG_SOC_SERIES_STM32L1X) - LL_RCC_MSI_SetRange(STM32_MSI_RANGE << RCC_ICSCR_MSIRANGE_Pos); + LL_RCC_MSI_SetRange(STM32_MSI_RANGE << RCC_ICSCR_MSIRANGE_Pos); #else - LL_RCC_MSI_SetRange(STM32_MSI_RANGE << RCC_CR_MSIRANGE_Pos); + LL_RCC_MSI_SetRange(STM32_MSI_RANGE << RCC_CR_MSIRANGE_Pos); #endif /* CONFIG_SOC_SERIES_STM32L0X || CONFIG_SOC_SERIES_STM32L1X */ #if STM32_MSI_PLL_MODE - /* Enable MSI hardware auto calibration */ - LL_RCC_MSI_EnablePLLMode(); + /* Enable MSI hardware auto calibration */ + LL_RCC_MSI_EnablePLLMode(); #endif - LL_RCC_MSI_SetCalibTrimming(0); - /* Enable MSI if not enabled */ - if (LL_RCC_MSI_IsReady() != 1) { - /* Enable MSI */ - LL_RCC_MSI_Enable(); - while (LL_RCC_MSI_IsReady() != 1) { - /* Wait for MSI ready */ + LL_RCC_MSI_SetCalibTrimming(0); + + /* Enable MSI if not enabled */ + if (LL_RCC_MSI_IsReady() != 1) { + /* Enable MSI */ + LL_RCC_MSI_Enable(); + while (LL_RCC_MSI_IsReady() != 1) { + /* Wait for MSI ready */ + } } } #endif /* STM32_MSI_ENABLED */