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] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 24 Mar 2017 13:27:49 -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] usb: musb: cppi_dma.c: use DIV_ROUND_UP macro in
 cppi_next_(r|t)x_segment()

On Wed, Feb 15, 2017 at 11:12:36AM +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>
> ---
>  drivers/usb/musb/cppi_dma.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
> index 1ae48e6..d376188 100644
> --- a/drivers/usb/musb/cppi_dma.c
> +++ b/drivers/usb/musb/cppi_dma.c
> @@ -582,9 +582,9 @@ 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++;
> +		n_bds = DIV_ROUND_UP(length, maxpacket);
> +		if (length == 0)
> +			n_bds = 1;

Is it a little better logically if

+		if (length)
+			n_bds = DIV_ROUND_UP(length, maxpacket);
+		else
+			n_bds = 1;

or

+		n_bds = length ? DIV_ROUND_UP(length, maxpacket) : 1;

Regards,
-Bin.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ