From: Axel Lin Date: Fri, 12 Jul 2013 09:41:08 +0000 (+0800) Subject: spi: fsl_espi: Use DIV_ROUND_UP instead of open-coded X-Git-Tag: v2013.10-rc1~39^2~12 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a444aa7a1cd9c209e6621fe0531f61f2f7c1a7e9;p=oweals%2Fu-boot.git spi: fsl_espi: Use DIV_ROUND_UP instead of open-coded Use DIV_ROUND_UP to simplify the code. Signed-off-by: Axel Lin --- diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c index fc0a58be29..c883d3cac0 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);