From 516fc76f842c72fa898968e8d43bdbfb74d56cd5 Mon Sep 17 00:00:00 2001 From: Mateusz Holenko Date: Tue, 30 Jan 2024 18:47:31 +0100 Subject: [PATCH] drivers: eth_stm32_hal: Fix compilation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Promote clk_ratio_adj to double for internal calculations related to ratio to avoid compilation warnings related to implicit conversion from float to double. Signed-off-by: Mateusz HoĊ‚enko --- drivers/ethernet/eth_stm32_hal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/ethernet/eth_stm32_hal.c b/drivers/ethernet/eth_stm32_hal.c index 1808b59f23..b9d4c19186 100644 --- a/drivers/ethernet/eth_stm32_hal.c +++ b/drivers/ethernet/eth_stm32_hal.c @@ -1844,13 +1844,13 @@ static int ptp_clock_stm32_rate_adjust(const struct device *dev, double ratio) uint32_t addend_val; /* No change needed */ - if (ratio == 1.0f) { + if (ratio == 1.0L) { return 0; } key = irq_lock(); - ratio *= eth_dev_data->clk_ratio_adj; + ratio *= (double)eth_dev_data->clk_ratio_adj; /* Limit possible ratio */ if (ratio * 100 < CONFIG_ETH_STM32_HAL_PTP_CLOCK_ADJ_MIN_PCT || @@ -1863,7 +1863,7 @@ static int ptp_clock_stm32_rate_adjust(const struct device *dev, double ratio) eth_dev_data->clk_ratio_adj = ratio; /* Update addend register */ - addend_val = UINT32_MAX * eth_dev_data->clk_ratio * ratio; + addend_val = UINT32_MAX * (double)eth_dev_data->clk_ratio * ratio; #if defined(CONFIG_SOC_SERIES_STM32H7X) || defined(CONFIG_SOC_SERIES_STM32H5X) heth->Instance->MACTSAR = addend_val;