From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sn1nam01on0098.outbound.protection.outlook.com ([104.47.32.98]:58848 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725832AbeIOGvB (ORCPT ); Sat, 15 Sep 2018 02:51:01 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Andy Shevchenko , Mika Westerberg , Linus Walleij , Sasha Levin Subject: [PATCH AUTOSEL 4.14 54/57] gpiolib: Respect error code of ->get_direction() Date: Sat, 15 Sep 2018 01:33:02 +0000 Message-ID: <20180915013223.179909-54-alexander.levin@microsoft.com> References: <20180915013223.179909-1-alexander.levin@microsoft.com> In-Reply-To: <20180915013223.179909-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: Andy Shevchenko [ Upstream commit 36b312792b97933dc07abe074f50941199bd357c ] In case we try to lock GPIO pin as IRQ when something going wrong we print a misleading message. Correct this by checking an error code from ->get_direction() in gpiochip_lock_as_irq() and printing a corresponding message. Signed-off-by: Andy Shevchenko Cc: Mika Westerberg Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/gpio/gpiolib.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 7e0bfd7347f6..e5bf3e774439 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2811,6 +2811,12 @@ int gpiochip_lock_as_irq(struct gpio_chip *chip, uns= igned int offset) if (!chip->can_sleep && chip->get_direction) { int dir =3D chip->get_direction(chip, offset); =20 + if (dir < 0) { + chip_err(chip, "%s: cannot get GPIO direction\n", + __func__); + return dir; + } + if (dir) clear_bit(FLAG_IS_OUT, &desc->flags); else --=20 2.17.1