mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 23:53:32 +00:00
staging: comedi: Using macro DIV_ROUND_UP
The macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /(d)). It clarifies the divisor calculations. This occurence was detected using the coccinelle script: @@ expression e1; expression e2; @@ ( - ((e1) + e2 - 1) / (e2) + DIV_ROUND_UP(e1,e2) | - ((e1) + (e2 - 1)) / (e2) + DIV_ROUND_UP(e1,e2) ) Signed-off-by: simran singhal <singhalsimran0@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
427fda4e5c
commit
7dfc697124
2 changed files with 2 additions and 2 deletions
|
@ -502,7 +502,7 @@ static int apci3xxx_ai_ns_to_timer(struct comedi_device *dev,
|
|||
timer = *ns / base;
|
||||
break;
|
||||
case CMDF_ROUND_UP:
|
||||
timer = (*ns + base - 1) / base;
|
||||
timer = DIV_ROUND_UP(*ns, base);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -2007,7 +2007,7 @@ static unsigned int get_divisor(unsigned int ns, unsigned int flags)
|
|||
|
||||
switch (flags & CMDF_ROUND_MASK) {
|
||||
case CMDF_ROUND_UP:
|
||||
divisor = (ns + TIMER_BASE - 1) / TIMER_BASE;
|
||||
divisor = DIV_ROUND_UP(ns, TIMER_BASE);
|
||||
break;
|
||||
case CMDF_ROUND_DOWN:
|
||||
divisor = ns / TIMER_BASE;
|
||||
|
|
Loading…
Reference in a new issue