mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
gpio: Fix wrong rounding in gpio-menz127
[ Upstream commit7279d99175] men_z127_debounce() tries to round up and down, but uses functions which are only suitable when the divider is a power of two, which is not the case. Use the appropriate ones. Found by static check. Compile tested. Fixes:f436bc2726("gpio: add driver for MEN 16Z127 GPIO controller") Signed-off-by: Nadav Amit <namit@vmware.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
5bcbbadf6a
commit
de6ccdbd77
@@ -56,9 +56,9 @@ static int men_z127_debounce(struct gpio_chip *gc, unsigned gpio,
|
||||
rnd = fls(debounce) - 1;
|
||||
|
||||
if (rnd && (debounce & BIT(rnd - 1)))
|
||||
debounce = round_up(debounce, MEN_Z127_DB_MIN_US);
|
||||
debounce = roundup(debounce, MEN_Z127_DB_MIN_US);
|
||||
else
|
||||
debounce = round_down(debounce, MEN_Z127_DB_MIN_US);
|
||||
debounce = rounddown(debounce, MEN_Z127_DB_MIN_US);
|
||||
|
||||
if (debounce > MEN_Z127_DB_MAX_US)
|
||||
debounce = MEN_Z127_DB_MAX_US;
|
||||
|
||||
Reference in New Issue
Block a user