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: Andy Shevchenko , Mika Westerberg , Linus Walleij , Sasha Levin Subject: [PATCH AUTOSEL 4.9 33/34] gpiolib: Respect error code of ->get_direction() Date: Sat, 15 Sep 2018 01:34:47 +0000 Message-ID: <20180915013422.180023-33-alexander.levin@microsoft.com> References: <20180915013422.180023-1-alexander.levin@microsoft.com> In-Reply-To: <20180915013422.180023-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: 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 dd0076497463..f9b3f95253d1 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2749,6 +2749,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