mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bin Liu <b-liu@ti.com>
To: Ivan Safonov <insafonov@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] usb: musb: cppi_dma.c: use DIV_ROUND_UP macro in cppi_next_(r|t)x_segment()
Date: Mon, 27 Mar 2017 09:31:08 -0500	[thread overview]
Message-ID: <20170327143108.GB12674@uda0271908> (raw)
In-Reply-To: <20170325095258.7088-1-insafonov@gmail.com>

On Sat, Mar 25, 2017 at 12:52:58PM +0300, Ivan Safonov wrote:
> DIV_ROUND_UP is bit useful than series of "/" and "%" operations.
> Replace "/%" sequence with DIV_ROUND_UP macro.
> 
> Signed-off-by: Ivan Safonov <insafonov@gmail.com>

Applied. Thanks.
-Bin.

> ---
> Changes in v2:
>  - little style fix
> 
>  drivers/usb/musb/cppi_dma.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
> index c4fabe95..a13bd36 100644
> --- a/drivers/usb/musb/cppi_dma.c
> +++ b/drivers/usb/musb/cppi_dma.c
> @@ -582,9 +582,10 @@ cppi_next_tx_segment(struct musb *musb, struct cppi_channel *tx)
>  		maxpacket = length;
>  		n_bds = 1;
>  	} else {
> -		n_bds = length / maxpacket;
> -		if (!length || (length % maxpacket))
> -			n_bds++;
> +		if (length)
> +			n_bds = DIV_ROUND_UP(length, maxpacket);
> +		else
> +			n_bds = 1;
>  		n_bds = min(n_bds, (unsigned) NUM_TXCHAN_BD);
>  		length = min(n_bds * maxpacket, length);
>  	}
> @@ -790,9 +791,7 @@ cppi_next_rx_segment(struct musb *musb, struct cppi_channel *rx, int onepacket)
>  			n_bds = 0xffff / maxpacket;
>  			length = n_bds * maxpacket;
>  		} else {
> -			n_bds = length / maxpacket;
> -			if (length % maxpacket)
> -				n_bds++;
> +			n_bds = DIV_ROUND_UP(length, maxpacket);
>  		}
>  		if (n_bds == 1)
>  			onepacket = 1;
> -- 
> 2.10.2
> 

      reply	other threads:[~2017-03-27 15:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-15  8:12 [PATCH] " Ivan Safonov
2017-03-24 18:27 ` Bin Liu
2017-03-25  9:52   ` [PATCH v2] " Ivan Safonov
2017-03-27 14:31     ` Bin Liu [this message]

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=20170327143108.GB12674@uda0271908 \
    --to=b-liu@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=insafonov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®