Skip to content
Snippets Groups Projects
Commit 327b5c9f authored by Axel Lin's avatar Axel Lin Committed by Sonic Zhang
Browse files

spi: bfin_spi: Use DIV_ROUND_UP instead of open-coded


Use DIV_ROUND_UP to simplify the code.

Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Signed-off-by: default avatarScott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: default avatarSonic Zhang <sonic.zhang@analog.com>
parent 53086bef
No related branches found
No related tags found
No related merge requests found
...@@ -144,10 +144,8 @@ void spi_set_speed(struct spi_slave *slave, uint hz) ...@@ -144,10 +144,8 @@ void spi_set_speed(struct spi_slave *slave, uint hz)
u32 baud; u32 baud;
sclk = get_sclk(); sclk = get_sclk();
baud = sclk / (2 * hz);
/* baud should be rounded up */ /* baud should be rounded up */
if (sclk % (2 * hz)) baud = DIV_ROUND_UP(sclk, 2 * hz);
baud += 1;
if (baud < 2) if (baud < 2)
baud = 2; baud = 2;
else if (baud > (u16)-1) else if (baud > (u16)-1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment