lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20170327143108.GB12674@uda0271908>
Date:   Mon, 27 Mar 2017 09:31:08 -0500
From:   Bin Liu <b-liu@...com>
To:     Ivan Safonov <insafonov@...il.com>
CC:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        <linux-usb@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] usb: musb: cppi_dma.c: use DIV_ROUND_UP macro in
 cppi_next_(r|t)x_segment()

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@...il.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
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ