Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965102AbdCXS2P (ORCPT ); Fri, 24 Mar 2017 14:28:15 -0400 Received: from lelnx193.ext.ti.com ([198.47.27.77]:22125 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935821AbdCXS2F (ORCPT ); Fri, 24 Mar 2017 14:28:05 -0400 Date: Fri, 24 Mar 2017 13:27:49 -0500 From: Bin Liu To: Ivan Safonov CC: Greg Kroah-Hartman , , Subject: Re: [PATCH] usb: musb: cppi_dma.c: use DIV_ROUND_UP macro in cppi_next_(r|t)x_segment() Message-ID: <20170324182749.GB19814@uda0271908> Mail-Followup-To: Bin Liu , Ivan Safonov , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <20170215081236.19340-1-insafonov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20170215081236.19340-1-insafonov@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1032 Lines: 37 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 > --- > 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.