summaryrefslogtreecommitdiff
path: root/drivers/spi/fsl_espi.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2013-07-12 17:41:08 +0800
committerJagannadha Sutradharudu Teki <jaganna@xilinx.com>2013-08-06 23:58:09 +0530
commita444aa7a1cd9c209e6621fe0531f61f2f7c1a7e9 (patch)
treed222466304c96db4babf249df957473bfad6f496 /drivers/spi/fsl_espi.c
parentd05bfd0586ccebe96e31976459c8ef45ec65e109 (diff)
downloadu-boot-imx-a444aa7a1cd9c209e6621fe0531f61f2f7c1a7e9.zip
u-boot-imx-a444aa7a1cd9c209e6621fe0531f61f2f7c1a7e9.tar.gz
u-boot-imx-a444aa7a1cd9c209e6621fe0531f61f2f7c1a7e9.tar.bz2
spi: fsl_espi: Use DIV_ROUND_UP instead of open-coded
Use DIV_ROUND_UP to simplify the code. Signed-off-by: Axel Lin <axel.lin@ingics.com>
Diffstat (limited to 'drivers/spi/fsl_espi.c')
-rw-r--r--drivers/spi/fsl_espi.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c
index fc0a58b..c883d3c 100644
--- a/drivers/spi/fsl_espi.c
+++ b/drivers/spi/fsl_espi.c
@@ -221,15 +221,13 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *data_out,
slave->bus, slave->cs, *(uint *) dout,
dout, *(uint *) din, din, len);
- num_chunks = data_len / max_tran_len +
- (data_len % max_tran_len ? 1 : 0);
+ num_chunks = DIV_ROUND_UP(data_len, max_tran_len);
while (num_chunks--) {
if (data_in)
din = buffer + rx_offset;
dout = buffer;
tran_len = min(data_len , max_tran_len);
- num_blks = (tran_len + cmd_len) / 4 +
- ((tran_len + cmd_len) % 4 ? 1 : 0);
+ num_blks = DIV_ROUND_UP(tran_len + cmd_len, 4);
num_bytes = (tran_len + cmd_len) % 4;
fsl->data_len = tran_len + cmd_len;
spi_cs_activate(slave);