From: Jagan Teki <jagannadh.teki@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/3] spi: fsl_espi: Use DIV_ROUND_UP instead of open-coded
Date: Wed, 07 Aug 2013 00:19:39 +0530 [thread overview]
Message-ID: <52014543.4020901@gmail.com> (raw)
In-Reply-To: <1373622068.24016.4.camel@phoenix>
On 12-07-2013 15:11, Axel Lin wrote:
> Use DIV_ROUND_UP to simplify the code.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> drivers/spi/fsl_espi.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c
> index 28609ee..e20ab9f 100644
> --- a/drivers/spi/fsl_espi.c
> +++ b/drivers/spi/fsl_espi.c
> @@ -234,15 +234,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);
>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
--
Thanks,
Jagan.
next prev parent reply other threads:[~2013-08-06 18:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52014543.4020901@gmail.com \
--to=jagannadh.teki@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox