Skip to content

Commit

Permalink
gpio: Fix wrong rounding in gpio-menz127
Browse files Browse the repository at this point in the history
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: f436bc2 ("gpio: add driver for MEN 16Z127 GPIO controller")
Signed-off-by: Nadav Amit <[email protected]>
Signed-off-by: Linus Walleij <[email protected]>
  • Loading branch information
anadav authored and linusw committed Jun 18, 2018
1 parent ce397d2 commit 7279d99
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/gpio/gpio-menz127.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7279d99

Please sign in to comment.