From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam02on0129.outbound.protection.outlook.com ([104.47.36.129]:32192 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728849AbeIQIbq (ORCPT ); Mon, 17 Sep 2018 04:31:46 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Nadav Amit , Linus Walleij , Sasha Levin Subject: [PATCH AUTOSEL 4.9 54/57] gpio: Fix wrong rounding in gpio-menz127 Date: Mon, 17 Sep 2018 03:04:17 +0000 Message-ID: <20180917030340.378-54-alexander.levin@microsoft.com> References: <20180917030340.378-1-alexander.levin@microsoft.com> In-Reply-To: <20180917030340.378-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: stable-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 a1210e330571..95061d25895b 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