[PATCH 2/2] spi: dw: round up result of calculation for clock divider

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



avoid ending up with a higher frequency than requested

---
 drivers/spi/spi-dw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index c85e4b3..2fd517d 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -300,7 +300,8 @@ static int dw_spi_transfer_one(struct spi_master *master,
     if (transfer->speed_hz != dws->current_freq) {
         if (transfer->speed_hz != chip->speed_hz) {
             /* clk_div doesn't support odd number */
-            chip->clk_div = (dws->max_freq / transfer->speed_hz + 1) & 0xfffe;
+            chip->clk_div = ((dws->max_freq + transfer->speed_hz) /
+                transfer->speed_hz + 1) & 0xfffe;
             chip->speed_hz = transfer->speed_hz;
         }
         dws->current_freq = transfer->speed_hz;
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux