From patchwork Tue Jul 3 00:38:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 938295 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41KQGZ2q8Sz9s29 for ; Tue, 3 Jul 2018 10:38:46 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752963AbeGCAip (ORCPT ); Mon, 2 Jul 2018 20:38:45 -0400 Received: from mga09.intel.com ([134.134.136.24]:59413 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752770AbeGCAio (ORCPT ); Mon, 2 Jul 2018 20:38:44 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jul 2018 17:38:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,301,1526367600"; d="scan'208";a="53975210" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 02 Jul 2018 17:38:28 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DFCEAF7; Tue, 3 Jul 2018 03:38:31 +0300 (EEST) From: Andy Shevchenko To: Linus Walleij , linux-gpio@vger.kernel.org Cc: Andy Shevchenko , Mika Westerberg Subject: [PATCH v1] gpiolib: Respect error code of ->get_direction() Date: Tue, 3 Jul 2018 03:38:31 +0300 Message-Id: <20180703003831.27833-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.18.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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. Note, this doesn't change overall behavior because error code used to be recognized as direction output which anyway led to an abortion of request. Fixes: 9c10280d85c1 ("gpio: flush direction status in gpiochip_lock_as_irq()") Signed-off-by: Andy Shevchenko Cc: Mika Westerberg --- drivers/gpio/gpiolib.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index c6f77e806cb8..0ff89b3f354b 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3264,6 +3264,12 @@ int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset) if (!chip->can_sleep && chip->get_direction) { int dir = chip->get_direction(chip, offset); + 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