Commit d9798aa6 authored by Tapasweni Pathak's avatar Tapasweni Pathak Committed by Greg Kroah-Hartman

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:
// <smpl>
@haskernel@
@@
@depends on haskernel@
expression x,__divisor;
@@
- (((x) + ((__divisor) / 2)) / (__divisor))
+ DIV_ROUND_CLOSEST(x,__divisor)
// </smpl>
Signed-off-by: default avatarTapasweni Pathak <tapaswenipathak@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dea7503a
...@@ -1970,7 +1970,7 @@ static int s626_ns_to_timer(unsigned int *nanosec, unsigned int flags) ...@@ -1970,7 +1970,7 @@ static int s626_ns_to_timer(unsigned int *nanosec, unsigned int flags)
switch (flags & CMDF_ROUND_MASK) { switch (flags & CMDF_ROUND_MASK) {
case CMDF_ROUND_NEAREST: case CMDF_ROUND_NEAREST:
default: default:
divider = (*nanosec + base / 2) / base; divider = DIV_ROUND_CLOSEST(*nanosec, base);
break; break;
case CMDF_ROUND_DOWN: case CMDF_ROUND_DOWN:
divider = (*nanosec) / base; divider = (*nanosec) / base;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment