Skip to content

Commit

Permalink
usb: musb: cppi_dma.c: use DIV_ROUND_UP macro in cppi_next_(r|t)x_seg…
Browse files Browse the repository at this point in the history
…ment()

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>
  • Loading branch information
Ivan Safonov authored and Greg Kroah-Hartman committed Apr 18, 2017
1 parent ec1dafe commit f5332b0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions drivers/usb/musb/cppi_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f5332b0

Please sign in to comment.