From: Ivan Safonov <[email protected]>

DIV_ROUND_UP is bit useful than series of "/" and "%" operations.
Replace "/%" sequence with DIV_ROUND_UP macro.

Signed-off-by: Ivan Safonov <[email protected]>
Signed-off-by: Bin Liu <[email protected]>
---
 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 c4fabe952ca6..a13bd3625043 100644
--- a/drivers/usb/musb/cppi_dma.c
+++ b/drivers/usb/musb/cppi_dma.c
@@ -582,9 +582,10 @@ static inline int cppi_autoreq_update(struct cppi_channel 
*rx,
                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 @@ static inline int cppi_autoreq_update(struct cppi_channel 
*rx,
                        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;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to