gpio: Fix wrong rounding in gpio-menz127
authorNadav Amit <namit@vmware.com>
Mon, 4 Jun 2018 13:58:14 +0000 (06:58 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Oct 2018 00:01:48 +0000 (17:01 -0700)
[ Upstream commit 7279d9917560bbd0d82813d6bf00490a82c06783 ]

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: f436bc2726c64 ("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>
drivers/gpio/gpio-menz127.c

index a1210e33057120668d50129447e5af540366d16b..95061d25895b5ea8bdfebd4ecb55eb3e6e3272e5 100644 (file)
@@ -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;