Thread (8 messages) 8 messages, 3 authors, 2020-09-14
STALE2093d LANDED
Revisions (2)
  1. v1 [diff vs current]
  2. v2 current

[PATCH v2 3/5] spi: stm32: fix stm32_spi_prepare_mbr in case of odd clk_rate

From: Alain Volmat <hidden>
Date: 2020-08-10 07:13:08
Also in: linux-spi, lkml
Subsystem: spi subsystem, st stm32 spi driver, the rest · Maintainers: Mark Brown, Alain Volmat, Linus Torvalds

From: Amelie Delaunay <redacted>

Fix spi->clk_rate when it is odd to the nearest lowest even value because
minimum SPI divider is 2.

Signed-off-by: Amelie Delaunay <redacted>
Signed-off-by: Alain Volmat <redacted>
---
v2: identical to v1

 drivers/spi/spi-stm32.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index e5450233f3f8..571dea72bf7e 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -441,7 +441,8 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz,
 {
 	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
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help