Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966548AbdCYG5W (ORCPT ); Sat, 25 Mar 2017 02:57:22 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:35592 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937153AbdCYG5V (ORCPT ); Sat, 25 Mar 2017 02:57:21 -0400 From: Ivan Safonov To: Bin Liu Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, insafonov@gmail.com Subject: [PATCH v2] usb: musb: cppi_dma.c: use DIV_ROUND_UP macro in cppi_next_(r|t)x_segment() Date: Sat, 25 Mar 2017 12:52:58 +0300 Message-Id: <20170325095258.7088-1-insafonov@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170324182749.GB19814@uda0271908> References: <20170324182749.GB19814@uda0271908> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1217 Lines: 42 DIV_ROUND_UP is bit useful than series of "/" and "%" operations. Replace "/%" sequence with DIV_ROUND_UP macro. Signed-off-by: Ivan Safonov --- 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