Skip to content

Commit

Permalink
spi: dw: round up result of calculation for clock divider
Browse files Browse the repository at this point in the history
Avoid ending up with a higher frequency than requested

Signed-off-by: Matthias Seidel <kernel@mseidel.net>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Matthias Seidel authored and Mark Brown committed Sep 12, 2016
1 parent 13b1030 commit 3aef463
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/spi/spi-dw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3aef463

Please sign in to comment.