]> www.infradead.org Git - users/dwmw2/linux.git/commit
staging: comedi: dt3000: Fix rounding up of timer divisor
authorIan Abbott <abbotti@mev.co.uk>
Mon, 12 Aug 2019 12:08:14 +0000 (13:08 +0100)
committerSasha Levin <sashal@kernel.org>
Sun, 25 Aug 2019 14:10:34 +0000 (10:10 -0400)
commit2244a42351a428258d72f53f0a2cc064b037abad
tree10b6a36c00e6549273f83c0a7cbba0a4d9b750ed
parent7961db77b2135740f683418397b06fbdae099a25
staging: comedi: dt3000: Fix rounding up of timer divisor

commit 8e2a589a3fc36ce858d42e767c3bcd8fc62a512b upstream.

`dt3k_ns_to_timer()` determines the prescaler and divisor to use to
produce a desired timing period.  It is influenced by a rounding mode
and can round the divisor up, down, or to the nearest value.  However,
the code for rounding up currently does the same as rounding down!  Fix
ir by using the `DIV_ROUND_UP()` macro to calculate the divisor when
rounding up.

Also, change the types of the `divider`, `base` and `prescale` variables
from `int` to `unsigned int` to avoid mixing signed and unsigned types
in the calculations.

Also fix a typo in a nearby comment: "improvment" => "improvement".

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20190812120814.21188-1-abbotti@mev.co.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/dt3000.c