From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Nadav Amit , Linus Walleij , Sasha Levin Subject: [PATCH AUTOSEL 4.18 120/136] gpio: Fix wrong rounding in gpio-menz127 Date: Mon, 17 Sep 2018 03:01:27 +0000 Message-ID: <20180917030006.245495-120-alexander.levin@microsoft.com> References: <20180917030006.245495-1-alexander.levin@microsoft.com> In-Reply-To: <20180917030006.245495-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: From: Nadav Amit [ 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 Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- 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, unsign= ed gpio, rnd =3D fls(debounce) - 1; =20 if (rnd && (debounce & BIT(rnd - 1))) - debounce =3D round_up(debounce, MEN_Z127_DB_MIN_US); + debounce =3D roundup(debounce, MEN_Z127_DB_MIN_US); else - debounce =3D round_down(debounce, MEN_Z127_DB_MIN_US); + debounce =3D rounddown(debounce, MEN_Z127_DB_MIN_US); =20 if (debounce > MEN_Z127_DB_MAX_US) debounce =3D MEN_Z127_DB_MAX_US; --=20 2.17.1