From dfa5ec79d28300b0d1fdeafbeebf0a6b721edc38 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Tue, 4 Mar 2008 15:25:11 -0800 Subject: 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/) // @haskernel@ @@ #include @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) // Signed-off-by: Julia Lawall Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/ftdi_sio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/usb/serial/ftdi_sio.c') diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 4643212eb95..496c0c93ad8 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) data_offset = priv->write_offset; if (data_offset > 0) { /* Subtract the control bytes */ - countback -= (data_offset * ((countback + (PKTSZ - 1)) / PKTSZ)); + countback -= (data_offset * DIV_ROUND_UP(countback, PKTSZ)); } spin_lock_irqsave(&priv->tx_lock, flags); --priv->tx_outstanding_urbs; @@ -1506,7 +1506,7 @@ static void ftdi_read_bulk_callback (struct urb *urb) /* count data bytes, but not status bytes */ countread = urb->actual_length; - countread -= 2 * ((countread + (PKTSZ - 1)) / PKTSZ); + countread -= 2 * DIV_ROUND_UP(countread, PKTSZ); spin_lock_irqsave(&priv->rx_lock, flags); priv->rx_bytes += countread; spin_unlock_irqrestore(&priv->rx_lock, flags); -- cgit v1.2.3