diff options
author | Julia Lawall <julia@diku.dk> | 2008-03-04 18:25:11 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-04-25 00:16:39 -0400 |
commit | dfa5ec79d28300b0d1fdeafbeebf0a6b721edc38 (patch) | |
tree | bd379b8bd572186c9274e31e5c3ab3b829512106 /drivers/usb/serial/ftdi_sio.c | |
parent | 3d71fe0bb29a3fbffdbe69dd0696927b6a23dd4e (diff) |
USB: use DIV_ROUND_UP
The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /
(d)) but is perhaps more readable.
An extract of the semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@haskernel@
@@
#include <linux/kernel.h>
@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: Julia Lawall <julia@diku.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/ftdi_sio.c')
-rw-r--r-- | drivers/usb/serial/ftdi_sio.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 4643212eb959..496c0c93ad81 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -1406,7 +1406,7 @@ static void ftdi_write_bulk_callback (struct urb *urb) | |||
1406 | data_offset = priv->write_offset; | 1406 | data_offset = priv->write_offset; |
1407 | if (data_offset > 0) { | 1407 | if (data_offset > 0) { |
1408 | /* Subtract the control bytes */ | 1408 | /* Subtract the control bytes */ |
1409 | countback -= (data_offset * ((countback + (PKTSZ - 1)) / PKTSZ)); | 1409 | countback -= (data_offset * DIV_ROUND_UP(countback, PKTSZ)); |
1410 | } | 1410 | } |
1411 | spin_lock_irqsave(&priv->tx_lock, flags); | 1411 | spin_lock_irqsave(&priv->tx_lock, flags); |
1412 | --priv->tx_outstanding_urbs; | 1412 | --priv->tx_outstanding_urbs; |
@@ -1506,7 +1506,7 @@ static void ftdi_read_bulk_callback (struct urb *urb) | |||
1506 | 1506 | ||
1507 | /* count data bytes, but not status bytes */ | 1507 | /* count data bytes, but not status bytes */ |
1508 | countread = urb->actual_length; | 1508 | countread = urb->actual_length; |
1509 | countread -= 2 * ((countread + (PKTSZ - 1)) / PKTSZ); | 1509 | countread -= 2 * DIV_ROUND_UP(countread, PKTSZ); |
1510 | spin_lock_irqsave(&priv->rx_lock, flags); | 1510 | spin_lock_irqsave(&priv->rx_lock, flags); |
1511 | priv->rx_bytes += countread; | 1511 | priv->rx_bytes += countread; |
1512 | spin_unlock_irqrestore(&priv->rx_lock, flags); | 1512 | spin_unlock_irqrestore(&priv->rx_lock, flags); |