summaryrefslogtreecommitdiff
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorIvan Safonov <insafonov@gmail.com>2017-04-16 23:21:15 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-04-18 16:48:26 +0200
commitf5332b000707b0b415291901846c4a8fc24f6a2e (patch)
tree5e0f88ab36581200608c884301c24a4f7cb0aabb /drivers/usb/musb
parentec1dafe8ec5f846d6b1b280309d8b03d25b096fd (diff)
usb: musb: cppi_dma.c: use DIV_ROUND_UP macro in cppi_next_(r|t)x_segment()
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> Signed-off-by: Bin Liu <b-liu@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/cppi_dma.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c
index c4fabe952ca6..a13bd3625043 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;