Commit 9cc61973 authored by Amelie Delaunay's avatar Amelie Delaunay Committed by Mark Brown

spi: stm32: fix stm32_spi_prepare_mbr in case of odd clk_rate

Fix spi->clk_rate when it is odd to the nearest lowest even value because
minimum SPI divider is 2.
Signed-off-by: default avatarAmelie Delaunay <amelie.delaunay@st.com>
Signed-off-by: default avatarAlain Volmat <alain.volmat@st.com>
Link: https://lore.kernel.org/r/1597043558-29668-4-git-send-email-alain.volmat@st.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3373e900
...@@ -441,7 +441,8 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz, ...@@ -441,7 +441,8 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz,
{ {
u32 div, mbrdiv; u32 div, mbrdiv;
div = DIV_ROUND_UP(spi->clk_rate, speed_hz); /* Ensure spi->clk_rate is even */
div = DIV_ROUND_UP(spi->clk_rate & ~0x1, speed_hz);
/* /*
* SPI framework set xfer->speed_hz to master->max_speed_hz if * SPI framework set xfer->speed_hz to master->max_speed_hz if
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment