Use DIV_ROUND_UP to simplify the code.

Signed-off-by: Axel Lin <axel....@ingics.com>
---
 drivers/spi/bfin_spi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/spi/bfin_spi.c b/drivers/spi/bfin_spi.c
index a9a4d92..f7192c2 100644
--- a/drivers/spi/bfin_spi.c
+++ b/drivers/spi/bfin_spi.c
@@ -144,10 +144,8 @@ void spi_set_speed(struct spi_slave *slave, uint hz)
        u32 baud;
 
        sclk = get_sclk();
-       baud = sclk / (2 * hz);
        /* baud should be rounded up */
-       if (sclk % (2 * hz))
-               baud += 1;
+       baud = DIV_ROUND_UP(sclk, 2 * hz);
        if (baud < 2)
                baud = 2;
        else if (baud > (u16)-1)
-- 
1.8.1.2



_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to