public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] spi: bfin_spi: Use DIV_ROUND_UP instead of open-coded
@ 2013-07-12  9:39 Axel Lin
  2013-07-12  9:41 ` [U-Boot] [PATCH 2/3] spi: fsl_espi: " Axel Lin
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Axel Lin @ 2013-07-12  9:39 UTC (permalink / raw)
  To: u-boot

Use DIV_ROUND_UP to simplify the code.

Signed-off-by: Axel Lin <axel.lin@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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-08-06 18:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-12  9:39 [U-Boot] [PATCH 1/3] spi: bfin_spi: Use DIV_ROUND_UP instead of open-coded Axel Lin
2013-07-12  9:41 ` [U-Boot] [PATCH 2/3] spi: fsl_espi: " Axel Lin
2013-08-06 18:49   ` Jagan Teki
2013-08-06 18:56     ` Jagan Teki
2013-07-12  9:42 ` [U-Boot] [PATCH 3/3] spi: mpc8xxx_spi: " Axel Lin
2013-08-06 18:49   ` Jagan Teki
2013-08-06 18:55     ` Jagan Teki
2013-07-15  7:58 ` [U-Boot] [PATCH 1/3] spi: bfin_spi: " Sonic Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox