spi: spi-sh-msiof: round up div to fix freq calculation
authorTakashi Yoshii <takasi-y@ops.dti.ne.jp>
Sun, 1 Dec 2013 18:19:13 +0000 (03:19 +0900)
committerMark Brown <broonie@linaro.org>
Mon, 2 Dec 2013 12:48:05 +0000 (12:48 +0000)
Truncation on integer division in sh_msiof_spi_set_clk_regs()
results in insufficient transfer frequency (> max_speed_freq).

For example, source 52MHz, required max 6MHz
 52/6 = 8.6 --> 8, then 1/8 table selected,
and result in 52/8 = 6.5 MHz (>6MHz)

Rounding it up is a simple solution.
 52/6 = 8.6 --> 9, then 1/16 table selected,
and result in 52/16 = 3.25 MHz

Signed-off-by: Takashi Yoshii <takasi-y@ops.dti.ne.jp>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/spi/spi-sh-msiof.c

index c74298cf70e2406d8972f4fe75cc2fcd59a15864..ac8795f2e7009a96f517043520d261c32a6ad7b4 100644 (file)
@@ -152,7 +152,7 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
        size_t k;
 
        if (!WARN_ON(!spi_hz || !parent_rate))
-               div = parent_rate / spi_hz;
+               div = DIV_ROUND_UP(parent_rate, spi_hz);
 
        /* TODO: make more fine grained */
 
This page took 0.029015 seconds and 5 git commands to generate.