aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/drivers/amplc_pci230.c
diff options
context:
space:
mode:
authorAmitoj Kaur Chawla <amitoj1606@gmail.com>2016-02-19 20:57:15 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-20 15:25:58 -0800
commit2ead7b32aadc83833d7cf6e9751ef56b89e90462 (patch)
treedf9720f1dc9dfe3609b5644afed33b1358b8fa4d /drivers/staging/comedi/drivers/amplc_pci230.c
parentstaging: comedi: drivers: Remove unnecessary else following return (diff)
downloadlinux-dev-2ead7b32aadc83833d7cf6e9751ef56b89e90462.tar.xz
linux-dev-2ead7b32aadc83833d7cf6e9751ef56b89e90462.zip
staging: comedi: drivers: Use DIV_ROUND_CLOSEST
The kernel.h macro DIV_ROUND_CLOSEST performs the computation `(x +d/2)/d` but is perhaps more readable. The Coccinelle script used is as follows: // <smpl> @@ expression x,__divisor; @@ - (((x) + ((__divisor) / 2)) / (__divisor)) + DIV_ROUND_CLOSEST(x,__divisor) // </smpl> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers/amplc_pci230.c')
-rw-r--r--drivers/staging/comedi/drivers/amplc_pci230.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c
index 4b39f6960c0a..d1fe88a6133f 100644
--- a/drivers/staging/comedi/drivers/amplc_pci230.c
+++ b/drivers/staging/comedi/drivers/amplc_pci230.c
@@ -637,7 +637,7 @@ static unsigned int pci230_divide_ns(uint64_t ns, unsigned int timebase,
switch (flags & CMDF_ROUND_MASK) {
default:
case CMDF_ROUND_NEAREST:
- div += (rem + (timebase / 2)) / timebase;
+ div += DIV_ROUND_CLOSEST(rem, timebase);
break;
case CMDF_ROUND_DOWN:
break;