提交 3aef4632 编写于 作者: M Matthias Seidel 提交者: Mark Brown

spi: dw: round up result of calculation for clock divider

Avoid ending up with a higher frequency than requested
Signed-off-by: NMatthias Seidel <kernel@mseidel.net>
Signed-off-by: NMark Brown <broonie@kernel.org>
上级 13b10301
......@@ -300,7 +300,7 @@ 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 = (DIV_ROUND_UP(dws->max_freq, transfer->speed_hz) + 1) & 0xfffe;
chip->speed_hz = transfer->speed_hz;
}
dws->current_freq = transfer->speed_hz;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册