diff options
author | Tapasweni Pathak <tapaswenipathak@gmail.com> | 2014-10-08 21:26:57 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-10-20 06:29:20 +0400 |
commit | dea7503ac4c53edfd0d25d6a1c8b360b3db700d7 (patch) | |
tree | 666f87e918a6d55f80c3c04aa1a34bf8e7977ab1 /drivers/staging/octeon-usb | |
parent | ffceca8c1739938b58cdc5ce375d33a13150f7af (diff) | |
download | linux-dea7503ac4c53edfd0d25d6a1c8b360b3db700d7.tar.xz |
staging: octeon-usb: use DIV_ROUND_UP
The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /
(d)) but is perhaps more readable.
Coccinelle script used :
// <smpl>
@haskernel@
@@
@depends on haskernel@
expression n,d;
@@
(
- (n + d - 1) / d
+ DIV_ROUND_UP(n,d)
|
- (n + (d - 1)) / d
+ DIV_ROUND_UP(n,d)
)
@depends on haskernel@
expression n,d;
@@
- DIV_ROUND_UP((n),d)
+ DIV_ROUND_UP(n,d)
@depends on haskernel@
expression n,d;
@@
- DIV_ROUND_UP(n,(d))
+ DIV_ROUND_UP(n,d)
// </smpl>
Signed-off-by: Tapasweni Pathak <tapaswenipathak@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/octeon-usb')
-rw-r--r-- | drivers/staging/octeon-usb/octeon-hcd.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 6ddde6af7e3a..7ac64efc6520 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -743,7 +743,7 @@ static int cvmx_usb_initialize(struct cvmx_usb_state *usb, * such that USB is as close as possible to 125Mhz */ { - int divisor = (octeon_get_clock_rate()+125000000-1)/125000000; + int divisor = DIV_ROUND_UP(octeon_get_clock_rate(), 125000000); /* Lower than 4 doesn't seem to work properly */ if (divisor < 4) divisor = 4; @@ -1606,8 +1606,8 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_state *usb, * Calculate the number of packets to transfer. If the length is zero * we still need to transfer one packet */ - packets_to_transfer = (bytes_to_transfer + pipe->max_packet - 1) / - pipe->max_packet; + packets_to_transfer = DIV_ROUND_UP(bytes_to_transfer, + pipe->max_packet); if (packets_to_transfer == 0) packets_to_transfer = 1; else if ((packets_to_transfer > 1) && @@ -1852,8 +1852,7 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_state *usb, * zero we still need to transfer one packet */ packets_to_transfer = - (bytes_to_transfer + pipe->max_packet - 1) / - pipe->max_packet; + DIV_ROUND_UP(bytes_to_transfer, pipe->max_packet); if (packets_to_transfer == 0) packets_to_transfer = 1; else if ((packets_to_transfer > 1) && |