linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: Fix wrong rounding in gpio-menz127
@ 2018-06-04 13:58 Nadav Amit
  2018-06-12  8:40 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Nadav Amit @ 2018-06-04 13:58 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-gpio, linux-kernel, Nadav Amit

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>
---
 drivers/gpio/gpio-menz127.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-menz127.c b/drivers/gpio/gpio-menz127.c
index e1037582e34d..b2635326546e 100644
--- a/drivers/gpio/gpio-menz127.c
+++ b/drivers/gpio/gpio-menz127.c
@@ -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;
-- 
2.17.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpio: Fix wrong rounding in gpio-menz127
  2018-06-04 13:58 [PATCH] gpio: Fix wrong rounding in gpio-menz127 Nadav Amit
@ 2018-06-12  8:40 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2018-06-12  8:40 UTC (permalink / raw)
  To: Nadav Amit; +Cc: open list:GPIO SUBSYSTEM, linux-kernel

On Mon, Jun 4, 2018 at 3:58 PM, Nadav Amit <namit@vmware.com> wrote:

> 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>

Applied as a non-critical fix as I have not error reports.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-12  8:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-04 13:58 [PATCH] gpio: Fix wrong rounding in gpio-menz127 Nadav Amit
2018-06-12  8:40 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).